1
0
mirror of https://github.com/php/php-src.git synced 2026-04-19 05:51:02 +02:00
Files
archived-php-src/Zend/tests/named_params/references.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

40 lines
1.1 KiB
PHP

--TEST--
Check that reference detection works properly
--FILE--
<?php
$v00 = $v01 = $v32 = $v33 = 0;
test(p32: $v32, p33: $v33, p00: $v00, p01: $v01);
echo "$v00 $v01 $v32 $v33\n";
$v = [0 => 0, 1 => 0, 32 => 0, 33 => 0];
test(p32: $v[32], p33: $v[33], p00: $v[0], p01: $v[1]);
echo "$v[0] $v[1] $v[32] $v[33]\n";
function test(
&$p00 = null, $p01 = null, &$p02 = null, $p03 = null, &$p04 = null, $p05 = null,
&$p06 = null, $p07 = null, &$p08 = null, $p09 = null, &$p10 = null, $p11 = null,
&$p12 = null, $p13 = null, &$p14 = null, $p15 = null, &$p16 = null, $p17 = null,
&$p18 = null, $p19 = null, &$p20 = null, $p21 = null, &$p22 = null, $p23 = null,
&$p24 = null, $p25 = null, &$p26 = null, $p27 = null, &$p28 = null, $p29 = null,
&$p30 = null, $p31 = null, &$p32 = null, $p33 = null, &$p34 = null, $p35 = null
) {
$p00++;
$p32++;
}
$v00 = $v01 = $v32 = $v33 = 0;
test(p32: $v32, p33: $v33, p00: $v00, p01: $v01);
echo "$v00 $v01 $v32 $v33\n";
$v = [0 => 0, 1 => 0, 32 => 0, 33 => 0];
test(p32: $v[32], p33: $v[33], p00: $v[0], p01: $v[1]);
echo "$v[0] $v[1] $v[32] $v[33]\n";
?>
--EXPECT--
1 0 1 0
1 0 1 0
1 0 1 0
1 0 1 0