@@ -6613,18 +6613,18 @@ void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t flags, z
6613
6613
}
6614
6614
/* }}} */
6615
6615
6616
- void zend_compile_prop_group (zend_ast * list ) /* {{{ */
6616
+ void zend_compile_prop_group (zend_ast * ast ) /* {{{ */
6617
6617
{
6618
- zend_ast * type_ast = list -> child [0 ];
6619
- zend_ast * prop_ast = list -> child [1 ];
6620
- zend_ast * attr_ast = list -> child [2 ];
6618
+ zend_ast * type_ast = ast -> child [0 ];
6619
+ zend_ast * prop_ast = ast -> child [1 ];
6620
+ zend_ast * attr_ast = ast -> child [2 ];
6621
6621
6622
6622
if (attr_ast && zend_ast_get_list (prop_ast )-> children > 1 ) {
6623
6623
zend_error_noreturn (E_COMPILE_ERROR , "Cannot apply attributes to a group of properties" );
6624
6624
return ;
6625
6625
}
6626
6626
6627
- zend_compile_prop_decl (prop_ast , type_ast , list -> attr , attr_ast );
6627
+ zend_compile_prop_decl (prop_ast , type_ast , ast -> attr , attr_ast );
6628
6628
}
6629
6629
/* }}} */
6630
6630
@@ -6640,23 +6640,18 @@ static void zend_check_const_and_trait_alias_attr(uint32_t attr, const char* ent
6640
6640
}
6641
6641
/* }}} */
6642
6642
6643
- void zend_compile_class_const_decl (zend_ast * ast , zend_ast * attr_ast ) /* {{{ */
6643
+ void zend_compile_class_const_decl (zend_ast * ast , uint32_t flags , zend_ast * attr_ast ) /* {{{ */
6644
6644
{
6645
6645
zend_ast_list * list = zend_ast_get_list (ast );
6646
6646
zend_class_entry * ce = CG (active_class_entry );
6647
- uint32_t i ;
6647
+ uint32_t i , children = list -> children ;
6648
6648
6649
6649
if ((ce -> ce_flags & ZEND_ACC_TRAIT ) != 0 ) {
6650
6650
zend_error_noreturn (E_COMPILE_ERROR , "Traits cannot have constants" );
6651
6651
return ;
6652
6652
}
6653
6653
6654
- if (attr_ast && list -> children > 1 ) {
6655
- zend_error_noreturn (E_COMPILE_ERROR , "Cannot apply attributes to a group of constants" );
6656
- return ;
6657
- }
6658
-
6659
- for (i = 0 ; i < list -> children ; ++ i ) {
6654
+ for (i = 0 ; i < children ; ++ i ) {
6660
6655
zend_class_constant * c ;
6661
6656
zend_ast * const_ast = list -> child [i ];
6662
6657
zend_ast * name_ast = const_ast -> child [0 ];
@@ -6666,12 +6661,12 @@ void zend_compile_class_const_decl(zend_ast *ast, zend_ast *attr_ast) /* {{{ */
6666
6661
zend_string * doc_comment = doc_comment_ast ? zend_string_copy (zend_ast_get_str (doc_comment_ast )) : NULL ;
6667
6662
zval value_zv ;
6668
6663
6669
- if (UNEXPECTED (ast -> attr & (ZEND_ACC_STATIC |ZEND_ACC_ABSTRACT |ZEND_ACC_FINAL ))) {
6670
- zend_check_const_and_trait_alias_attr (ast -> attr , "constant" );
6664
+ if (UNEXPECTED (flags & (ZEND_ACC_STATIC |ZEND_ACC_ABSTRACT |ZEND_ACC_FINAL ))) {
6665
+ zend_check_const_and_trait_alias_attr (flags , "constant" );
6671
6666
}
6672
6667
6673
6668
zend_const_expr_to_zval (& value_zv , value_ast );
6674
- c = zend_declare_class_constant_ex (ce , name , & value_zv , ast -> attr , doc_comment );
6669
+ c = zend_declare_class_constant_ex (ce , name , & value_zv , flags , doc_comment );
6675
6670
6676
6671
if (attr_ast ) {
6677
6672
zend_compile_attributes (& c -> attributes , attr_ast , 0 , ZEND_ATTRIBUTE_TARGET_CLASS_CONST );
@@ -6680,6 +6675,21 @@ void zend_compile_class_const_decl(zend_ast *ast, zend_ast *attr_ast) /* {{{ */
6680
6675
}
6681
6676
/* }}} */
6682
6677
6678
+ void zend_compile_class_const_group (zend_ast * ast ) /* {{{ */
6679
+ {
6680
+ zend_ast * const_ast = ast -> child [0 ];
6681
+ zend_ast * attr_ast = ast -> child [1 ];
6682
+
6683
+ if (attr_ast && zend_ast_get_list (const_ast )-> children > 1 ) {
6684
+ zend_error_noreturn (E_COMPILE_ERROR , "Cannot apply attributes to a group of constants" );
6685
+
6686
+ return ;
6687
+ }
6688
+
6689
+ zend_compile_class_const_decl (const_ast , ast -> attr , attr_ast );
6690
+ }
6691
+ /* }}} */
6692
+
6683
6693
static void zend_compile_method_ref (zend_ast * ast , zend_trait_method_reference * method_ref ) /* {{{ */
6684
6694
{
6685
6695
zend_ast * class_ast = ast -> child [0 ];
@@ -8983,7 +8993,7 @@ void zend_compile_stmt(zend_ast *ast) /* {{{ */
8983
8993
zend_compile_prop_group (ast );
8984
8994
break ;
8985
8995
case ZEND_AST_CLASS_CONST_GROUP :
8986
- zend_compile_class_const_decl (ast -> child [ 0 ], ast -> child [ 1 ] );
8996
+ zend_compile_class_const_group (ast );
8987
8997
break ;
8988
8998
case ZEND_AST_USE_TRAIT :
8989
8999
zend_compile_use_trait (ast );
0 commit comments