Skip to content

Commit

Permalink
Fix trait alias to semi-reserved name parsing
Browse files Browse the repository at this point in the history
This was missing the explicit construction of an Identifier node.
  • Loading branch information
nikic committed Oct 29, 2017
1 parent 5054a68 commit b241a12
Show file tree
Hide file tree
Showing 5 changed files with 1,565 additions and 1,530 deletions.
6 changes: 5 additions & 1 deletion grammar/php5.y
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ identifier:
T_STRING { $$ = Node\Identifier[$1]; }
;

reserved_non_modifiers_identifier:
reserved_non_modifiers { $$ = Node\Identifier[$1]; }
;

namespace_name_parts:
T_STRING { init($1); }
| namespace_name_parts T_NS_SEPARATOR T_STRING { push($1, $3); }
Expand Down Expand Up @@ -484,7 +488,7 @@ trait_adaptation:
{ $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], $3, null]; }
| trait_method_reference T_AS identifier ';'
{ $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], null, $3]; }
| trait_method_reference T_AS reserved_non_modifiers ';'
| trait_method_reference T_AS reserved_non_modifiers_identifier ';'
{ $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], null, $3]; }
;

Expand Down
6 changes: 5 additions & 1 deletion grammar/php7.y
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ identifier:
T_STRING { $$ = Node\Identifier[$1]; }
;

reserved_non_modifiers_identifier:
reserved_non_modifiers { $$ = Node\Identifier[$1]; }
;

namespace_name_parts:
T_STRING { init($1); }
| namespace_name_parts T_NS_SEPARATOR T_STRING { push($1, $3); }
Expand Down Expand Up @@ -544,7 +548,7 @@ trait_adaptation:
{ $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], $3, null]; }
| trait_method_reference T_AS identifier ';'
{ $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], null, $3]; }
| trait_method_reference T_AS reserved_non_modifiers ';'
| trait_method_reference T_AS reserved_non_modifiers_identifier ';'
{ $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], null, $3]; }
;

Expand Down
Loading

0 comments on commit b241a12

Please sign in to comment.