mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-26 20:14:46 +01:00
Add constant dereferencing, a list-minute 5.6 change
This commit is contained in:
parent
31bc022d0d
commit
452e1c0180
@ -628,6 +628,7 @@ scalar_dereference:
|
||||
array_expr '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| T_CONSTANT_ENCAPSED_STRING '[' dim_offset ']'
|
||||
{ $$ = Expr\ArrayDimFetch[Scalar\String[Scalar\String::parse($1)], $3]; }
|
||||
| constant '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| scalar_dereference '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
/* alternative array syntax missing intentionally */
|
||||
;
|
||||
@ -745,12 +746,12 @@ common_scalar:
|
||||
{ $$ = Scalar\String[Scalar\String::parseDocString($1, $2)]; }
|
||||
| T_START_HEREDOC T_END_HEREDOC
|
||||
{ $$ = Scalar\String['']; }
|
||||
| name { $$ = Expr\ConstFetch[$1]; }
|
||||
;
|
||||
|
||||
static_scalar:
|
||||
common_scalar { $$ = $1; }
|
||||
| class_name T_PAAMAYIM_NEKUDOTAYIM class_const_name { $$ = Expr\ClassConstFetch[$1, $3]; }
|
||||
| name { $$ = Expr\ConstFetch[$1]; }
|
||||
| T_ARRAY '(' static_array_pair_list ')' { $$ = Expr\Array_[$3]; }
|
||||
| '[' static_array_pair_list ']' { $$ = Expr\Array_[$2]; }
|
||||
| static_operation { $$ = $1; }
|
||||
@ -792,10 +793,15 @@ static_operation:
|
||||
| '(' static_scalar ')' { $$ = $2; }
|
||||
;
|
||||
|
||||
scalar:
|
||||
common_scalar { $$ = $1; }
|
||||
constant:
|
||||
name { $$ = Expr\ConstFetch[$1]; }
|
||||
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM class_const_name
|
||||
{ $$ = Expr\ClassConstFetch[$1, $3]; }
|
||||
;
|
||||
|
||||
scalar:
|
||||
common_scalar { $$ = $1; }
|
||||
| constant { $$ = $1; }
|
||||
| '"' encaps_list '"'
|
||||
{ parseEncapsed($2, '"'); $$ = Scalar\Encapsed[$2]; }
|
||||
| T_START_HEREDOC encaps_list T_END_HEREDOC
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,10 @@ Array/string dereferencing
|
||||
|
||||
array(1, 2, 3)[2];
|
||||
array(1, 2, 3)[2][0][0];
|
||||
|
||||
FOO[0];
|
||||
Foo::BAR[1];
|
||||
$foo::BAR[2][1][0];
|
||||
-----
|
||||
array(
|
||||
0: Expr_ArrayDimFetch(
|
||||
@ -178,4 +182,50 @@ array(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
6: Expr_ArrayDimFetch(
|
||||
var: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: FOO
|
||||
)
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
7: Expr_ArrayDimFetch(
|
||||
var: Expr_ClassConstFetch(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: Foo
|
||||
)
|
||||
)
|
||||
name: BAR
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
8: Expr_ArrayDimFetch(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Expr_ArrayDimFetch(
|
||||
var: Expr_ClassConstFetch(
|
||||
class: Expr_Variable(
|
||||
name: foo
|
||||
)
|
||||
name: BAR
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 2
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
dim: Scalar_LNumber(
|
||||
value: 0
|
||||
)
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue
Block a user