@@ -1112,9 +1112,10 @@ static zend_always_inline bool zend_value_instanceof_static(zval *zv) {
11121112static zend_always_inline zend_class_entry * zend_fetch_ce_from_cache_slot (
11131113 void * * cache_slot , zend_type * type )
11141114{
1115- if (EXPECTED (HAVE_CACHE_SLOT && * cache_slot )) {
1116- return (zend_class_entry * ) * cache_slot ;
1117- }
1115+ // todo: work with cache_slot
1116+ //if (EXPECTED(HAVE_CACHE_SLOT && *cache_slot)) {
1117+ // return (zend_class_entry *) *cache_slot;
1118+ //}
11181119
11191120 zend_string * name = ZEND_TYPE_NAME (* type );
11201121 zend_class_entry * ce ;
@@ -1140,58 +1141,47 @@ static zend_always_inline zend_class_entry *zend_fetch_ce_from_cache_slot(
11401141 return ce ;
11411142}
11421143
1143- static int zend_type_node_matches (const zend_type_node * node , zval * zv )
1144- {
1145- switch (node -> kind ) {
1146- case ZEND_TYPE_SIMPLE : {
1147- return 2 ;
1148- }
11491144
1150- case ZEND_TYPE_UNION : {
1151- for (uint32_t i = 0 ; i < node -> compound .num_types ; i ++ ) {
1152- if (zend_type_node_matches (node -> compound .types [i ], zv )) {
1153- return 1 ;
1145+ static bool zend_check_type_slow (
1146+ zend_type * type , zend_type_node * type_tree , zval * arg , zend_reference * ref , void * * cache_slot ,
1147+ bool is_return_type , bool is_internal )
1148+ {
1149+ if (EXPECTED (type_tree != NULL ) && type_tree -> kind != ZEND_TYPE_SIMPLE ) {
1150+ switch (type_tree -> kind ) {
1151+ case ZEND_TYPE_UNION : {
1152+ for (uint32_t i = 0 ; i < type_tree -> compound .num_types ; i ++ ) {
1153+ if (zend_check_type_slow (type , type_tree -> compound .types [i ], arg , ref , cache_slot , is_return_type , is_internal )) {
1154+ return true;
1155+ }
11541156 }
1157+ return false;
11551158 }
1156- return 0 ;
1157- }
11581159
1159- case ZEND_TYPE_INTERSECTION : {
1160- for (uint32_t i = 0 ; i < node -> compound .num_types ; i ++ ) {
1161- if (!zend_type_node_matches (node -> compound .types [i ], zv )) {
1162- return 0 ;
1160+ case ZEND_TYPE_INTERSECTION : {
1161+ for (uint32_t i = 0 ; i < type_tree -> compound .num_types ; i ++ ) {
1162+ if (!zend_check_type_slow (type , type_tree -> compound .types [i ], arg , ref , cache_slot , is_return_type , is_internal )) {
1163+ return false;
1164+ }
11631165 }
1166+ return true;
11641167 }
1165- return 1 ;
1166- }
1167-
1168- default :
1169- return 0 ;
1170- }
1171- }
11721168
1173-
1174- static zend_always_inline bool zend_check_type_slow (
1175- zend_type * type , zend_type_node * type_tree , zval * arg , zend_reference * ref , void * * cache_slot ,
1176- bool is_return_type , bool is_internal )
1177- {
1178- if (EXPECTED (type_tree != NULL ) && type_tree -> kind != ZEND_TYPE_SIMPLE ) {
1179- const int result = zend_type_node_matches (type_tree , arg );
1180- if (result < 2 ) {
1181- return result ;
1169+ default :
1170+ return false;
11821171 }
11831172 }
11841173
1185- if (ZEND_TYPE_IS_COMPLEX (* type ) && EXPECTED (Z_TYPE_P (arg ) == IS_OBJECT )) {
1186- const zend_class_entry * ce = zend_fetch_ce_from_cache_slot (cache_slot , type );
1174+ if (ZEND_TYPE_IS_COMPLEX (type_tree -> simple_type ) && EXPECTED (Z_TYPE_P (arg ) == IS_OBJECT )) {
1175+ const zend_class_entry * ce = zend_fetch_ce_from_cache_slot (cache_slot , & type_tree -> simple_type );
11871176 /* If we have a CE we check if it satisfies the type constraint,
11881177 * otherwise it will check if a standard type satisfies it. */
11891178 if (ce && instanceof_function (Z_OBJCE_P (arg ), ce )) {
11901179 return true;
11911180 }
1181+ PROGRESS_CACHE_SLOT ();
11921182 }
11931183
1194- const uint32_t type_mask = ZEND_TYPE_FULL_MASK (* type );
1184+ const uint32_t type_mask = ZEND_TYPE_FULL_MASK (type_tree -> simple_type );
11951185 if ((type_mask & MAY_BE_CALLABLE ) &&
11961186 zend_is_callable (arg , is_internal ? IS_CALLABLE_SUPPRESS_DEPRECATIONS : 0 , NULL )) {
11971187 return 1 ;
0 commit comments