@@ -174,29 +174,34 @@ static zend_always_inline zend_bool zend_iterable_compatibility_check(zend_arg_i
174
174
}
175
175
/* }}} */
176
176
177
+ /* todo: this is probably useful elsewhere too */
178
+ /* caller is responsible for adding any necessary refcount */
179
+ static zend_string * _get_parent_class_name (zend_class_entry * ce )
180
+ { /* {{{ */
181
+ zend_string * pname ;
182
+
183
+ if (ce -> ce_flags & ZEND_ACC_LINKED ) {
184
+ ZEND_ASSERT (ce -> parent );
185
+ pname = ce -> parent -> name ;
186
+ } else {
187
+ pname = parent_name ;
188
+ }
189
+
190
+ /* If there is a parent, it must have a name */
191
+ ZEND_ASSERT (pname );
192
+ return pname ;
193
+ }/* }}} */
194
+
177
195
static
178
196
zend_string * _resolve_parent_and_self (const zend_function * fe , zend_string * name )
179
- {
197
+ { /* {{{ */
180
198
zend_class_entry * ce = fe -> common .scope ;
181
199
/* if there isn't a class then we shouldn't be resolving parent and self */
182
200
ZEND_ASSERT (fe -> common .scope );
183
201
184
202
switch (zend_get_class_fetch_type (name )) {
185
203
case ZEND_FETCH_CLASS_PARENT :
186
- name = NULL ;
187
- if (ce -> ce_flags & ZEND_ACC_LINKED ) {
188
- if (ce -> parent && ce -> parent -> name ) {
189
- name = ce -> parent -> name ;
190
- }
191
- } else if (ce -> parent_name ) {
192
- name = ce -> parent_name ;
193
- }
194
- if (name == NULL ) {
195
- zend_error_noreturn (E_COMPILE_ERROR ,
196
- "Cannot use parent as type constraint in %s::%s() because %s does not have a parent type" ,
197
- ZEND_FN_SCOPE_NAME (fe ), ZSTR_VAL (fe -> common .function_name ),
198
- ZEND_FN_SCOPE_NAME (fe ));
199
- }
204
+ name = _get_parent_class_name (ce );
200
205
break ;
201
206
202
207
case ZEND_FETCH_CLASS_SELF :
@@ -217,7 +222,7 @@ zend_string *_resolve_parent_and_self(const zend_function *fe, zend_string *name
217
222
}
218
223
219
224
return zend_string_copy (name );
220
- }
225
+ } /* }}} */
221
226
222
227
typedef enum {
223
228
CONTRAVARIANT = -1 ,
0 commit comments