@@ -1140,11 +1140,11 @@ static zend_always_inline zend_class_entry *zend_fetch_ce_from_cache_slot(
11401140 return ce ;
11411141}
11421142
1143- static bool zend_check_intersection_type_from_cache_slot (zend_type_list * intersection_type_list ,
1143+ static bool zend_check_intersection_type_from_cache_slot (zend_type * original_type , zend_type_list * intersection_type_list ,
11441144 zend_class_entry * arg_ce , void * * * cache_slot_ptr )
11451145{
11461146 void * * cache_slot = * cache_slot_ptr ;
1147- zend_class_entry * ce ;
1147+ zend_class_entry * ce = NULL ;
11481148 zend_type * list_type ;
11491149 bool status = true;
11501150 ZEND_TYPE_LIST_FOREACH (intersection_type_list , list_type ) {
@@ -1162,6 +1162,9 @@ static bool zend_check_intersection_type_from_cache_slot(zend_type_list *interse
11621162 if (HAVE_CACHE_SLOT ) {
11631163 * cache_slot_ptr = cache_slot ;
11641164 }
1165+ if (status && ce ) {
1166+ zend_type_satisfied_by_class (original_type , ce );
1167+ }
11651168 return status ;
11661169}
11671170
@@ -1171,15 +1174,18 @@ static zend_always_inline bool zend_check_type_slow(
11711174{
11721175 uint32_t type_mask ;
11731176 if (ZEND_TYPE_IS_COMPLEX (* type ) && EXPECTED (Z_TYPE_P (arg ) == IS_OBJECT )) {
1174- zend_class_entry * ce ;
1177+ zend_class_entry * ce = Z_OBJCE_P (arg );
1178+ if (EXPECTED (zend_type_is_satisfied_by_class (type , ce ))) {
1179+ return 1 ;
1180+ }
11751181 if (UNEXPECTED (ZEND_TYPE_HAS_LIST (* type ))) {
11761182 zend_type * list_type ;
11771183 if (ZEND_TYPE_IS_INTERSECTION (* type )) {
1178- return zend_check_intersection_type_from_cache_slot (ZEND_TYPE_LIST (* type ), Z_OBJCE_P (arg ), & cache_slot );
1184+ return zend_check_intersection_type_from_cache_slot (type , ZEND_TYPE_LIST (* type ), Z_OBJCE_P (arg ), & cache_slot );
11791185 } else {
11801186 ZEND_TYPE_LIST_FOREACH (ZEND_TYPE_LIST (* type ), list_type ) {
11811187 if (ZEND_TYPE_IS_INTERSECTION (* list_type )) {
1182- if (zend_check_intersection_type_from_cache_slot (ZEND_TYPE_LIST (* list_type ), Z_OBJCE_P (arg ), & cache_slot )) {
1188+ if (zend_check_intersection_type_from_cache_slot (type , ZEND_TYPE_LIST (* list_type ), Z_OBJCE_P (arg ), & cache_slot )) {
11831189 return true;
11841190 }
11851191 /* The cache_slot is progressed in zend_check_intersection_type_from_cache_slot() */
@@ -1188,6 +1194,7 @@ static zend_always_inline bool zend_check_type_slow(
11881194 ce = zend_fetch_ce_from_cache_slot (cache_slot , list_type );
11891195 /* Instance of a single type part of a union is sufficient to pass the type check */
11901196 if (ce && instanceof_function (Z_OBJCE_P (arg ), ce )) {
1197+ zend_type_satisfied_by_class (type , ce );
11911198 return true;
11921199 }
11931200 PROGRESS_CACHE_SLOT ();
@@ -1199,6 +1206,7 @@ static zend_always_inline bool zend_check_type_slow(
11991206 /* If we have a CE we check if it satisfies the type constraint,
12001207 * otherwise it will check if a standard type satisfies it. */
12011208 if (ce && instanceof_function (Z_OBJCE_P (arg ), ce )) {
1209+ zend_type_satisfied_by_class (type , ce );
12021210 return true;
12031211 }
12041212 }
0 commit comments