Declare missing types and other minor improvements in run-tests.php (#12573)

* refactor: declare missing types and other minor improvements.

* refactor: declare missing types and other minor improvements.

* refactor: declare missing types and other minor improvements.

* refactor: declare missing types and other minor improvements.

---------

Co-authored-by: Marcos Marcolin <marcos@ixcsoft.com.br>
This commit is contained in:
Marcos Marcolin 2023-10-31 10:56:06 -03:00 committed by GitHub
parent 60a33af3c4
commit 06b009c5a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,7 @@
*/ */
/* Temporary variables while this file is being refactored. */ /* Temporary variables while this file is being refactored. */
/** @var ?JUnit */ /** @var ?JUnit $junit */
$junit = null; $junit = null;
/* End temporary variables. */ /* End temporary variables. */
@ -166,7 +166,7 @@ function main(): void
global $context_line_count; global $context_line_count;
// Temporary for the duration of refactoring // Temporary for the duration of refactoring
/** @var JUnit */ /** @var JUnit $junit */
global $junit; global $junit;
define('IS_WINDOWS', substr(PHP_OS, 0, 3) == "WIN"); define('IS_WINDOWS', substr(PHP_OS, 0, 3) == "WIN");
@ -465,7 +465,6 @@ function main(): void
case 'g': case 'g':
$SHOW_ONLY_GROUPS = explode(",", $argv[++$i]); $SHOW_ONLY_GROUPS = explode(",", $argv[++$i]);
break; break;
//case 'h'
case '--keep-all': case '--keep-all':
foreach ($cfgfiles as $file) { foreach ($cfgfiles as $file) {
$cfg['keep'][$file] = true; $cfg['keep'][$file] = true;
@ -1842,7 +1841,7 @@ function run_test(string $php, $file, array $env): string
global $show_progress; global $show_progress;
// Temporary // Temporary
/** @var JUnit */ /** @var JUnit $junit */
global $junit; global $junit;
static $skipCache; static $skipCache;
@ -3354,9 +3353,8 @@ class JUnit
fwrite($this->fp, $xml); fwrite($this->fp, $xml);
} }
private function getSuitesXML(string $suite_name = ''): string private function getSuitesXML(): string
{ {
// FIXME: $suite_name gets overwritten
$result = ''; $result = '';
foreach ($this->suites as $suite_name => $suite) { foreach ($this->suites as $suite_name => $suite) {
@ -3649,10 +3647,10 @@ class SkipCache
class RuntestsValgrind class RuntestsValgrind
{ {
protected $version = ''; protected string $version;
protected $header = ''; protected string $header;
protected $version_3_8_0 = false; protected bool $version_3_8_0;
protected $tool = null; protected string $tool;
public function getHeader(): string public function getHeader(): string
{ {
@ -3665,7 +3663,7 @@ class RuntestsValgrind
$header = system_with_timeout("valgrind --tool={$this->tool} --version", $environment); $header = system_with_timeout("valgrind --tool={$this->tool} --version", $environment);
if (!$header) { if (!$header) {
error("Valgrind returned no version info for {$this->tool}, cannot proceed.\n". error("Valgrind returned no version info for {$this->tool}, cannot proceed.\n".
"Please check if Valgrind is installed and the tool is named correctly."); "Please check if Valgrind is installed and the tool is named correctly.");
} }
$count = 0; $count = 0;
$version = preg_replace("/valgrind-(\d+)\.(\d+)\.(\d+)([.\w_-]+)?(\s+)/", '$1.$2.$3', $header, 1, $count); $version = preg_replace("/valgrind-(\d+)\.(\d+)\.(\d+)([.\w_-]+)?(\s+)/", '$1.$2.$3', $header, 1, $count);