Skip to content

Commit 99ff52f

Browse files
committed
Remove weird count usage from run-tests
1 parent 501a72e commit 99ff52f

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

run-tests.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,27 +1851,34 @@ function run_test($php, $file, $env)
18511851
// the redirect section allows a set of tests to be reused outside of
18521852
// a given test dir
18531853
if ($bork_info === null) {
1854-
if (isset($section_text['REDIRECTTEST'])) {
1854+
if (array_key_exists('REDIRECTTEST', $section_text)) {
18551855

18561856
if ($IN_REDIRECT) {
18571857
$bork_info = "Can't redirect a test from within a redirected test";
18581858
}
18591859

18601860
} else {
18611861

1862-
if (!isset($section_text['PHPDBG']) && @count($section_text['FILE']) + @count($section_text['FILEEOF']) + @count($section_text['FILE_EXTERNAL']) != 1) {
1862+
if (
1863+
array_key_exists('PHPDBG', $section_text)
1864+
&& (
1865+
array_key_exists('FILE', $section_text)
1866+
xor array_key_exists('FILEEOF', $section_text)
1867+
xor array_key_exists('FILE_EXTERNAL', $section_text)
1868+
) === false
1869+
) {
18631870
$bork_info = "missing section --FILE--";
18641871
}
18651872

1866-
if (isset($section_text['FILEEOF'])) {
1873+
if (array_key_exists('FILEEOF', $section_text)) {
18671874
$section_text['FILE'] = preg_replace("/[\r\n]+$/", '', $section_text['FILEEOF']);
18681875
unset($section_text['FILEEOF']);
18691876
}
18701877

18711878
foreach (array('FILE', 'EXPECT', 'EXPECTF', 'EXPECTREGEX') as $prefix) {
18721879
$key = $prefix . '_EXTERNAL';
18731880

1874-
if (isset($section_text[$key])) {
1881+
if (array_key_exists($key, $section_text)) {
18751882
// don't allow tests to retrieve files from anywhere but this subdirectory
18761883
$section_text[$key] = dirname($file) . '/' . trim(str_replace('..', '', $section_text[$key]));
18771884

@@ -1884,7 +1891,13 @@ function run_test($php, $file, $env)
18841891
}
18851892
}
18861893

1887-
if ((@count($section_text['EXPECT']) + @count($section_text['EXPECTF']) + @count($section_text['EXPECTREGEX'])) != 1) {
1894+
if (
1895+
(
1896+
array_key_exists('EXPECT', $section_text)
1897+
xor array_key_exists('EXPECTF', $section_text)
1898+
xor array_key_exists('EXPECTREGEX', $section_text)
1899+
) === false
1900+
) {
18881901
$bork_info = "missing section --EXPECT--, --EXPECTF-- or --EXPECTREGEX--";
18891902
}
18901903
}
@@ -1908,7 +1921,7 @@ function run_test($php, $file, $env)
19081921
return 'BORKED';
19091922
}
19101923

1911-
if (isset($section_text['CAPTURE_STDIO'])) {
1924+
if (array_key_exists('CAPTURE_STDIO', $section_text)) {
19121925
$captureStdIn = stripos($section_text['CAPTURE_STDIO'], 'STDIN') !== false;
19131926
$captureStdOut = stripos($section_text['CAPTURE_STDIO'], 'STDOUT') !== false;
19141927
$captureStdErr = stripos($section_text['CAPTURE_STDIO'], 'STDERR') !== false;
@@ -2213,7 +2226,7 @@ function run_test($php, $file, $env)
22132226
$test_files[] = array($f, $file);
22142227
}
22152228
}
2216-
$test_cnt += @count($test_files) - 1;
2229+
$test_cnt += count($test_files) - 1;
22172230
$test_idx--;
22182231

22192232
show_redirect_start($IN_REDIRECT['TESTS'], $tested, $tested_file);
@@ -2247,7 +2260,7 @@ function run_test($php, $file, $env)
22472260
}
22482261
}
22492262

2250-
if (is_array($org_file) || @count($section_text['REDIRECTTEST']) == 1) {
2263+
if (is_array($org_file) || array_key_exists('REDIRECTTEST', $section_text)) {
22512264

22522265
if (is_array($org_file)) {
22532266
$file = $org_file[0];

0 commit comments

Comments
 (0)