@@ -228,13 +228,13 @@ function main(): void
228
228
// fail to reattach to the OpCache because it will be using the
229
229
// wrong path.
230
230
die ("TEMP environment is NOT set " );
231
- } else {
232
- if ( count ( $ environment ) == 1 ) {
233
- // Not having other environment variables, only having TEMP, is
234
- // probably ok, but strange and may make a difference in the
235
- // test pass rate, so warn the user.
236
- echo " WARNING: Only 1 environment variable will be available to tests(TEMP environment variable) " . PHP_EOL ;
237
- }
231
+ }
232
+
233
+ if ( count ( $ environment) == 1 ) {
234
+ // Not having other environment variables, only having TEMP, is
235
+ // probably ok, but strange and may make a difference in the
236
+ // test pass rate, so warn the user.
237
+ echo " WARNING: Only 1 environment variable will be available to tests(TEMP environment variable) " . PHP_EOL ;
238
238
}
239
239
}
240
240
@@ -436,10 +436,8 @@ function main(): void
436
436
$ matches = [];
437
437
if (preg_match ('/^#.*\[(.*)\]\:\s+(.*)$/ ' , $ test , $ matches )) {
438
438
$ redir_tests [] = [$ matches [1 ], $ matches [2 ]];
439
- } else {
440
- if (strlen ($ test )) {
441
- $ test_files [] = trim ($ test );
442
- }
439
+ } elseif (strlen ($ test )) {
440
+ $ test_files [] = trim ($ test );
443
441
}
444
442
}
445
443
}
@@ -624,27 +622,21 @@ function main(): void
624
622
if (!$ testfile && strpos ($ argv [$ i ], '* ' ) !== false && function_exists ('glob ' )) {
625
623
if (substr ($ argv [$ i ], -5 ) == '.phpt ' ) {
626
624
$ pattern_match = glob ($ argv [$ i ]);
625
+ } elseif (preg_match ("/\*$/ " , $ argv [$ i ])) {
626
+ $ pattern_match = glob ($ argv [$ i ] . '.phpt ' );
627
627
} else {
628
- if (preg_match ("/\*$/ " , $ argv [$ i ])) {
629
- $ pattern_match = glob ($ argv [$ i ] . '.phpt ' );
630
- } else {
631
- die ('Cannot find test file " ' . $ argv [$ i ] . '". ' . PHP_EOL );
632
- }
628
+ die ('Cannot find test file " ' . $ argv [$ i ] . '". ' . PHP_EOL );
633
629
}
634
630
635
631
if (is_array ($ pattern_match )) {
636
632
$ test_files = array_merge ($ test_files , $ pattern_match );
637
633
}
634
+ } elseif (is_dir ($ testfile )) {
635
+ find_files ($ testfile );
636
+ } elseif (substr ($ testfile , -5 ) == '.phpt ' ) {
637
+ $ test_files [] = $ testfile ;
638
638
} else {
639
- if (is_dir ($ testfile )) {
640
- find_files ($ testfile );
641
- } else {
642
- if (substr ($ testfile , -5 ) == '.phpt ' ) {
643
- $ test_files [] = $ testfile ;
644
- } else {
645
- die ('Cannot find test file " ' . $ argv [$ i ] . '". ' . PHP_EOL );
646
- }
647
- }
639
+ die ('Cannot find test file " ' . $ argv [$ i ] . '". ' . PHP_EOL );
648
640
}
649
641
}
650
642
}
@@ -1085,9 +1077,9 @@ function test_name($name): string
1085
1077
{
1086
1078
if (is_array ($ name )) {
1087
1079
return $ name [0 ] . ': ' . $ name [1 ];
1088
- } else {
1089
- return $ name ;
1090
1080
}
1081
+
1082
+ return $ name ;
1091
1083
}
1092
1084
/**
1093
1085
* @param array|string $a
@@ -1105,9 +1097,9 @@ function test_sort($a, $b): int
1105
1097
1106
1098
if ($ ta == $ tb ) {
1107
1099
return strcmp ($ a , $ b );
1108
- } else {
1109
- return $ tb - $ ta ;
1110
1100
}
1101
+
1102
+ return $ tb - $ ta ;
1111
1103
}
1112
1104
1113
1105
//
@@ -1118,10 +1110,8 @@ function save_text(string $filename, string $text, ?string $filename_copy = null
1118
1110
{
1119
1111
global $ DETAILED ;
1120
1112
1121
- if ($ filename_copy && $ filename_copy != $ filename ) {
1122
- if (file_put_contents ($ filename_copy , $ text ) === false ) {
1123
- error ("Cannot open file ' " . $ filename_copy . "' (save_text) " );
1124
- }
1113
+ if ($ filename_copy && $ filename_copy != $ filename && file_put_contents ($ filename_copy , $ text ) === false ) {
1114
+ error ("Cannot open file ' " . $ filename_copy . "' (save_text) " );
1125
1115
}
1126
1116
1127
1117
if (file_put_contents ($ filename , $ text ) === false ) {
@@ -1214,12 +1204,16 @@ function system_with_timeout(
1214
1204
1215
1205
if ($ n === false ) {
1216
1206
break ;
1217
- } elseif ($ n === 0 ) {
1207
+ }
1208
+
1209
+ if ($ n === 0 ) {
1218
1210
/* timed out */
1219
1211
$ data .= "\n ** ERROR: process timed out ** \n" ;
1220
1212
proc_terminate ($ proc , 9 );
1221
1213
return $ data ;
1222
- } elseif ($ n > 0 ) {
1214
+ }
1215
+
1216
+ if ($ n > 0 ) {
1223
1217
if ($ captureStdOut ) {
1224
1218
$ line = fread ($ pipes [1 ], 8192 );
1225
1219
} elseif ($ captureStdErr ) {
@@ -2201,17 +2195,17 @@ function run_test(string $php, $file, array $env): string
2201
2195
2202
2196
$ junit ->markTestAs ('PASS ' , $ shortname , $ tested );
2203
2197
return 'REDIR ' ;
2204
- } else {
2205
- $ bork_info = "Redirect info must contain exactly one TEST string to be used as redirect directory. " ;
2206
- show_result ("BORK " , $ bork_info , '' , '' , $ temp_filenames );
2207
- $ PHP_FAILED_TESTS ['BORKED ' ][] = [
2208
- 'name ' => $ file ,
2209
- 'test_name ' => '' ,
2210
- 'output ' => '' ,
2211
- 'diff ' => '' ,
2212
- 'info ' => "$ bork_info [ $ file] " ,
2213
- ];
2214
2198
}
2199
+
2200
+ $ bork_info = "Redirect info must contain exactly one TEST string to be used as redirect directory. " ;
2201
+ show_result ("BORK " , $ bork_info , '' , '' , $ temp_filenames );
2202
+ $ PHP_FAILED_TESTS ['BORKED ' ][] = [
2203
+ 'name ' => $ file ,
2204
+ 'test_name ' => '' ,
2205
+ 'output ' => '' ,
2206
+ 'diff ' => '' ,
2207
+ 'info ' => "$ bork_info [ $ file] " ,
2208
+ ];
2215
2209
}
2216
2210
2217
2211
if (is_array ($ org_file ) || $ test ->hasSection ('REDIRECTTEST ' )) {
@@ -2776,9 +2770,9 @@ function comp_line(string $l1, string $l2, bool $is_reg)
2776
2770
{
2777
2771
if ($ is_reg ) {
2778
2772
return preg_match ('/^ ' . $ l1 . '$/s ' , $ l2 );
2779
- } else {
2780
- return !strcmp ($ l1 , $ l2 );
2781
2773
}
2774
+
2775
+ return !strcmp ($ l1 , $ l2 );
2782
2776
}
2783
2777
2784
2778
function count_array_diff (
@@ -2854,20 +2848,20 @@ function generate_array_diff(array $ar1, array $ar2, bool $is_reg, array $w): ar
2854
2848
$ idx1 ++;
2855
2849
$ idx2 ++;
2856
2850
continue ;
2857
- } else {
2858
- $ c1 = @count_array_diff ($ ar1 , $ ar2 , $ is_reg , $ w , $ idx1 + 1 , $ idx2 , $ cnt1 , $ cnt2 , 10 );
2859
- $ c2 = @count_array_diff ($ ar1 , $ ar2 , $ is_reg , $ w , $ idx1 , $ idx2 + 1 , $ cnt1 , $ cnt2 , 10 );
2851
+ }
2860
2852
2861
- if ($ c1 > $ c2 ) {
2862
- $ old1 [$ idx1 ] = sprintf ("{$ line_number_spec }- " , $ idx1 + 1 ) . $ w [$ idx1 ++];
2863
- } elseif ($ c2 > 0 ) {
2864
- $ old2 [$ idx2 ] = sprintf ("{$ line_number_spec }+ " , $ idx2 + 1 ) . $ ar2 [$ idx2 ++];
2865
- } else {
2866
- $ old1 [$ idx1 ] = sprintf ("{$ line_number_spec }- " , $ idx1 + 1 ) . $ w [$ idx1 ++];
2867
- $ old2 [$ idx2 ] = sprintf ("{$ line_number_spec }+ " , $ idx2 + 1 ) . $ ar2 [$ idx2 ++];
2868
- }
2869
- $ last_printed_context_line = $ idx1 ;
2853
+ $ c1 = @count_array_diff ($ ar1 , $ ar2 , $ is_reg , $ w , $ idx1 + 1 , $ idx2 , $ cnt1 , $ cnt2 , 10 );
2854
+ $ c2 = @count_array_diff ($ ar1 , $ ar2 , $ is_reg , $ w , $ idx1 , $ idx2 + 1 , $ cnt1 , $ cnt2 , 10 );
2855
+
2856
+ if ($ c1 > $ c2 ) {
2857
+ $ old1 [$ idx1 ] = sprintf ("{$ line_number_spec }- " , $ idx1 + 1 ) . $ w [$ idx1 ++];
2858
+ } elseif ($ c2 > 0 ) {
2859
+ $ old2 [$ idx2 ] = sprintf ("{$ line_number_spec }+ " , $ idx2 + 1 ) . $ ar2 [$ idx2 ++];
2860
+ } else {
2861
+ $ old1 [$ idx1 ] = sprintf ("{$ line_number_spec }- " , $ idx1 + 1 ) . $ w [$ idx1 ++];
2862
+ $ old2 [$ idx2 ] = sprintf ("{$ line_number_spec }+ " , $ idx2 + 1 ) . $ ar2 [$ idx2 ++];
2870
2863
}
2864
+ $ last_printed_context_line = $ idx1 ;
2871
2865
}
2872
2866
$ mapping [$ idx2 ] = $ idx1 ;
2873
2867
0 commit comments