Skip to content

Commit cd4d759

Browse files
committed
Reduce variability in attribute declarations
1 parent 781ca23 commit cd4d759

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Zend/tests/attributes_001.phpt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,18 @@ $r2 = $r->getProperty("x");
4242
dump_attributes($r2->getAttributes());
4343

4444
// Multiple attributes with multiple values
45-
<<a1,a2(1),a3(1,2)>>
45+
<<a1>>
46+
<<a2(1)>>
47+
<<a3(1,2)>>
4648
function f1() {}
4749
$r = new ReflectionFunction("f1");
4850
dump_attributes($r->getAttributes());
4951

5052
// Attributes with AST
51-
<<a1,a2(1+1),a3(1+3,2+2),a4(["a"=>1,"b"=>2])>>
53+
<<a1>>
54+
<<a2(1+1)>>
55+
<<a3(1+3,2+2)>>
56+
<<a4(["a"=>1,"b"=>2])>>
5257
function f2() {}
5358
$r = new ReflectionFunction("f2");
5459
dump_attributes($r->getAttributes());

Zend/zend_language_parser.y

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,13 @@ attribute_values:
319319
| attribute_values ',' expr { $$ = zend_ast_add_attribute_value($1, $3); }
320320
;
321321

322-
attribute_list:
322+
attribute_decl:
323323
class_name_reference { zend_ast_add_attribute($1, NULL); }
324324
| class_name_reference '(' attribute_values ')' { zend_ast_add_attribute($1, $3); }
325-
| attribute_list ',' class_name_reference { zend_ast_add_attribute($3, NULL); }
326-
| attribute_list ',' class_name_reference '(' attribute_values ')' { zend_ast_add_attribute($3, $5); }
327325
;
328326

329327
attribute:
330-
T_SL attribute_list T_SR
328+
T_SL attribute_decl T_SR
331329
;
332330

333331
attributes:

0 commit comments

Comments
 (0)