@@ -226,6 +226,28 @@ static zend_string *_resolve_parent_and_self(const zend_function *fe, zend_strin
226
226
return zend_string_copy (name );
227
227
} /* }}} */
228
228
229
+ static zend_bool class_visible (zend_class_entry * ce ) {
230
+ if (CG (in_compilation )) {
231
+ return 1 ;
232
+ }
233
+ if (ce -> type == ZEND_INTERNAL_CLASS ) {
234
+ return !(CG (compiler_options ) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES );
235
+ } else {
236
+ ZEND_ASSERT (ce -> type == ZEND_USER_CLASS );
237
+ return !(CG (compiler_options ) & ZEND_COMPILE_IGNORE_OTHER_FILES )
238
+ || ce -> info .user .filename == CG (compiled_filename );
239
+ }
240
+ }
241
+
242
+ zend_class_entry * lookup_class (zend_string * name ) {
243
+ zend_class_entry * ce = zend_lookup_class (name );
244
+ if (!ce ) {
245
+ return NULL ;
246
+ }
247
+
248
+ return class_visible (ce ) ? ce : NULL ;
249
+ }
250
+
229
251
typedef enum {
230
252
INHERITANCE_UNRESOLVED = -1 ,
231
253
INHERITANCE_ERROR = 0 ,
@@ -272,8 +294,8 @@ _inheritance_status _check_covariance(
272
294
code = INHERITANCE_SUCCESS ;
273
295
} else {
274
296
if (fe -> common .type == ZEND_USER_FUNCTION ) {
275
- zend_class_entry * fe_ce = zend_lookup_class (fe_class_name );
276
- zend_class_entry * proto_ce = zend_lookup_class (proto_class_name );
297
+ zend_class_entry * fe_ce = lookup_class (fe_class_name );
298
+ zend_class_entry * proto_ce = lookup_class (proto_class_name );
277
299
278
300
if (fe_ce && proto_ce ) {
279
301
code = instanceof_function (fe_ce , proto_ce )
@@ -289,7 +311,7 @@ _inheritance_status _check_covariance(
289
311
}
290
312
zend_string_release (proto_class_name );
291
313
} else if (proto_type_code == IS_ITERABLE ) {
292
- zend_class_entry * fe_ce = zend_lookup_class (fe_class_name );
314
+ zend_class_entry * fe_ce = lookup_class (fe_class_name );
293
315
if (fe_ce ) {
294
316
code = instanceof_function (fe_ce , zend_ce_traversable )
295
317
? INHERITANCE_SUCCESS
0 commit comments