From 8bbac00e9a379b2e07bd13a9dac0c74e58eb3fe6 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Thu, 26 Feb 2026 18:44:06 -0800 Subject: [PATCH] zend_language_parser.y: simplify `class_declaration_statement` grammar Allow `class_modifiers` to be empty (resulting in a `0`) and unify the rules for class declarations with and without modifiers. --- Zend/zend_language_parser.y | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index e2686c7e1c5a8..6b6ced389b783 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -605,13 +605,10 @@ class_declaration_statement: class_modifiers T_CLASS { $$ = CG(zend_lineno); } T_STRING 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 '}' - { $$ = zend_ast_create_decl(ZEND_AST_CLASS, 0, $2, $6, zend_ast_get_str($3), $4, $5, $8, NULL, NULL); } ; class_modifiers: - class_modifier { $$ = $1; } + %empty { $$ = 0; } | class_modifiers class_modifier { $$ = zend_add_class_modifier($1, $2); if (!$$) { YYERROR; } } ;