@@ -216,6 +216,15 @@ static zend_class_entry *lookup_class(const zend_function *fe, zend_string *name
216
216
return NULL ;
217
217
}
218
218
219
+ /* Instanceof that's safe to use on unlinked classes. For the unlinked case, we only handle
220
+ * class identity here. */
221
+ static zend_bool unlinked_instanceof (zend_class_entry * ce1 , zend_class_entry * ce2 ) {
222
+ if ((ce1 -> ce_flags & ZEND_ACC_LINKED ) && (ce2 -> ce_flags & ZEND_ACC_LINKED )) {
223
+ return instanceof_function (ce1 , ce2 );
224
+ }
225
+ return ce1 == ce2 ;
226
+ }
227
+
219
228
/* Unresolved means that class declarations that are currently not available are needed to
220
229
* determine whether the inheritance is valid or not. At runtime UNRESOLVED should be treated
221
230
* as an ERROR. */
@@ -254,15 +263,15 @@ static inheritance_status zend_perform_covariant_type_check(
254
263
if (!fe_ce || !proto_ce ) {
255
264
return INHERITANCE_UNRESOLVED ;
256
265
}
257
- return instanceof_function (fe_ce , proto_ce ) ? INHERITANCE_SUCCESS : INHERITANCE_ERROR ;
266
+ return unlinked_instanceof (fe_ce , proto_ce ) ? INHERITANCE_SUCCESS : INHERITANCE_ERROR ;
258
267
} else if (ZEND_TYPE_CODE (proto_type ) == IS_ITERABLE ) {
259
268
if (ZEND_TYPE_IS_CLASS (fe_type )) {
260
269
zend_string * fe_class_name = resolve_class_name (fe , ZEND_TYPE_NAME (fe_type ));
261
270
zend_class_entry * fe_ce = lookup_class (fe , fe_class_name );
262
271
if (!fe_ce ) {
263
272
return INHERITANCE_UNRESOLVED ;
264
273
}
265
- return instanceof_function (fe_ce , zend_ce_traversable )
274
+ return unlinked_instanceof (fe_ce , zend_ce_traversable )
266
275
? INHERITANCE_SUCCESS : INHERITANCE_ERROR ;
267
276
}
268
277
0 commit comments