Skip to content

Commit

Permalink
Fix #741 incorrect varvar positions
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Dec 19, 2020
1 parent bec74ac commit 893a5bc
Show file tree
Hide file tree
Showing 3 changed files with 352 additions and 345 deletions.
18 changes: 9 additions & 9 deletions grammar/php7.y
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ non_empty_global_var_list:
;

global_var:
simple_variable { $$ = Expr\Variable[$1]; }
simple_variable { $$ = $1; }
;

static_var_list:
Expand Down Expand Up @@ -1007,7 +1007,7 @@ callable_expr:
;

callable_variable:
simple_variable { $$ = Expr\Variable[$1]; }
simple_variable { $$ = $1; }
| array_object_dereferencable '[' optional_expr ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
| array_object_dereferencable '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; }
| function_call { $$ = $1; }
Expand All @@ -1032,15 +1032,15 @@ variable:
;

simple_variable:
T_VARIABLE { $$ = parseVar($1); }
| '$' '{' expr '}' { $$ = $3; }
plain_variable { $$ = $1; }
| '$' '{' expr '}' { $$ = Expr\Variable[$3]; }
| '$' simple_variable { $$ = Expr\Variable[$2]; }
| '$' error { $$ = Expr\Error[]; $this->errorState = 2; }
| '$' error { $$ = Expr\Variable[Expr\Error[]]; $this->errorState = 2; }
;

static_member_prop_name:
simple_variable
{ $var = $1; $$ = \is_string($var) ? Node\VarLikeIdentifier[$var] : $var; }
{ $var = $1->name; $$ = \is_string($var) ? Node\VarLikeIdentifier[$var] : $var; }
;

static_member:
Expand All @@ -1049,7 +1049,7 @@ static_member:
;

new_variable:
simple_variable { $$ = Expr\Variable[$1]; }
simple_variable { $$ = $1; }
| new_variable '[' optional_expr ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
| new_variable '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; }
| new_variable T_OBJECT_OPERATOR property_name { $$ = Expr\PropertyFetch[$1, $3]; }
Expand All @@ -1063,13 +1063,13 @@ new_variable:
member_name:
identifier_ex { $$ = $1; }
| '{' expr '}' { $$ = $2; }
| simple_variable { $$ = Expr\Variable[$1]; }
| simple_variable { $$ = $1; }
;

property_name:
identifier { $$ = $1; }
| '{' expr '}' { $$ = $2; }
| simple_variable { $$ = Expr\Variable[$1]; }
| simple_variable { $$ = $1; }
| error { $$ = Expr\Error[]; $this->errorState = 2; }
;

Expand Down
Loading

0 comments on commit 893a5bc

Please sign in to comment.