@@ -184,29 +184,34 @@ static zend_always_inline zend_bool zend_iterable_compatibility_check(zend_arg_i
184
184
}
185
185
/* }}} */
186
186
187
+ /* todo: this is probably useful elsewhere too */
188
+ /* caller is responsible for adding any necessary refcount */
189
+ static zend_string * _get_parent_class_name (zend_class_entry * ce )
190
+ { /* {{{ */
191
+ zend_string * pname ;
192
+
193
+ if (ce -> ce_flags & ZEND_ACC_LINKED ) {
194
+ ZEND_ASSERT (ce -> parent );
195
+ pname = ce -> parent -> name ;
196
+ } else {
197
+ pname = ce -> parent_name ;
198
+ }
199
+
200
+ /* If there is a parent, it must have a name */
201
+ ZEND_ASSERT (pname );
202
+ return pname ;
203
+ }/* }}} */
204
+
187
205
static
188
206
zend_string * _resolve_parent_and_self (const zend_function * fe , zend_string * name )
189
- {
207
+ { /* {{{ */
190
208
zend_class_entry * ce = fe -> common .scope ;
191
209
/* if there isn't a class then we shouldn't be resolving parent and self */
192
210
ZEND_ASSERT (fe -> common .scope );
193
211
194
212
switch (zend_get_class_fetch_type (name )) {
195
213
case ZEND_FETCH_CLASS_PARENT :
196
- name = NULL ;
197
- if (ce -> ce_flags & ZEND_ACC_LINKED ) {
198
- if (ce -> parent && ce -> parent -> name ) {
199
- name = ce -> parent -> name ;
200
- }
201
- } else if (ce -> parent_name ) {
202
- name = ce -> parent_name ;
203
- }
204
- if (name == NULL ) {
205
- zend_error_noreturn (E_COMPILE_ERROR ,
206
- "Cannot use parent as type constraint in %s::%s() because %s does not have a parent type" ,
207
- ZEND_FN_SCOPE_NAME (fe ), ZSTR_VAL (fe -> common .function_name ),
208
- ZEND_FN_SCOPE_NAME (fe ));
209
- }
214
+ name = _get_parent_class_name (ce );
210
215
break ;
211
216
212
217
case ZEND_FETCH_CLASS_SELF :
@@ -227,7 +232,7 @@ zend_string *_resolve_parent_and_self(const zend_function *fe, zend_string *name
227
232
}
228
233
229
234
return zend_string_copy (name );
230
- }
235
+ } /* }}} */
231
236
232
237
typedef enum {
233
238
CONTRAVARIANT = -1 ,
0 commit comments