mirror of
https://github.com/php/php-src.git
synced 2026-04-14 11:32:11 +02:00
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.
70 lines
999 B
PHP
70 lines
999 B
PHP
--TEST--
|
|
Extra named params in backtraces
|
|
--FILE--
|
|
<?php
|
|
|
|
function test($a, ...$rest) {
|
|
var_dump(debug_backtrace());
|
|
debug_print_backtrace();
|
|
throw new Exception("Test");
|
|
}
|
|
|
|
try {
|
|
test(1, 2, x: 3, y: 4);
|
|
} catch (Exception $e) {
|
|
var_dump($e->getTrace());
|
|
echo $e, "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECTF--
|
|
array(1) {
|
|
[0]=>
|
|
array(4) {
|
|
["file"]=>
|
|
string(%d) "%s"
|
|
["line"]=>
|
|
int(10)
|
|
["function"]=>
|
|
string(4) "test"
|
|
["args"]=>
|
|
array(4) {
|
|
[0]=>
|
|
int(1)
|
|
[1]=>
|
|
int(2)
|
|
["x"]=>
|
|
int(3)
|
|
["y"]=>
|
|
int(4)
|
|
}
|
|
}
|
|
}
|
|
#0 test(1, 2, x: 3, y: 4) called at [%s:10]
|
|
array(1) {
|
|
[0]=>
|
|
array(4) {
|
|
["file"]=>
|
|
string(%d) "%s"
|
|
["line"]=>
|
|
int(10)
|
|
["function"]=>
|
|
string(4) "test"
|
|
["args"]=>
|
|
array(4) {
|
|
[0]=>
|
|
int(1)
|
|
[1]=>
|
|
int(2)
|
|
["x"]=>
|
|
int(3)
|
|
["y"]=>
|
|
int(4)
|
|
}
|
|
}
|
|
}
|
|
Exception: Test in %s:%d
|
|
Stack trace:
|
|
#0 %s(%d): test(1, 2, x: 3, y: 4)
|
|
#1 {main}
|