mirror of
https://github.com/php/php-src.git
synced 2026-04-23 07:58:20 +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.
133 lines
2.2 KiB
PHP
133 lines
2.2 KiB
PHP
--TEST--
|
|
Test dirname() function : usage variations
|
|
--FILE--
|
|
<?php
|
|
class temp
|
|
{
|
|
function __toString() {
|
|
return "Object";
|
|
}
|
|
}
|
|
|
|
$file_path_variations = array (
|
|
/* home dir shortcut char */
|
|
"~/home/user/bar",
|
|
"~/home/user/bar/",
|
|
"~/home/user/bar.tar",
|
|
"~/home/user/bar.tar/",
|
|
|
|
/* with hotname:dir notation */
|
|
"hostname:/home/user/bar.tar",
|
|
"hostname:/home/user/tbar.gz/",
|
|
"hostname:/home/user/My Pics.gz",
|
|
"hostname:/home/user/My Pics.gz/",
|
|
"hostname:/home/user/My Pics/",
|
|
"hostname:/home/user/My Pics",
|
|
|
|
/* path containing numeric string */
|
|
"10.5",
|
|
"/10.5",
|
|
"/10.5/",
|
|
"10.5/",
|
|
"10/10.gz",
|
|
'0',
|
|
"0",
|
|
|
|
/* object */
|
|
new temp,
|
|
|
|
/* path as spaces */
|
|
" ",
|
|
' ',
|
|
|
|
/* empty path */
|
|
"",
|
|
'',
|
|
);
|
|
|
|
function check_dirname( $paths ) {
|
|
$loop_counter = 0;
|
|
$noOfPaths = count($paths);
|
|
for( ; $loop_counter < $noOfPaths; $loop_counter++ ) {
|
|
echo "\n--Iteration ";
|
|
echo $loop_counter +1;
|
|
echo " --\n";
|
|
var_dump( dirname($paths[$loop_counter]) );
|
|
}
|
|
}
|
|
|
|
echo "*** Testing possible variations in path ***\n";
|
|
check_dirname( $file_path_variations );
|
|
|
|
echo "Done\n";
|
|
?>
|
|
--EXPECTREGEX--
|
|
\*\*\* Testing possible variations in path \*\*\*
|
|
|
|
--Iteration 1 --
|
|
string\(11\) "~(\\|\/)home(\\|\/)user"
|
|
|
|
--Iteration 2 --
|
|
string\(11\) "~(\\|\/)home(\\|\/)user"
|
|
|
|
--Iteration 3 --
|
|
string\(11\) "~(\\|\/)home(\\|\/)user"
|
|
|
|
--Iteration 4 --
|
|
string\(11\) "~(\\|\/)home(\\|\/)user"
|
|
|
|
--Iteration 5 --
|
|
string\(19\) "hostname:(\\|\/)home(\\|\/)user"
|
|
|
|
--Iteration 6 --
|
|
string\(19\) "hostname:(\\|\/)home(\\|\/)user"
|
|
|
|
--Iteration 7 --
|
|
string\(19\) "hostname:(\\|\/)home(\\|\/)user"
|
|
|
|
--Iteration 8 --
|
|
string\(19\) "hostname:(\\|\/)home(\\|\/)user"
|
|
|
|
--Iteration 9 --
|
|
string\(19\) "hostname:(\\|\/)home(\\|\/)user"
|
|
|
|
--Iteration 10 --
|
|
string\(19\) "hostname:(\\|\/)home(\\|\/)user"
|
|
|
|
--Iteration 11 --
|
|
string\(1\) "."
|
|
|
|
--Iteration 12 --
|
|
string\(1\) "(\\|\/)"
|
|
|
|
--Iteration 13 --
|
|
string\(1\) "(\\|\/)"
|
|
|
|
--Iteration 14 --
|
|
string\(1\) "."
|
|
|
|
--Iteration 15 --
|
|
string\(2\) "10"
|
|
|
|
--Iteration 16 --
|
|
string\(1\) "."
|
|
|
|
--Iteration 17 --
|
|
string\(1\) "."
|
|
|
|
--Iteration 18 --
|
|
string\(1\) "."
|
|
|
|
--Iteration 19 --
|
|
string\(1\) "."
|
|
|
|
--Iteration 20 --
|
|
string\(1\) "."
|
|
|
|
--Iteration 21 --
|
|
string\(0\) ""
|
|
|
|
--Iteration 22 --
|
|
string\(0\) ""
|
|
Done
|