@@ -200,27 +200,39 @@ static bool class_visible(zend_class_entry *ce) {
200
200
}
201
201
}
202
202
203
+ static zend_always_inline void register_unresolved_class (zend_string * name ) {
204
+ /* We'll autoload this class and process delayed variance obligations later. */
205
+ if (!CG (delayed_autoloads )) {
206
+ ALLOC_HASHTABLE (CG (delayed_autoloads ));
207
+ zend_hash_init (CG (delayed_autoloads ), 0 , NULL , NULL , 0 );
208
+ }
209
+ zend_hash_add_empty_element (CG (delayed_autoloads ), name );
210
+ }
211
+
203
212
static zend_class_entry * lookup_class (
204
213
zend_class_entry * scope , zend_string * name , bool register_unresolved ) {
205
- uint32_t flags = ZEND_FETCH_CLASS_ALLOW_UNLINKED | ZEND_FETCH_CLASS_NO_AUTOLOAD ;
206
- zend_class_entry * ce = NULL ;
214
+ if (UNEXPECTED (!EG (active ))) {
215
+ if (zend_string_equals_ci (scope -> name , name )) {
216
+ return scope ;
217
+ }
207
218
208
- if (EG (class_table )) {
209
- ce = zend_lookup_class_ex (name , NULL , flags );
219
+ if (register_unresolved ) {
220
+ register_unresolved_class (name );
221
+ }
222
+
223
+ return NULL ;
210
224
}
211
225
226
+ zend_class_entry * ce = zend_lookup_class_ex (
227
+ name , NULL , ZEND_FETCH_CLASS_ALLOW_UNLINKED | ZEND_FETCH_CLASS_NO_AUTOLOAD );
228
+
212
229
if (!CG (in_compilation )) {
213
230
if (ce ) {
214
231
return ce ;
215
232
}
216
233
217
234
if (register_unresolved ) {
218
- /* We'll autoload this class and process delayed variance obligations later. */
219
- if (!CG (delayed_autoloads )) {
220
- ALLOC_HASHTABLE (CG (delayed_autoloads ));
221
- zend_hash_init (CG (delayed_autoloads ), 0 , NULL , NULL , 0 );
222
- }
223
- zend_hash_add_empty_element (CG (delayed_autoloads ), name );
235
+ register_unresolved_class (name );
224
236
}
225
237
} else {
226
238
if (ce && class_visible (ce )) {
0 commit comments