@@ -122,36 +122,41 @@ void compile_alias_attributes(
122122 }
123123
124124 if (* attributes != NULL ) {
125- /* Validate attributes in a secondary loop (needed to detect repeated attributes). */
126- ZEND_HASH_PACKED_FOREACH_PTR (* attributes , attr ) {
127- if (attr -> offset != 0 || NULL == (config = zend_internal_attribute_get (attr -> lcname ))) {
128- continue ;
129- }
125+ zend_apply_internal_attribute_validation (* attributes , 0 , ZEND_ATTRIBUTE_TARGET_CLASS_ALIAS );
126+ }
127+ }
128+ /* }}} */
130129
131- uint32_t target = ZEND_ATTRIBUTE_TARGET_CLASS_ALIAS ;
130+ ZEND_API void zend_apply_internal_attribute_validation (HashTable * attributes , uint32_t offset , uint32_t target ) {
131+ zend_attribute * attr ;
132+ zend_internal_attribute * config ;
132133
133- if (!(target & (config -> flags & ZEND_ATTRIBUTE_TARGET_ALL ))) {
134- zend_string * location = zend_get_attribute_target_names (target );
135- zend_string * allowed = zend_get_attribute_target_names (config -> flags );
134+ /* Validate attributes in a secondary loop (needed to detect repeated attributes). */
135+ ZEND_HASH_PACKED_FOREACH_PTR (attributes , attr ) {
136+ if (attr -> offset != offset || NULL == (config = zend_internal_attribute_get (attr -> lcname ))) {
137+ continue ;
138+ }
136139
137- zend_error_noreturn (E_ERROR , "Attribute \"%s\" cannot target %s (allowed targets: %s)" ,
138- ZSTR_VAL (attr -> name ), ZSTR_VAL (location ), ZSTR_VAL (allowed )
139- );
140- }
140+ if (!(target & (config -> flags & ZEND_ATTRIBUTE_TARGET_ALL ))) {
141+ zend_string * location = zend_get_attribute_target_names (target );
142+ zend_string * allowed = zend_get_attribute_target_names (config -> flags );
141143
142- if (!(config -> flags & ZEND_ATTRIBUTE_IS_REPEATABLE )) {
143- if (zend_is_attribute_repeated (* attributes , attr )) {
144- zend_error_noreturn (E_ERROR , "Attribute \"%s\" must not be repeated" , ZSTR_VAL (attr -> name ));
145- }
146- }
144+ zend_error_noreturn (E_ERROR , "Attribute \"%s\" cannot target %s (allowed targets: %s)" ,
145+ ZSTR_VAL (attr -> name ), ZSTR_VAL (location ), ZSTR_VAL (allowed )
146+ );
147+ }
147148
148- if (config -> validator != NULL ) {
149- config -> validator (attr , target , CG (active_class_entry ));
149+ if (!(config -> flags & ZEND_ATTRIBUTE_IS_REPEATABLE )) {
150+ if (zend_is_attribute_repeated (attributes , attr )) {
151+ zend_error_noreturn (E_ERROR , "Attribute \"%s\" must not be repeated" , ZSTR_VAL (attr -> name ));
150152 }
151- } ZEND_HASH_FOREACH_END ();
152- }
153+ }
154+
155+ if (config -> validator != NULL ) {
156+ config -> validator (attr , target , CG (active_class_entry ));
157+ }
158+ } ZEND_HASH_FOREACH_END ();
153159}
154- /* }}} */
155160
156161uint32_t zend_attribute_attribute_get_flags (zend_attribute * attr , zend_class_entry * scope )
157162{
0 commit comments