From 5f5cf1e7c728894bbe4b7084c3cb2b3b6cf06f09 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 15 Jun 2020 11:50:55 +0200 Subject: [PATCH 1/4] Treat namespaced names as single token --- .../018_variable_attribute_name.phpt | 2 +- Zend/tests/bug43343.phpt | 2 +- Zend/tests/bug55086.phpt | 2 +- Zend/tests/grammar/regression_010.phpt | 7 ++-- Zend/tests/namespaced_name_whitespace.phpt | 10 ++++++ Zend/tests/ns_096.phpt | 2 +- Zend/tests/ns_trailing_comma_error_01.phpt | 2 +- Zend/tests/ns_trailing_comma_error_02.phpt | 2 +- Zend/tests/ns_trailing_comma_error_04.phpt | 2 +- Zend/tests/ns_trailing_comma_error_07.phpt | 2 +- Zend/zend_language_parser.y | 34 ++++++++++++------- Zend/zend_language_scanner.l | 20 ++++++++--- 12 files changed, 60 insertions(+), 27 deletions(-) create mode 100644 Zend/tests/namespaced_name_whitespace.phpt diff --git a/Zend/tests/attributes/018_variable_attribute_name.phpt b/Zend/tests/attributes/018_variable_attribute_name.phpt index 64fb69a4e0318..8852eb270e70d 100644 --- a/Zend/tests/attributes/018_variable_attribute_name.phpt +++ b/Zend/tests/attributes/018_variable_attribute_name.phpt @@ -8,4 +8,4 @@ class A {} ?> --EXPECTF-- -Parse error: syntax error, unexpected '$x' (T_VARIABLE), expecting identifier (T_STRING) or static (T_STATIC) or namespace (T_NAMESPACE) or \\ (T_NS_SEPARATOR) in %s on line %d +Parse error: syntax error, unexpected '$x' (T_VARIABLE) in %s on line %d diff --git a/Zend/tests/bug43343.phpt b/Zend/tests/bug43343.phpt index 79b3e5a24ad38..609abab837064 100644 --- a/Zend/tests/bug43343.phpt +++ b/Zend/tests/bug43343.phpt @@ -8,4 +8,4 @@ $foo = 'bar'; var_dump(new namespace::$foo); ?> --EXPECTF-- -Parse error: %s error%sexpecting%sT_NS_SEPARATOR%sin %sbug43343.php on line 5 +Parse error: syntax error, unexpected 'namespace' (T_NAMESPACE) in %s on line %d diff --git a/Zend/tests/bug55086.phpt b/Zend/tests/bug55086.phpt index 9a5c747b9f007..10be0d1ef512a 100644 --- a/Zend/tests/bug55086.phpt +++ b/Zend/tests/bug55086.phpt @@ -26,7 +26,7 @@ namespace N2 { echo $a->hello(), PHP_EOL; echo $a->foo(), PHP_EOL; try { - } catch(namespace \Foo $e) + } catch (namespace\Foo $e) { } } diff --git a/Zend/tests/grammar/regression_010.phpt b/Zend/tests/grammar/regression_010.phpt index e5e65e3a85d8d..b353c3c95baf6 100644 --- a/Zend/tests/grammar/regression_010.phpt +++ b/Zend/tests/grammar/regression_010.phpt @@ -5,8 +5,11 @@ Test to check regressions on T_IMPLEMENTS followed by a T_NS_SEPARATOR interface A{} +// No longer considered legal in PHP 8. class B implements\A {} echo "Done", PHP_EOL; ---EXPECT-- -Done + +?> +--EXPECTF-- +Parse error: syntax error, unexpected 'implements\A' (T_NAME_QUALIFIED), expecting '{' in %s on line %d diff --git a/Zend/tests/namespaced_name_whitespace.phpt b/Zend/tests/namespaced_name_whitespace.phpt new file mode 100644 index 0000000000000..b91f92f0162eb --- /dev/null +++ b/Zend/tests/namespaced_name_whitespace.phpt @@ -0,0 +1,10 @@ +--TEST-- +Whitespace between namespace separators is no longer allowed +--FILE-- + +--EXPECTF-- +Parse error: syntax error, unexpected '\' (T_NS_SEPARATOR) in %s on line %d diff --git a/Zend/tests/ns_096.phpt b/Zend/tests/ns_096.phpt index 48f0c75387a9d..9a259a6888a75 100644 --- a/Zend/tests/ns_096.phpt +++ b/Zend/tests/ns_096.phpt @@ -7,4 +7,4 @@ use Foo\Bar\{\Baz}; ?> --EXPECTF-- -Parse error: syntax error, unexpected '\' (T_NS_SEPARATOR), expecting identifier (T_STRING) or function (T_FUNCTION) or const (T_CONST) in %s on line 3 +Parse error: syntax error, unexpected '\Baz' (T_NAME_FULLY_QUALIFIED), expecting identifier (T_STRING) or namespaced name (T_NAME_QUALIFIED) or function (T_FUNCTION) or const (T_CONST) in %s on line %d diff --git a/Zend/tests/ns_trailing_comma_error_01.phpt b/Zend/tests/ns_trailing_comma_error_01.phpt index 1b226036cfe7e..131270ed379c1 100644 --- a/Zend/tests/ns_trailing_comma_error_01.phpt +++ b/Zend/tests/ns_trailing_comma_error_01.phpt @@ -5,4 +5,4 @@ Group use declarations mustn't be empty use Baz\{}; ?> --EXPECTF-- -Parse error: syntax error, unexpected '}', expecting identifier (T_STRING) or function (T_FUNCTION) or const (T_CONST) in %s on line %d +Parse error: syntax error, unexpected '}', expecting identifier (T_STRING) or namespaced name (T_NAME_QUALIFIED) or function (T_FUNCTION) or const (T_CONST) in %s on line %d diff --git a/Zend/tests/ns_trailing_comma_error_02.phpt b/Zend/tests/ns_trailing_comma_error_02.phpt index c2123a85f5a4e..51cea59bc1a21 100644 --- a/Zend/tests/ns_trailing_comma_error_02.phpt +++ b/Zend/tests/ns_trailing_comma_error_02.phpt @@ -5,4 +5,4 @@ Group use declarations mustn't contain just a comma use Baz\{,}; ?> --EXPECTF-- -Parse error: syntax error, unexpected ',', expecting identifier (T_STRING) or function (T_FUNCTION) or const (T_CONST) in %s on line %d +Parse error: syntax error, unexpected ',', expecting identifier (T_STRING) or namespaced name (T_NAME_QUALIFIED) or function (T_FUNCTION) or const (T_CONST) in %s on line %d diff --git a/Zend/tests/ns_trailing_comma_error_04.phpt b/Zend/tests/ns_trailing_comma_error_04.phpt index 09d7ebf34924d..fc62f015db9cc 100644 --- a/Zend/tests/ns_trailing_comma_error_04.phpt +++ b/Zend/tests/ns_trailing_comma_error_04.phpt @@ -5,4 +5,4 @@ Group use declarations mustn't begin with a comma use Baz\{,Foo}; ?> --EXPECTF-- -Parse error: syntax error, unexpected ',', expecting identifier (T_STRING) or function (T_FUNCTION) or const (T_CONST) in %s on line %d +Parse error: syntax error, unexpected ',', expecting identifier (T_STRING) or namespaced name (T_NAME_QUALIFIED) or function (T_FUNCTION) or const (T_CONST) in %s on line %d diff --git a/Zend/tests/ns_trailing_comma_error_07.phpt b/Zend/tests/ns_trailing_comma_error_07.phpt index e925a60de8c2e..f5c114a5e1748 100644 --- a/Zend/tests/ns_trailing_comma_error_07.phpt +++ b/Zend/tests/ns_trailing_comma_error_07.phpt @@ -5,4 +5,4 @@ Unmixed group use declarations mustn't begin with a comma use function Baz\{,Foo}; ?> --EXPECTF-- -Parse error: syntax error, unexpected ',', expecting identifier (T_STRING) in %s on line %d +Parse error: syntax error, unexpected ',', expecting identifier (T_STRING) or namespaced name (T_NAME_QUALIFIED) in %s on line %d diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index f930cf0e5d897..c57779766f443 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -89,6 +89,9 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); %token T_LNUMBER "integer number (T_LNUMBER)" %token T_DNUMBER "floating-point number (T_DNUMBER)" %token T_STRING "identifier (T_STRING)" +%token T_NAME_FULLY_QUALIFIED "fully qualified name (T_NAME_FULLY_QUALIFIED)" +%token T_NAME_RELATIVE "namespace-relative name (T_NAME_RELATIVE)" +%token T_NAME_QUALIFIED "namespaced name (T_NAME_QUALIFIED)" %token T_VARIABLE "variable (T_VARIABLE)" %token T_INLINE_HTML %token T_ENCAPSED_AND_WHITESPACE "quoted-string and whitespace (T_ENCAPSED_AND_WHITESPACE)" @@ -230,7 +233,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); %token T_ERROR %type top_statement namespace_name name statement function_declaration_statement -%type class_declaration_statement trait_declaration_statement +%type class_declaration_statement trait_declaration_statement legacy_namespace_name %type interface_declaration_statement interface_extends_list %type group_use_declaration inline_use_declarations inline_use_declaration %type mixed_group_use_declaration use_declaration unprefixed_use_declaration @@ -308,13 +311,20 @@ top_statement_list: namespace_name: T_STRING { $$ = $1; } - | namespace_name T_NS_SEPARATOR T_STRING { $$ = zend_ast_append_str($1, $3); } + | T_NAME_QUALIFIED { $$ = $1; } +; + +/* Some places allow using a leading backslash before a namespace name, because PHP. */ +legacy_namespace_name: + namespace_name { $$ = $1; } + | T_NAME_FULLY_QUALIFIED { $$ = $1; } ; name: - namespace_name { $$ = $1; $$->attr = ZEND_NAME_NOT_FQ; } - | T_NAMESPACE T_NS_SEPARATOR namespace_name { $$ = $3; $$->attr = ZEND_NAME_RELATIVE; } - | T_NS_SEPARATOR namespace_name { $$ = $2; $$->attr = ZEND_NAME_FQ; } + T_STRING { $$ = $1; $$->attr = ZEND_NAME_NOT_FQ; } + | T_NAME_QUALIFIED { $$ = $1; $$->attr = ZEND_NAME_NOT_FQ; } + | T_NAME_FULLY_QUALIFIED { $$ = $1; $$->attr = ZEND_NAME_FQ; } + | T_NAME_RELATIVE { $$ = $1; $$->attr = ZEND_NAME_RELATIVE; } ; attribute_arguments: @@ -379,17 +389,13 @@ use_type: ; group_use_declaration: - namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}' + legacy_namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}' { $$ = zend_ast_create(ZEND_AST_GROUP_USE, $1, $4); } - | T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}' - { $$ = zend_ast_create(ZEND_AST_GROUP_USE, $2, $5); } ; mixed_group_use_declaration: - namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}' + legacy_namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}' { $$ = zend_ast_create(ZEND_AST_GROUP_USE, $1, $4);} - | T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}' - { $$ = zend_ast_create(ZEND_AST_GROUP_USE, $2, $5); } ; possible_comma: @@ -431,8 +437,10 @@ unprefixed_use_declaration: ; use_declaration: - unprefixed_use_declaration { $$ = $1; } - | T_NS_SEPARATOR unprefixed_use_declaration { $$ = $2; } + legacy_namespace_name + { $$ = zend_ast_create(ZEND_AST_USE_ELEM, $1, NULL); } + | legacy_namespace_name T_AS T_STRING + { $$ = zend_ast_create(ZEND_AST_USE_ELEM, $1, $3); } ; const_list: diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 7b5a8ab1c8737..7b65308b19cdb 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -1586,10 +1586,6 @@ NEWLINE ("\r"|"\n"|"\r\n") RETURN_TOKEN(T_PAAMAYIM_NEKUDOTAYIM); } -"\\" { - RETURN_TOKEN(T_NS_SEPARATOR); -} - "..." { RETURN_TOKEN(T_ELLIPSIS); } @@ -2277,6 +2273,22 @@ inline_char_handler: RETURN_TOKEN_WITH_VAL(T_ENCAPSED_AND_WHITESPACE); } +"namespace"("\\"{LABEL})+ { + RETURN_TOKEN_WITH_STR(T_NAME_RELATIVE, sizeof("namespace\\") - 1); +} + +{LABEL}("\\"{LABEL})+ { + RETURN_TOKEN_WITH_STR(T_NAME_QUALIFIED, 0); +} + +"\\"{LABEL}("\\"{LABEL})* { + RETURN_TOKEN_WITH_STR(T_NAME_FULLY_QUALIFIED, 1); +} + +"\\" { + RETURN_TOKEN(T_NS_SEPARATOR); +} + {LABEL} { RETURN_TOKEN_WITH_STR(T_STRING, 0); } From ac5fe533c1e162e833698a088dcf694b948071a7 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 15 Jun 2020 11:55:19 +0200 Subject: [PATCH 2/4] Allow using reserved class names --- Zend/tests/lsb_008.phpt | 2 +- Zend/tests/lsb_009.phpt | 2 +- Zend/tests/reserved_class_name.phpt | 22 ++++++++++++++++++++++ Zend/zend_language_parser.y | 8 ++++---- 4 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 Zend/tests/reserved_class_name.phpt diff --git a/Zend/tests/lsb_008.phpt b/Zend/tests/lsb_008.phpt index 79f906bd7e387..80d5a72878cf2 100644 --- a/Zend/tests/lsb_008.phpt +++ b/Zend/tests/lsb_008.phpt @@ -5,4 +5,4 @@ ZE2 Late Static Binding class name "static" class static { } --EXPECTF-- -Parse error: %s error,%sexpecting %s in %s on line %d +Fatal error: Cannot use 'static' as class name as it is reserved in %s on line %d diff --git a/Zend/tests/lsb_009.phpt b/Zend/tests/lsb_009.phpt index 9b1686391bd2e..aa168f73ff560 100644 --- a/Zend/tests/lsb_009.phpt +++ b/Zend/tests/lsb_009.phpt @@ -5,4 +5,4 @@ ZE2 Late Static Binding interface name "static" interface static { } --EXPECTF-- -Parse error: %s error,%sexpecting %s in %s on line %d +Fatal error: Cannot use 'static' as class name as it is reserved in %s on line %d diff --git a/Zend/tests/reserved_class_name.phpt b/Zend/tests/reserved_class_name.phpt new file mode 100644 index 0000000000000..b90548ccea5ff --- /dev/null +++ b/Zend/tests/reserved_class_name.phpt @@ -0,0 +1,22 @@ +--TEST-- +Can declare classes with reserved name +--FILE-- + +--EXPECT-- +object(FooBar\List)#1 (0) { +} +object(FooBar\List)#1 (0) { +} diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index c57779766f443..eaf118f1b9cee 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -553,10 +553,10 @@ is_variadic: class_declaration_statement: class_modifiers T_CLASS { $$ = CG(zend_lineno); } - T_STRING extends_from implements_list backup_doc_comment '{' class_statement_list '}' + identifier extends_from implements_list backup_doc_comment '{' class_statement_list '}' { $$ = zend_ast_create_decl(ZEND_AST_CLASS, $1, $3, $7, zend_ast_get_str($4), $5, $6, $9, NULL, NULL); } | T_CLASS { $$ = CG(zend_lineno); } - T_STRING extends_from implements_list backup_doc_comment '{' class_statement_list '}' + identifier extends_from implements_list backup_doc_comment '{' class_statement_list '}' { $$ = zend_ast_create_decl(ZEND_AST_CLASS, 0, $2, $6, zend_ast_get_str($3), $4, $5, $8, NULL, NULL); } ; @@ -573,13 +573,13 @@ class_modifier: trait_declaration_statement: T_TRAIT { $$ = CG(zend_lineno); } - T_STRING backup_doc_comment '{' class_statement_list '}' + identifier backup_doc_comment '{' class_statement_list '}' { $$ = zend_ast_create_decl(ZEND_AST_CLASS, ZEND_ACC_TRAIT, $2, $4, zend_ast_get_str($3), NULL, NULL, $6, NULL, NULL); } ; interface_declaration_statement: T_INTERFACE { $$ = CG(zend_lineno); } - T_STRING interface_extends_list backup_doc_comment '{' class_statement_list '}' + identifier interface_extends_list backup_doc_comment '{' class_statement_list '}' { $$ = zend_ast_create_decl(ZEND_AST_CLASS, ZEND_ACC_INTERFACE, $2, $5, zend_ast_get_str($3), NULL, $4, $7, NULL, NULL); } ; From 7cfba25d1c40ba62fe35d661bb8a95fe8563aa22 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 15 Jun 2020 12:17:34 +0200 Subject: [PATCH 3/4] Also allow reserved function / const names --- Zend/tests/grammar/regression_004.phpt | 6 ++-- Zend/tests/grammar/regression_005.phpt | 6 ++-- Zend/tests/reserved_class_name.phpt | 22 ------------- Zend/tests/reserved_namespaced_names.phpt | 40 +++++++++++++++++++++++ Zend/zend_language_parser.y | 14 +++----- 5 files changed, 51 insertions(+), 37 deletions(-) delete mode 100644 Zend/tests/reserved_class_name.phpt create mode 100644 Zend/tests/reserved_namespaced_names.phpt diff --git a/Zend/tests/grammar/regression_004.phpt b/Zend/tests/grammar/regression_004.phpt index f032fc882dabb..5dfab04744310 100644 --- a/Zend/tests/grammar/regression_004.phpt +++ b/Zend/tests/grammar/regression_004.phpt @@ -9,6 +9,6 @@ class Obj function return(){} // valid } -function echo(){} // not valid ---EXPECTF-- -Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting %s in %s on line 9 +function echo(){} // valid +--EXPECT-- + diff --git a/Zend/tests/grammar/regression_005.phpt b/Zend/tests/grammar/regression_005.phpt index ad83ee717d9cb..726ce43dad033 100644 --- a/Zend/tests/grammar/regression_005.phpt +++ b/Zend/tests/grammar/regression_005.phpt @@ -8,6 +8,6 @@ class Obj const return = 'yep'; } -const return = 'nope'; ---EXPECTF-- -Parse error: syntax error, unexpected 'return' (T_RETURN), expecting identifier (T_STRING) in %s on line 8 +const return = 'yep'; +--EXPECT-- + diff --git a/Zend/tests/reserved_class_name.phpt b/Zend/tests/reserved_class_name.phpt deleted file mode 100644 index b90548ccea5ff..0000000000000 --- a/Zend/tests/reserved_class_name.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Can declare classes with reserved name ---FILE-- - ---EXPECT-- -object(FooBar\List)#1 (0) { -} -object(FooBar\List)#1 (0) { -} diff --git a/Zend/tests/reserved_namespaced_names.phpt b/Zend/tests/reserved_namespaced_names.phpt new file mode 100644 index 0000000000000..d7c975a326208 --- /dev/null +++ b/Zend/tests/reserved_namespaced_names.phpt @@ -0,0 +1,40 @@ +--TEST-- +Can declare classes with reserved name +--FILE-- + +--EXPECT-- +object(FooBar\List)#1 (0) { +} +object(FooBar\List)#1 (0) { +} +array(0) { +} +array(0) { +} +array(0) { +} +array(0) { +} diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index eaf118f1b9cee..bc63248de66d4 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -255,7 +255,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); %type echo_expr_list unset_variables catch_name_list catch_list optional_variable parameter_list class_statement_list %type implements_list case_list if_stmt_without_else %type non_empty_parameter_list argument_list non_empty_argument_list property_list -%type class_const_list class_const_decl class_name_list trait_adaptations method_body non_empty_for_exprs +%type class_const_list class_name_list trait_adaptations method_body non_empty_for_exprs %type ctor_arguments alt_if_stmt_without_else trait_adaptation_list lexical_vars %type lexical_var_list encaps_list %type array_pair non_empty_array_pair_list array_pair_list possible_array_pair @@ -535,7 +535,7 @@ unset_variable: ; function_declaration_statement: - function returns_ref T_STRING backup_doc_comment '(' parameter_list ')' return_type + function returns_ref identifier backup_doc_comment '(' parameter_list ')' return_type backup_fn_flags '{' inner_statement_list '}' backup_fn_flags { $$ = zend_ast_create_decl(ZEND_AST_FUNC_DECL, $2 | $13, $1, $4, zend_ast_get_str($3), $6, NULL, $11, $8, NULL); CG(extra_fn_flags) = $9; } @@ -923,16 +923,12 @@ property: ; class_const_list: - class_const_list ',' class_const_decl { $$ = zend_ast_list_add($1, $3); } - | class_const_decl { $$ = zend_ast_create_list(1, ZEND_AST_CLASS_CONST_DECL, $1); } -; - -class_const_decl: - identifier '=' expr backup_doc_comment { $$ = zend_ast_create(ZEND_AST_CONST_ELEM, $1, $3, ($4 ? zend_ast_create_zval_from_str($4) : NULL)); } + class_const_list ',' const_decl { $$ = zend_ast_list_add($1, $3); } + | const_decl { $$ = zend_ast_create_list(1, ZEND_AST_CLASS_CONST_DECL, $1); } ; const_decl: - T_STRING '=' expr backup_doc_comment { $$ = zend_ast_create(ZEND_AST_CONST_ELEM, $1, $3, ($4 ? zend_ast_create_zval_from_str($4) : NULL)); } + identifier '=' expr backup_doc_comment { $$ = zend_ast_create(ZEND_AST_CONST_ELEM, $1, $3, ($4 ? zend_ast_create_zval_from_str($4) : NULL)); } ; echo_expr_list: From ed599e654de3f210628e23e97401498afd49bbb1 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 15 Jun 2020 12:20:27 +0200 Subject: [PATCH 4/4] Also allow as alias name This was already allowed for implicit alias, allow it for explicit ones as well. --- Zend/tests/reserved_namespaced_names.phpt | 7 +++++++ Zend/zend_language_parser.y | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Zend/tests/reserved_namespaced_names.phpt b/Zend/tests/reserved_namespaced_names.phpt index d7c975a326208..f3eb168295674 100644 --- a/Zend/tests/reserved_namespaced_names.phpt +++ b/Zend/tests/reserved_namespaced_names.phpt @@ -7,12 +7,15 @@ namespace FooBar { class List {} function list() { return []; } const LIST = []; + + class Test {} } namespace BarFoo { use FooBar\List as MyList; use function FooBar\list as get_list; use const FooBar\LIST as THE_LIST; + use /* namespace */ FooBar as List; var_dump(new \FooBar\List); var_dump(new MyList); @@ -22,6 +25,8 @@ namespace BarFoo { var_dump(\FooBar\LIST); var_dump(THE_LIST); + + var_dump(new List\Test); } ?> @@ -38,3 +43,5 @@ array(0) { } array(0) { } +object(FooBar\Test)#1 (0) { +} diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index bc63248de66d4..1a545a450af67 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -432,14 +432,14 @@ inline_use_declaration: unprefixed_use_declaration: namespace_name { $$ = zend_ast_create(ZEND_AST_USE_ELEM, $1, NULL); } - | namespace_name T_AS T_STRING + | namespace_name T_AS identifier { $$ = zend_ast_create(ZEND_AST_USE_ELEM, $1, $3); } ; use_declaration: legacy_namespace_name { $$ = zend_ast_create(ZEND_AST_USE_ELEM, $1, NULL); } - | legacy_namespace_name T_AS T_STRING + | legacy_namespace_name T_AS identifier { $$ = zend_ast_create(ZEND_AST_USE_ELEM, $1, $3); } ;