mirror of
https://github.com/php/php-src.git
synced 2026-04-29 11:13:36 +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.
60 lines
1.8 KiB
PHP
60 lines
1.8 KiB
PHP
--TEST--
|
|
Test ltrim() function
|
|
--FILE--
|
|
<?php
|
|
|
|
/* Testing for Error conditions */
|
|
|
|
/* Invalid Number of Arguments */
|
|
|
|
echo "\n *** Output for Error Conditions ***\n";
|
|
|
|
/* heredoc string */
|
|
$str = <<<EOD
|
|
us
|
|
ing heredoc string
|
|
EOD;
|
|
|
|
echo "\n *** Using heredoc string ***\n";
|
|
var_dump( ltrim($str, "\nusi") );
|
|
|
|
/* Testing the Normal behaviour of ltrim() function */
|
|
|
|
echo "\n *** Output for Normal Behaviour ***\n";
|
|
var_dump ( ltrim(" \t\0 ltrim test") ); /* without second Argument */
|
|
var_dump ( ltrim(" ltrim test" , "") ); /* no characters in second Argument */
|
|
var_dump ( ltrim(" ltrim test", true) ); /* with boolean value as second Argument */
|
|
var_dump ( ltrim(" ltrim test", " ") ); /* with single space as second Argument */
|
|
var_dump ( ltrim("\t\n\r\0\x0B ltrim test", "\t\n\r\0\x0B") ); /* with multiple escape sequences as second Argument */
|
|
var_dump ( ltrim("ABCXYZltrim test", "A..Z") ); /* with characters range as second Argument */
|
|
var_dump ( ltrim("0123456789ltrim test", "0..9") ); /* with numbers range as second Argument */
|
|
var_dump ( ltrim("@$#ltrim test", "#@$") ); /* with some special characters as second Argument */
|
|
|
|
|
|
echo "\n *** Output for scalar argument) ***\n";
|
|
var_dump( ltrim( 12345 ) ); /* Scalar argument */
|
|
|
|
echo "\nDone\n";
|
|
|
|
?>
|
|
--EXPECT--
|
|
*** Output for Error Conditions ***
|
|
|
|
*** Using heredoc string ***
|
|
string(17) "ng heredoc string"
|
|
|
|
*** Output for Normal Behaviour ***
|
|
string(10) "ltrim test"
|
|
string(13) " ltrim test"
|
|
string(18) " ltrim test"
|
|
string(10) "ltrim test"
|
|
string(11) " ltrim test"
|
|
string(10) "ltrim test"
|
|
string(10) "ltrim test"
|
|
string(10) "ltrim test"
|
|
|
|
*** Output for scalar argument) ***
|
|
string(5) "12345"
|
|
|
|
Done
|