@@ -133,14 +133,21 @@ typedef struct _type_reference {
133
133
zend_bool legacy_behavior ;
134
134
} type_reference ;
135
135
136
+ /* Struct for attributes */
137
+ typedef struct _attribute_reference {
138
+ zend_string * name ;
139
+ zval * arguments ;
140
+ } attribute_reference ;
141
+
136
142
typedef enum {
137
143
REF_TYPE_OTHER , /* Must be 0 */
138
144
REF_TYPE_FUNCTION ,
139
145
REF_TYPE_GENERATOR ,
140
146
REF_TYPE_PARAMETER ,
141
147
REF_TYPE_TYPE ,
142
148
REF_TYPE_PROPERTY ,
143
- REF_TYPE_CLASS_CONSTANT
149
+ REF_TYPE_CLASS_CONSTANT ,
150
+ REF_TYPE_ATTRIBUTE
144
151
} reflection_type_t ;
145
152
146
153
/* Struct for reflection objects */
@@ -221,6 +228,7 @@ static void reflection_free_objects_storage(zend_object *object) /* {{{ */
221
228
reflection_object * intern = reflection_object_from_obj (object );
222
229
parameter_reference * reference ;
223
230
property_reference * prop_reference ;
231
+ attribute_reference * attr_reference ;
224
232
225
233
if (intern -> ptr ) {
226
234
switch (intern -> ref_type ) {
@@ -246,6 +254,10 @@ static void reflection_free_objects_storage(zend_object *object) /* {{{ */
246
254
zend_string_release_ex (prop_reference -> unmangled_name , 0 );
247
255
efree (intern -> ptr );
248
256
break ;
257
+ case REF_TYPE_ATTRIBUTE :
258
+ attr_reference = (attribute_reference * )intern -> ptr ;
259
+ efree (attr_reference );
260
+ break ;
249
261
case REF_TYPE_GENERATOR :
250
262
case REF_TYPE_CLASS_CONSTANT :
251
263
case REF_TYPE_OTHER :
@@ -1179,6 +1191,22 @@ static void reflection_type_factory(zend_type type, zval *object, zend_bool lega
1179
1191
}
1180
1192
/* }}} */
1181
1193
1194
+ /* {{{ reflection_attribute_factory */
1195
+ static void reflection_attribute_factory (zval * object , zend_string * name , zval * arguments )
1196
+ {
1197
+ reflection_object * intern ;
1198
+ attribute_reference * reference ;
1199
+
1200
+ reflection_instantiate (reflection_attribute_ptr , object );
1201
+ intern = Z_REFLECTION_P (object );
1202
+ reference = (attribute_reference * ) emalloc (sizeof (attribute_reference ));
1203
+ reference -> name = name ;
1204
+ reference -> arguments = arguments ;
1205
+ intern -> ptr = reference ;
1206
+ intern -> ref_type = REF_TYPE_ATTRIBUTE ;
1207
+ }
1208
+ /* }}} */
1209
+
1182
1210
/* {{{ reflection_function_factory */
1183
1211
static void reflection_function_factory (zend_function * function , zval * closure_object , zval * object )
1184
1212
{
@@ -3646,7 +3674,7 @@ ZEND_METHOD(reflection_class_constant, getAttributes)
3646
3674
}
3647
3675
GET_REFLECTION_OBJECT_PTR (ref );
3648
3676
if (ref -> attributes ) {
3649
- zend_ast_convert_attributes (return_value , ref -> attributes , NULL );
3677
+ zend_ast_convert_attributes (return_value , ref -> attributes , ref -> ce );
3650
3678
} else {
3651
3679
array_init (return_value );
3652
3680
}
@@ -4027,7 +4055,7 @@ ZEND_METHOD(reflection_class, getAttributes)
4027
4055
}
4028
4056
GET_REFLECTION_OBJECT_PTR (ce );
4029
4057
if (ce -> type == ZEND_USER_CLASS && ce -> info .user .attributes ) {
4030
- zend_ast_convert_attributes (return_value , ce -> info .user .attributes , NULL );
4058
+ zend_ast_convert_attributes (return_value , ce -> info .user .attributes , ce );
4031
4059
} else {
4032
4060
array_init (return_value );
4033
4061
}
@@ -5545,7 +5573,7 @@ ZEND_METHOD(reflection_property, getAttributes)
5545
5573
}
5546
5574
GET_REFLECTION_OBJECT_PTR (ref );
5547
5575
if (ref -> prop -> attributes ) {
5548
- zend_ast_convert_attributes (return_value , ref -> prop -> attributes , NULL );
5576
+ zend_ast_convert_attributes (return_value , ref -> prop -> attributes , ref -> prop -> ce );
5549
5577
} else {
5550
5578
array_init (return_value );
5551
5579
}
0 commit comments