@@ -1112,9 +1112,10 @@ static zend_always_inline bool zend_value_instanceof_static(zval *zv) {
1112
1112
static zend_always_inline zend_class_entry * zend_fetch_ce_from_cache_slot (
1113
1113
void * * cache_slot , zend_type * type )
1114
1114
{
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
+ //}
1118
1119
1119
1120
zend_string * name = ZEND_TYPE_NAME (* type );
1120
1121
zend_class_entry * ce ;
@@ -1140,58 +1141,47 @@ static zend_always_inline zend_class_entry *zend_fetch_ce_from_cache_slot(
1140
1141
return ce ;
1141
1142
}
1142
1143
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
- }
1149
1144
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
+ }
1154
1156
}
1157
+ return false;
1155
1158
}
1156
- return 0 ;
1157
- }
1158
1159
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
+ }
1163
1165
}
1166
+ return true;
1164
1167
}
1165
- return 1 ;
1166
- }
1167
-
1168
- default :
1169
- return 0 ;
1170
- }
1171
- }
1172
1168
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;
1182
1171
}
1183
1172
}
1184
1173
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 );
1187
1176
/* If we have a CE we check if it satisfies the type constraint,
1188
1177
* otherwise it will check if a standard type satisfies it. */
1189
1178
if (ce && instanceof_function (Z_OBJCE_P (arg ), ce )) {
1190
1179
return true;
1191
1180
}
1181
+ PROGRESS_CACHE_SLOT ();
1192
1182
}
1193
1183
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 );
1195
1185
if ((type_mask & MAY_BE_CALLABLE ) &&
1196
1186
zend_is_callable (arg , is_internal ? IS_CALLABLE_SUPPRESS_DEPRECATIONS : 0 , NULL )) {
1197
1187
return 1 ;
0 commit comments