php-src/Zend/tests/required_param_after_optional_named_args.phpt
Nikita Popov afc4d67c8b Consistently treat optional-before-required as required
There was a loophole here when it came to usage with named arguments,
which was not intended. Close the loophole thoroughly by actually
dropping the default value from the signature entirely. The default
is still used to make the type nullable, but not for anything else.
2021-05-18 12:40:58 +02:00

18 lines
404 B
PHP

--TEST--
Optional param before required should be treated as required for named args as well
--FILE--
<?php
function test($a = 1, $b) {
}
try {
test(b: 2);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
Deprecated: Optional parameter $a declared before required parameter $b is implicitly treated as a required parameter in %s on line %d
test(): Argument #1 ($a) not passed