Skip to content

Commit 16f23cd

Browse files
gerardrochenikic
authored andcommitted
run-tests: remove use of FILE_BINARY constant
The FILE_BINARY (and FILE_TEXT) constants are not really valid or useful constants. It looks like they were added in 5.2.7 and have "no effect, and are only available for forward compatibility." See: https://www.php.net/manual/en/filesystem.constants.php The default value of the file_put_contents() flags parameter is 0 and FILE_BINARY is set to 0, so removing it doesn't change functionality. P.S. Maybe those constants should be deprecated or removed in 8.0. Closes GH-5556.
1 parent f07fbfb commit 16f23cd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

run-tests.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,8 @@ function save_or_mail_results()
966966
if ($sum_results['FAILED']) {
967967
foreach ($PHP_FAILED_TESTS['FAILED'] as $test_info) {
968968
$failed_tests_data .= $sep . $test_info['name'] . $test_info['info'];
969-
$failed_tests_data .= $sep . file_get_contents(realpath($test_info['output']), FILE_BINARY);
970-
$failed_tests_data .= $sep . file_get_contents(realpath($test_info['diff']), FILE_BINARY);
969+
$failed_tests_data .= $sep . file_get_contents(realpath($test_info['output']));
970+
$failed_tests_data .= $sep . file_get_contents(realpath($test_info['diff']));
971971
$failed_tests_data .= $sep . "\n\n";
972972
}
973973
$status = "failed";
@@ -1163,12 +1163,12 @@ function save_text($filename, $text, $filename_copy = null)
11631163
global $DETAILED;
11641164

11651165
if ($filename_copy && $filename_copy != $filename) {
1166-
if (file_put_contents($filename_copy, $text, FILE_BINARY) === false) {
1166+
if (file_put_contents($filename_copy, $text) === false) {
11671167
error("Cannot open file '" . $filename_copy . "' (save_text)");
11681168
}
11691169
}
11701170

1171-
if (file_put_contents($filename, $text, FILE_BINARY) === false) {
1171+
if (file_put_contents($filename, $text) === false) {
11721172
error("Cannot open file '" . $filename . "' (save_text)");
11731173
}
11741174

@@ -1890,7 +1890,7 @@ function run_test($php, $file, $env)
18901890
$section_text[$key] = dirname($file) . '/' . trim(str_replace('..', '', $section_text[$key]));
18911891

18921892
if (file_exists($section_text[$key])) {
1893-
$section_text[$prefix] = file_get_contents($section_text[$key], FILE_BINARY);
1893+
$section_text[$prefix] = file_get_contents($section_text[$key]);
18941894
unset($section_text[$key]);
18951895
} else {
18961896
$bork_info = "could not load --" . $key . "-- " . dirname($file) . '/' . trim($section_text[$key]);
@@ -2724,12 +2724,12 @@ function run_test($php, $file, $env)
27242724
if (!$passed) {
27252725

27262726
// write .exp
2727-
if (strpos($log_format, 'E') !== false && file_put_contents($exp_filename, $wanted, FILE_BINARY) === false) {
2727+
if (strpos($log_format, 'E') !== false && file_put_contents($exp_filename, $wanted) === false) {
27282728
error("Cannot create expected test output - $exp_filename");
27292729
}
27302730

27312731
// write .out
2732-
if (strpos($log_format, 'O') !== false && file_put_contents($output_filename, $output, FILE_BINARY) === false) {
2732+
if (strpos($log_format, 'O') !== false && file_put_contents($output_filename, $output) === false) {
27332733
error("Cannot create test output - $output_filename");
27342734
}
27352735

@@ -2740,7 +2740,7 @@ function run_test($php, $file, $env)
27402740
$diff = "# original source file: $orig_shortname\n" . $diff;
27412741
}
27422742
show_file_block('diff', $diff);
2743-
if (strpos($log_format, 'D') !== false && file_put_contents($diff_filename, $diff, FILE_BINARY) === false) {
2743+
if (strpos($log_format, 'D') !== false && file_put_contents($diff_filename, $diff) === false) {
27442744
error("Cannot create test diff - $diff_filename");
27452745
}
27462746

@@ -2763,7 +2763,7 @@ function run_test($php, $file, $env)
27632763
;;
27642764
esac
27652765
SH;
2766-
if (strpos($log_format, 'S') !== false && file_put_contents($sh_filename, $sh_script, FILE_BINARY) === false) {
2766+
if (strpos($log_format, 'S') !== false && file_put_contents($sh_filename, $sh_script) === false) {
27672767
error("Cannot create test shell script - $sh_filename");
27682768
}
27692769
chmod($sh_filename, 0755);
@@ -2775,7 +2775,7 @@ function run_test($php, $file, $env)
27752775
---- ACTUAL OUTPUT
27762776
$output
27772777
---- FAILED
2778-
", FILE_BINARY) === false) {
2778+
") === false) {
27792779
error("Cannot create test log - $log_filename");
27802780
error_report($file, $log_filename, $tested);
27812781
}

0 commit comments

Comments
 (0)