@@ -5743,7 +5743,7 @@ static void zend_compile_attribute(zval *v, zend_ast *ast) /* {{{ */
5743
5743
}
5744
5744
/* }}} */
5745
5745
5746
- static HashTable * zend_compile_attributes (zend_ast * ast ) /* {{{ */
5746
+ static HashTable * zend_compile_attributes (zend_ast * ast , int target ) /* {{{ */
5747
5747
{
5748
5748
HashTable * attr ;
5749
5749
@@ -5778,7 +5778,7 @@ static HashTable *zend_compile_attributes(zend_ast *ast) /* {{{ */
5778
5778
5779
5779
if (validator != NULL ) {
5780
5780
cb = * validator ;
5781
- cb (& a );
5781
+ cb (& a , target );
5782
5782
}
5783
5783
5784
5784
if (x ) {
@@ -5921,7 +5921,7 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32_t fall
5921
5921
zend_hash_init (op_array -> attributes , 8 , NULL , ZVAL_PTR_DTOR , 0 );
5922
5922
}
5923
5923
5924
- ZVAL_ARR (& attr , zend_compile_attributes (attributes_ast ));
5924
+ ZVAL_ARR (& attr , zend_compile_attributes (attributes_ast , ZEND_ATTRIBUTE_TARGET_PARAMETER ));
5925
5925
zend_hash_index_add (op_array -> attributes , i , & attr );
5926
5926
}
5927
5927
@@ -6381,7 +6381,11 @@ void zend_compile_func_decl(znode *result, zend_ast *ast, zend_bool toplevel) /*
6381
6381
op_array -> doc_comment = zend_string_copy (decl -> doc_comment );
6382
6382
}
6383
6383
if (decl -> attributes ) {
6384
- op_array -> attributes = zend_compile_attributes (decl -> attributes );
6384
+ int target = ZEND_ATTRIBUTE_TARGET_FUNCTION ;
6385
+ if (is_method ) {
6386
+ target = ZEND_ATTRIBUTE_TARGET_METHOD ;
6387
+ }
6388
+ op_array -> attributes = zend_compile_attributes (decl -> attributes , target );
6385
6389
}
6386
6390
if (decl -> kind == ZEND_AST_CLOSURE || decl -> kind == ZEND_AST_ARROW_FUNC ) {
6387
6391
op_array -> fn_flags |= ZEND_ACC_CLOSURE ;
@@ -6555,7 +6559,7 @@ void zend_compile_prop_group(zend_ast *list) /* {{{ */
6555
6559
zend_ast * type_ast = list -> child [0 ];
6556
6560
zend_ast * prop_ast = list -> child [1 ];
6557
6561
6558
- attributes = list -> child [2 ] ? zend_compile_attributes (list -> child [2 ]) : NULL ;
6562
+ attributes = list -> child [2 ] ? zend_compile_attributes (list -> child [2 ], ZEND_ATTRIBUTE_TARGET_PROPERTY ) : NULL ;
6559
6563
6560
6564
zend_compile_prop_decl (prop_ast , type_ast , list -> attr , attributes );
6561
6565
@@ -6589,7 +6593,7 @@ void zend_compile_class_const_decl(zend_ast *ast, zend_ast *attr_ast) /* {{{ */
6589
6593
return ;
6590
6594
}
6591
6595
6592
- attributes = attr_ast ? zend_compile_attributes (attr_ast ) : NULL ;
6596
+ attributes = attr_ast ? zend_compile_attributes (attr_ast , ZEND_ATTRIBUTE_TARGET_CLASS_CONST ) : NULL ;
6593
6597
6594
6598
for (i = 0 ; i < list -> children ; ++ i ) {
6595
6599
zend_ast * const_ast = list -> child [i ];
@@ -6820,7 +6824,7 @@ zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
6820
6824
ce -> info .user .doc_comment = zend_string_copy (decl -> doc_comment );
6821
6825
}
6822
6826
if (decl -> attributes ) {
6823
- ce -> info .user .attributes = zend_compile_attributes (decl -> attributes );
6827
+ ce -> info .user .attributes = zend_compile_attributes (decl -> attributes , ZEND_ATTRIBUTE_TARGET_CLASS );
6824
6828
}
6825
6829
6826
6830
if (UNEXPECTED ((decl -> flags & ZEND_ACC_ANON_CLASS ))) {
0 commit comments