Fix trait alias to semi-reserved name parsing

This was missing the explicit construction of an Identifier node.
This commit is contained in:
Nikita Popov 2017-10-29 14:13:58 +01:00
parent 5054a68bfb
commit b241a121a3
5 changed files with 2043 additions and 2008 deletions

View File

@ -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); }
@ -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]; }
;

View File

@ -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); }
@ -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]; }
;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
Trait alias
-----
<?php
class X {
use T {
exit
as die;
}
}
-----
/* do nothing */
-----
<?php
class X {
use T {
exit
as die;
}
}