@@ -200,27 +200,39 @@ static bool class_visible(zend_class_entry *ce) {
200200 }
201201}
202202
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+
203212static zend_class_entry * lookup_class (
204213 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+ }
207218
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 ;
210224 }
211225
226+ zend_class_entry * ce = zend_lookup_class_ex (
227+ name , NULL , ZEND_FETCH_CLASS_ALLOW_UNLINKED | ZEND_FETCH_CLASS_NO_AUTOLOAD );
228+
212229 if (!CG (in_compilation )) {
213230 if (ce ) {
214231 return ce ;
215232 }
216233
217234 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 );
224236 }
225237 } else {
226238 if (ce && class_visible (ce )) {
0 commit comments