mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
d92229d8c7
From an engine perspective, named parameters mainly add three concepts: * The SEND_* opcodes now accept a CONST op2, which is the argument name. For now, it is looked up by linear scan and runtime cached. * This may leave UNDEF arguments on the stack. To avoid having to deal with them in other places, a CHECK_UNDEF_ARGS opcode is used to either replace them with defaults, or error. * For variadic functions, EX(extra_named_params) are collected and need to be freed based on ZEND_CALL_HAS_EXTRA_NAMED_PARAMS. RFC: https://wiki.php.net/rfc/named_params Closes GH-5357.
36 lines
590 B
PHP
36 lines
590 B
PHP
--TEST--
|
|
Skipping over default parameters
|
|
--FILE--
|
|
<?php
|
|
|
|
function test1($a = 'a', $b = 'b') {
|
|
echo "a: $a, b: $b\n";
|
|
}
|
|
|
|
function test2($a = SOME_CONST, $b = 'b') {
|
|
echo "a: $a, b: $b\n";
|
|
}
|
|
|
|
function test3($a = SOME_OTHER_CONST, $b = 'b') {
|
|
echo "a: $a, b: $b\n";
|
|
}
|
|
|
|
test1(b: 'B');
|
|
|
|
define('SOME_CONST', 'X');
|
|
test2(b: 'B');
|
|
|
|
// NB: We also want to test the stack trace.
|
|
test3(b: 'B');
|
|
|
|
?>
|
|
--EXPECTF--
|
|
a: a, b: B
|
|
a: X, b: B
|
|
|
|
Fatal error: Uncaught Error: Undefined constant "SOME_OTHER_CONST" in %s:%d
|
|
Stack trace:
|
|
#0 %s(%d): test3(NULL, 'B')
|
|
#1 {main}
|
|
thrown in %s on line %d
|