php-src/Zend/tests/gh11320_1.phpt
Ilija Tovilo 8ed66b4347 Add tests for list() in assignment in array literals
Array literals will constant evaluate their elements. These can include
assignments, even though these are not valid constant expressions. The lhs of
assignments can be a list() element (or []) which is parsed as an array with a
special flag.
2023-05-26 12:15:01 +02:00

29 lines
396 B
PHP

--TEST--
GH-11320: Array literals can contain list() assignments
--FILE--
<?php
$index = 1;
function getList() { return [2, 3]; }
var_dump([$index => list($x, $y) = getList()]);
var_dump([$index => [$x, $y] = getList()]);
?>
--EXPECT--
array(1) {
[1]=>
array(2) {
[0]=>
int(2)
[1]=>
int(3)
}
}
array(1) {
[1]=>
array(2) {
[0]=>
int(2)
[1]=>
int(3)
}
}