Skip to content

Commit 2545dac

Browse files
Girgiasnikic
authored andcommitted
Refactor zend_resolve_ce()
1 parent 0376996 commit 2545dac

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

Zend/zend_execute.c

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -842,31 +842,25 @@ static zend_class_entry *resolve_single_class_type(zend_string *name, zend_class
842842
static zend_always_inline zend_class_entry* zend_resolve_ce(
843843
zend_property_info *info, zend_type *type) {
844844
zend_class_entry *ce;
845-
if (UNEXPECTED(ZEND_TYPE_HAS_NAME(*type))) {
846-
zend_string *name = ZEND_TYPE_NAME(*type);
847-
848-
if (ZSTR_HAS_CE_CACHE(name)) {
849-
ce = ZSTR_GET_CE_CACHE(name);
850-
if (!ce) {
851-
ce = zend_lookup_class_ex(name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
852-
if (UNEXPECTED(!ce)) {
853-
/* Cannot resolve */
854-
return NULL;
855-
}
856-
}
857-
} else {
858-
ce = resolve_single_class_type(name, info->ce);
859-
if (!ce) {
860-
/* Cannot resolve */
861-
return NULL;
862-
}
863-
if (!(info->ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
864-
zend_string_release(name);
865-
ZEND_TYPE_SET_CE(*type, ce);
866-
}
845+
zend_string *name = NULL;
846+
847+
if (UNEXPECTED(!ZEND_TYPE_HAS_NAME(*type))) {
848+
return ZEND_TYPE_CE(*type);
849+
}
850+
851+
name = ZEND_TYPE_NAME(*type);
852+
853+
if (ZSTR_HAS_CE_CACHE(name)) {
854+
ce = ZSTR_GET_CE_CACHE(name);
855+
if (!ce) {
856+
ce = zend_lookup_class_ex(name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
867857
}
868858
} else {
869-
ce = ZEND_TYPE_CE(*type);
859+
ce = resolve_single_class_type(name, info->ce);
860+
if (ce && !(info->ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
861+
zend_string_release(name);
862+
ZEND_TYPE_SET_CE(*type, ce);
863+
}
870864
}
871865
return ce;
872866
}

0 commit comments

Comments
 (0)