mirror of
https://github.com/php/php-src.git
synced 2026-04-22 07:28:09 +02:00
b10416a652
This deprecates passing null to non-nullable scale arguments of internal functions, with the eventual goal of making the behavior consistent with userland functions, where null is never accepted for non-nullable arguments. This change is expected to cause quite a lot of fallout. In most cases, calling code should be adjusted to avoid passing null. In some cases, PHP should be adjusted to make some function arguments nullable. I have already fixed a number of functions before landing this, but feel free to file a bug if you encounter a function that doesn't accept null, but probably should. (The rule of thumb for this to be applicable is that the function must have special behavior for 0 or "", which is distinct from the natural behavior of the parameter.) RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg Closes GH-6475.
40 lines
985 B
PHP
40 lines
985 B
PHP
--TEST--
|
|
Test readfile() function: error conditions
|
|
--FILE--
|
|
<?php
|
|
$context = stream_context_create();
|
|
|
|
echo "*** Test readfile(): error conditions ***\n";
|
|
|
|
echo "\n-- Testing readfile() with invalid arguments --\n";
|
|
// invalid arguments
|
|
try {
|
|
var_dump( readfile('') ); // empty string as $filename
|
|
} catch (\ValueError $e) {
|
|
echo $e->getMessage() . \PHP_EOL;
|
|
}
|
|
try {
|
|
var_dump( readfile(false) ); // boolean false as $filename
|
|
} catch (\ValueError $e) {
|
|
echo $e->getMessage() . \PHP_EOL;
|
|
}
|
|
|
|
echo "\n-- Testing readfile() with non-existent file --\n";
|
|
$non_existent_file = __DIR__."/non_existent_file.tmp";
|
|
var_dump( readfile($non_existent_file) );
|
|
|
|
echo "Done\n";
|
|
?>
|
|
--EXPECTF--
|
|
*** Test readfile(): error conditions ***
|
|
|
|
-- Testing readfile() with invalid arguments --
|
|
Path cannot be empty
|
|
Path cannot be empty
|
|
|
|
-- Testing readfile() with non-existent file --
|
|
|
|
Warning: readfile(%s/non_existent_file.tmp): Failed to open stream: %s in %s on line %d
|
|
bool(false)
|
|
Done
|