1
0
mirror of https://github.com/php/php-src.git synced 2026-04-18 05:21:02 +02:00
Files
archived-php-src/Zend/tests/named_params/func_get_args.phpt
Nikita Popov d92229d8c7 Implement named parameters
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.
2020-07-31 15:53:36 +02:00

30 lines
456 B
PHP

--TEST--
Behavior of func_get_args() and friends with named parameters
--FILE--
<?php
function test($a, $b = 'b', $c = 'c') {
var_dump(func_num_args());
var_dump(func_get_args());
var_dump(func_get_arg(0));
var_dump(func_get_arg(1));
var_dump(func_get_arg(2));
}
test(c: 'C', a: 'A');
?>
--EXPECT--
int(3)
array(3) {
[0]=>
string(1) "A"
[1]=>
string(1) "b"
[2]=>
string(1) "C"
}
string(1) "A"
string(1) "b"
string(1) "C"