mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
8ed66b4347
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.
29 lines
396 B
PHP
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)
|
|
}
|
|
}
|