@@ -857,24 +857,26 @@ static bool zend_check_and_resolve_property_class_type(
857
857
if (ZEND_TYPE_HAS_LIST (info -> type )) {
858
858
zend_type * list_type ;
859
859
ZEND_TYPE_LIST_FOREACH (ZEND_TYPE_LIST (info -> type ), list_type ) {
860
- if (ZEND_TYPE_HAS_CE_CACHE (* list_type )) {
861
- ce = ZEND_TYPE_CE_CACHE (* list_type );
862
- if (!ce ) {
860
+ if (ZEND_TYPE_HAS_NAME (* list_type )) {
861
+ if (ZEND_TYPE_HAS_CE_CACHE (* list_type )) {
862
+ ce = ZEND_TYPE_CE_CACHE (* list_type );
863
+ if (!ce ) {
864
+ zend_string * name = ZEND_TYPE_NAME (* list_type );
865
+ ce = resolve_single_class_type (name , info -> ce );
866
+ if (UNEXPECTED (!ce )) {
867
+ continue ;
868
+ }
869
+ ZEND_TYPE_SET_CE_CACHE (* list_type , ce );
870
+ }
871
+ } else {
863
872
zend_string * name = ZEND_TYPE_NAME (* list_type );
864
873
ce = resolve_single_class_type (name , info -> ce );
865
- if (UNEXPECTED ( !ce ) ) {
874
+ if (!ce ) {
866
875
continue ;
867
876
}
868
- ZEND_TYPE_SET_CE_CACHE (* list_type , ce );
869
- }
870
- } else if (ZEND_TYPE_HAS_NAME (* list_type )) {
871
- zend_string * name = ZEND_TYPE_NAME (* list_type );
872
- ce = resolve_single_class_type (name , info -> ce );
873
- if (!ce ) {
874
- continue ;
877
+ zend_string_release (name );
878
+ ZEND_TYPE_SET_CE (* list_type , ce );
875
879
}
876
- zend_string_release (name );
877
- ZEND_TYPE_SET_CE (* list_type , ce );
878
880
} else {
879
881
ce = ZEND_TYPE_CE (* list_type );
880
882
}
@@ -884,25 +886,27 @@ static bool zend_check_and_resolve_property_class_type(
884
886
} ZEND_TYPE_LIST_FOREACH_END ();
885
887
return 0 ;
886
888
} else {
887
- if (ZEND_TYPE_HAS_CE_CACHE (info -> type )) {
888
- ce = ZEND_TYPE_CE_CACHE (info -> type );
889
- if (!ce ) {
889
+ if (UNEXPECTED (ZEND_TYPE_HAS_NAME (info -> type ))) {
890
+ if (ZEND_TYPE_HAS_CE_CACHE (info -> type )) {
891
+ ce = ZEND_TYPE_CE_CACHE (info -> type );
892
+ if (!ce ) {
893
+ zend_string * name = ZEND_TYPE_NAME (info -> type );
894
+ ce = resolve_single_class_type (name , info -> ce );
895
+ if (UNEXPECTED (!ce )) {
896
+ return 0 ;
897
+ }
898
+ ZEND_TYPE_SET_CE_CACHE (info -> type , ce );
899
+ }
900
+ } else {
890
901
zend_string * name = ZEND_TYPE_NAME (info -> type );
891
902
ce = resolve_single_class_type (name , info -> ce );
892
903
if (UNEXPECTED (!ce )) {
893
904
return 0 ;
894
905
}
895
- ZEND_TYPE_SET_CE_CACHE (info -> type , ce );
896
- }
897
- } else if (UNEXPECTED (ZEND_TYPE_HAS_NAME (info -> type ))) {
898
- zend_string * name = ZEND_TYPE_NAME (info -> type );
899
- ce = resolve_single_class_type (name , info -> ce );
900
- if (UNEXPECTED (!ce )) {
901
- return 0 ;
902
- }
903
906
904
- zend_string_release (name );
905
- ZEND_TYPE_SET_CE (info -> type , ce );
907
+ zend_string_release (name );
908
+ ZEND_TYPE_SET_CE (info -> type , ce );
909
+ }
906
910
} else {
907
911
ce = ZEND_TYPE_CE (info -> type );
908
912
}
@@ -980,17 +984,22 @@ ZEND_API bool zend_value_instanceof_static(zval *zv) {
980
984
#endif
981
985
982
986
static zend_always_inline bool zend_check_type_slow (
983
- zend_type type , zval * arg , zend_reference * ref , void * * cache_slot , zend_class_entry * scope ,
987
+ zend_type * type , zval * arg , zend_reference * ref , void * * cache_slot , zend_class_entry * scope ,
984
988
bool is_return_type , bool is_internal )
985
989
{
986
990
uint32_t type_mask ;
987
- if (ZEND_TYPE_HAS_CLASS (type ) && Z_TYPE_P (arg ) == IS_OBJECT ) {
991
+ if (ZEND_TYPE_HAS_CLASS (* type ) && Z_TYPE_P (arg ) == IS_OBJECT ) {
988
992
zend_class_entry * ce ;
989
- if (ZEND_TYPE_HAS_LIST (type )) {
993
+ if (ZEND_TYPE_HAS_LIST (* type )) {
990
994
zend_type * list_type ;
991
- ZEND_TYPE_LIST_FOREACH (ZEND_TYPE_LIST (type ), list_type ) {
995
+ ZEND_TYPE_LIST_FOREACH (ZEND_TYPE_LIST (* type ), list_type ) {
992
996
if (HAVE_CACHE_SLOT && * cache_slot ) {
993
997
ce = * cache_slot ;
998
+ } else if (ZEND_TYPE_HAS_CE_CACHE (* list_type ) && ZEND_TYPE_CE_CACHE (* list_type )) {
999
+ ce = ZEND_TYPE_CE_CACHE (* list_type );
1000
+ if (HAVE_CACHE_SLOT ) {
1001
+ * cache_slot = ce ;
1002
+ }
994
1003
} else {
995
1004
ce = zend_fetch_class (ZEND_TYPE_NAME (* list_type ),
996
1005
(ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD ));
@@ -1003,6 +1012,9 @@ static zend_always_inline bool zend_check_type_slow(
1003
1012
if (HAVE_CACHE_SLOT ) {
1004
1013
* cache_slot = ce ;
1005
1014
}
1015
+ if (ZEND_TYPE_HAS_CE_CACHE (* list_type )) {
1016
+ ZEND_TYPE_SET_CE_CACHE (* list_type , ce );
1017
+ }
1006
1018
}
1007
1019
if (instanceof_function (Z_OBJCE_P (arg ), ce )) {
1008
1020
return 1 ;
@@ -1014,14 +1026,22 @@ static zend_always_inline bool zend_check_type_slow(
1014
1026
} else {
1015
1027
if (EXPECTED (HAVE_CACHE_SLOT && * cache_slot )) {
1016
1028
ce = (zend_class_entry * ) * cache_slot ;
1029
+ } else if (ZEND_TYPE_HAS_CE_CACHE (* type ) && ZEND_TYPE_CE_CACHE (* type )) {
1030
+ ce = ZEND_TYPE_CE_CACHE (* type );
1031
+ if (HAVE_CACHE_SLOT ) {
1032
+ * cache_slot = ce ;
1033
+ }
1017
1034
} else {
1018
- ce = zend_fetch_class (ZEND_TYPE_NAME (type ), (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD ));
1035
+ ce = zend_fetch_class (ZEND_TYPE_NAME (* type ), (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD ));
1019
1036
if (UNEXPECTED (!ce )) {
1020
1037
goto builtin_types ;
1021
1038
}
1022
1039
if (HAVE_CACHE_SLOT ) {
1023
1040
* cache_slot = (void * ) ce ;
1024
1041
}
1042
+ if (ZEND_TYPE_HAS_CE_CACHE (* type )) {
1043
+ ZEND_TYPE_SET_CE_CACHE (* type , ce );
1044
+ }
1025
1045
}
1026
1046
if (instanceof_function (Z_OBJCE_P (arg ), ce )) {
1027
1047
return 1 ;
@@ -1030,7 +1050,7 @@ static zend_always_inline bool zend_check_type_slow(
1030
1050
}
1031
1051
1032
1052
builtin_types :
1033
- type_mask = ZEND_TYPE_FULL_MASK (type );
1053
+ type_mask = ZEND_TYPE_FULL_MASK (* type );
1034
1054
if ((type_mask & MAY_BE_CALLABLE ) && zend_is_callable (arg , 0 , NULL )) {
1035
1055
return 1 ;
1036
1056
}
@@ -1060,18 +1080,18 @@ static zend_always_inline bool zend_check_type_slow(
1060
1080
}
1061
1081
1062
1082
static zend_always_inline bool zend_check_type (
1063
- zend_type type , zval * arg , void * * cache_slot , zend_class_entry * scope ,
1083
+ zend_type * type , zval * arg , void * * cache_slot , zend_class_entry * scope ,
1064
1084
bool is_return_type , bool is_internal )
1065
1085
{
1066
1086
zend_reference * ref = NULL ;
1067
- ZEND_ASSERT (ZEND_TYPE_IS_SET (type ));
1087
+ ZEND_ASSERT (ZEND_TYPE_IS_SET (* type ));
1068
1088
1069
1089
if (UNEXPECTED (Z_ISREF_P (arg ))) {
1070
1090
ref = Z_REF_P (arg );
1071
1091
arg = Z_REFVAL_P (arg );
1072
1092
}
1073
1093
1074
- if (EXPECTED (ZEND_TYPE_CONTAINS_CODE (type , Z_TYPE_P (arg )))) {
1094
+ if (EXPECTED (ZEND_TYPE_CONTAINS_CODE (* type , Z_TYPE_P (arg )))) {
1075
1095
return 1 ;
1076
1096
}
1077
1097
@@ -1086,7 +1106,7 @@ static zend_always_inline bool zend_verify_recv_arg_type(zend_function *zf, uint
1086
1106
cur_arg_info = & zf -> common .arg_info [arg_num - 1 ];
1087
1107
1088
1108
if (ZEND_TYPE_IS_SET (cur_arg_info -> type )
1089
- && UNEXPECTED (!zend_check_type (cur_arg_info -> type , arg , cache_slot , zf -> common .scope , 0 , 0 ))) {
1109
+ && UNEXPECTED (!zend_check_type (& cur_arg_info -> type , arg , cache_slot , zf -> common .scope , 0 , 0 ))) {
1090
1110
zend_verify_arg_error (zf , cur_arg_info , arg_num , arg );
1091
1111
return 0 ;
1092
1112
}
@@ -1098,7 +1118,7 @@ static zend_always_inline bool zend_verify_variadic_arg_type(
1098
1118
zend_function * zf , zend_arg_info * arg_info , uint32_t arg_num , zval * arg , void * * cache_slot )
1099
1119
{
1100
1120
ZEND_ASSERT (ZEND_TYPE_IS_SET (arg_info -> type ));
1101
- if (UNEXPECTED (!zend_check_type (arg_info -> type , arg , cache_slot , zf -> common .scope , 0 , 0 ))) {
1121
+ if (UNEXPECTED (!zend_check_type (& arg_info -> type , arg , cache_slot , zf -> common .scope , 0 , 0 ))) {
1102
1122
zend_verify_arg_error (zf , arg_info , arg_num , arg );
1103
1123
return 0 ;
1104
1124
}
@@ -1123,7 +1143,7 @@ static zend_never_inline ZEND_ATTRIBUTE_UNUSED bool zend_verify_internal_arg_typ
1123
1143
}
1124
1144
1125
1145
if (ZEND_TYPE_IS_SET (cur_arg_info -> type )
1126
- && UNEXPECTED (!zend_check_type (cur_arg_info -> type , arg , /* cache_slot */ NULL , fbc -> common .scope , 0 , /* is_internal */ 1 ))) {
1146
+ && UNEXPECTED (!zend_check_type (& cur_arg_info -> type , arg , /* cache_slot */ NULL , fbc -> common .scope , 0 , /* is_internal */ 1 ))) {
1127
1147
return 0 ;
1128
1148
}
1129
1149
arg ++ ;
@@ -1256,7 +1276,7 @@ static bool zend_verify_internal_return_type(zend_function *zf, zval *ret)
1256
1276
return 1 ;
1257
1277
}
1258
1278
1259
- if (UNEXPECTED (!zend_check_type (ret_info -> type , ret , /* cache_slot */ NULL , NULL , 1 , /* is_internal */ 1 ))) {
1279
+ if (UNEXPECTED (!zend_check_type (& ret_info -> type , ret , /* cache_slot */ NULL , NULL , 1 , /* is_internal */ 1 ))) {
1260
1280
zend_verify_internal_return_error (zf , ret );
1261
1281
return 0 ;
1262
1282
}
0 commit comments