mirror of
https://github.com/php/php-src.git
synced 2026-04-19 22:11:12 +02:00
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.
51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
--TEST--
|
|
IntlGregorianCalendar::__construct(): bad arguments
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded('intl'))
|
|
die('skip intl extension not enabled');
|
|
--FILE--
|
|
<?php
|
|
ini_set("intl.error_level", E_WARNING);
|
|
|
|
try {
|
|
var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7));
|
|
} catch (ArgumentCountError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7,8));
|
|
} catch (ArgumentCountError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
var_dump(intlgregcal_create_instance(1,2,3,4));
|
|
} catch (ArgumentCountError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
var_dump(new IntlGregorianCalendar(1,2,NULL,4));
|
|
} catch (ArgumentCountError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
var_dump(new IntlGregorianCalendar(1,2,3,4,5,array()));
|
|
} catch (TypeError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
$cal = new IntlGregorianCalendar();
|
|
try {
|
|
$cal->__construct();
|
|
} catch (Error $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
Too many arguments
|
|
Too many arguments
|
|
No variant with 4 arguments (excluding trailing NULLs)
|
|
No variant with 4 arguments (excluding trailing NULLs)
|
|
IntlGregorianCalendar::__construct(): Argument #6 ($second) must be of type int, array given
|
|
IntlGregorianCalendar object is already constructed
|