1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-12 01:19:47 +01:00
PHP-Parser/test/code/parser/expr/listWithKeys.test
Nikita Popov 574665b45b PHP 7.1: list() with keys
Expr\List will now contain ArrayItems instead of plain variables.
I'm reusing ArrayItem, because code handling list() must also handle
arrays, and this allows both to go through the same code path.

This also renames Expr\List->vars to ->items.

TODO: Should Expr\List be dropped in favor of Expr\Array with an
extra flag?
2016-07-09 21:55:55 +02:00

75 lines
1.9 KiB
Plaintext

List destructing with keys
-----
<?php
list('a' => $b) = ['a' => 'b'];
list('a' => list($b => $c), 'd' => $e) = $x;
-----
!!php7
array(
0: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: Scalar_String(
value: a
)
value: Expr_Variable(
name: b
)
byRef: false
)
)
)
expr: Expr_Array(
items: array(
0: Expr_ArrayItem(
key: Scalar_String(
value: a
)
value: Scalar_String(
value: b
)
byRef: false
)
)
)
)
1: Expr_Assign(
var: Expr_List(
items: array(
0: Expr_ArrayItem(
key: Scalar_String(
value: a
)
value: Expr_List(
items: array(
0: Expr_ArrayItem(
key: Expr_Variable(
name: b
)
value: Expr_Variable(
name: c
)
byRef: false
)
)
)
byRef: false
)
1: Expr_ArrayItem(
key: Scalar_String(
value: d
)
value: Expr_Variable(
name: e
)
byRef: false
)
)
)
expr: Expr_Variable(
name: x
)
)
)