diff options
-rw-r--r-- | Zend/tests/attributes/018_variable_attribute_name.phpt | 11 | ||||
-rw-r--r-- | Zend/zend_language_parser.y | 6 |
2 files changed, 14 insertions, 3 deletions
diff --git a/Zend/tests/attributes/018_variable_attribute_name.phpt b/Zend/tests/attributes/018_variable_attribute_name.phpt new file mode 100644 index 0000000000..64fb69a4e0 --- /dev/null +++ b/Zend/tests/attributes/018_variable_attribute_name.phpt @@ -0,0 +1,11 @@ +--TEST-- +Attribute name cannot be a variable +--FILE-- +<?php + +<<$x>> +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 diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 80a57514b9..b1b9aff155 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -325,11 +325,11 @@ attribute_arguments: ; attribute_decl: - class_name_reference + class_name { $$ = zend_ast_create(ZEND_AST_ATTRIBUTE, $1, NULL); } - | class_name_reference '(' ')' + | class_name '(' ')' { $$ = zend_ast_create(ZEND_AST_ATTRIBUTE, $1, NULL); } - | class_name_reference '(' attribute_arguments ')' + | class_name '(' attribute_arguments ')' { $$ = zend_ast_create(ZEND_AST_ATTRIBUTE, $1, $3); } ; |