Skip to content

Commit 5bfceae

Browse files
committed
Only check classes in intersection type if the type might be valid
Closes GH-9522
1 parent 09aa27c commit 5bfceae

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Zend/zend_execute.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,11 +1042,14 @@ static bool zend_check_intersection_type_from_cache_slot(zend_type_list *interse
10421042
zend_type *list_type;
10431043
bool status = true;
10441044
ZEND_TYPE_LIST_FOREACH(intersection_type_list, list_type) {
1045-
ce = zend_fetch_ce_from_cache_slot(cache_slot, list_type);
1046-
/* If type is not an instance of one of the types taking part in the
1047-
* intersection it cannot be a valid instance of the whole intersection type. */
1048-
if (!ce || !instanceof_function(arg_ce, ce)) {
1049-
status = false;
1045+
/* Only check classes if the type might be valid */
1046+
if (status) {
1047+
ce = zend_fetch_ce_from_cache_slot(cache_slot, list_type);
1048+
/* If type is not an instance of one of the types taking part in the
1049+
* intersection it cannot be a valid instance of the whole intersection type. */
1050+
if (!ce || !instanceof_function(arg_ce, ce)) {
1051+
status = false;
1052+
}
10501053
}
10511054
PROGRESS_CACHE_SLOT();
10521055
} ZEND_TYPE_LIST_FOREACH_END();

0 commit comments

Comments
 (0)