@@ -1235,22 +1235,26 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(int error_code,
1235
1235
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error (uint32_t num , zend_expected_type expected_type , zval * arg );
1236
1236
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error (uint32_t num , const char * name , zval * arg );
1237
1237
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_null_error (uint32_t num , const char * name , zval * arg );
1238
+ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_name_or_class_error (uint32_t num , const char * name , zval * arg );
1239
+ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_name_or_class_or_null_error (uint32_t num , const char * name , zval * arg );
1238
1240
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_string_or_class_error (uint32_t num , const char * name , zval * arg );
1239
1241
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_string_or_class_or_null_error (uint32_t num , const char * name , zval * arg );
1240
1242
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error (uint32_t num , char * error );
1241
1243
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error (zend_class_entry * error_ce , uint32_t arg_num , const char * format , ...);
1242
1244
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_type_error (uint32_t arg_num , const char * format , ...);
1243
1245
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error (uint32_t arg_num , const char * format , ...);
1244
1246
1245
- #define ZPP_ERROR_OK 0
1246
- #define ZPP_ERROR_FAILURE 1
1247
- #define ZPP_ERROR_WRONG_CALLBACK 2
1248
- #define ZPP_ERROR_WRONG_CLASS 3
1249
- #define ZPP_ERROR_WRONG_CLASS_OR_NULL 4
1250
- #define ZPP_ERROR_WRONG_ARG 5
1251
- #define ZPP_ERROR_WRONG_COUNT 6
1252
- #define ZPP_ERROR_WRONG_STRING_OR_CLASS 7
1253
- #define ZPP_ERROR_WRONG_STRING_OR_CLASS_OR_NULL 8
1247
+ #define ZPP_ERROR_OK 0
1248
+ #define ZPP_ERROR_FAILURE 1
1249
+ #define ZPP_ERROR_WRONG_CALLBACK 2
1250
+ #define ZPP_ERROR_WRONG_CLASS 3
1251
+ #define ZPP_ERROR_WRONG_CLASS_OR_NULL 4
1252
+ #define ZPP_ERROR_WRONG_ARG 5
1253
+ #define ZPP_ERROR_WRONG_COUNT 6
1254
+ #define ZPP_ERROR_WRONG_STRING_OR_CLASS 7
1255
+ #define ZPP_ERROR_WRONG_STRING_OR_CLASS_OR_NULL 8
1256
+ #define ZPP_ERROR_WRONG_CLASS_NAME_OR_CLASS 9
1257
+ #define ZPP_ERROR_WRONG_CLASS_NAME_OR_CLASS_OR_NULL 10
1254
1258
1255
1259
#define ZEND_PARSE_PARAMETERS_START_EX (flags , min_num_args , max_num_args ) do { \
1256
1260
const int _flags = (flags); \
@@ -1407,6 +1411,40 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num
1407
1411
#define Z_PARAM_CLASS_NAME_OR_OBJ_OR_NULL (dest ) \
1408
1412
Z_PARAM_CLASS_NAME_OR_OBJ_EX(dest, 1);
1409
1413
1414
+ #define Z_PARAM_CLASS_NAME_CE_OR_OBJ_EX (dest_ce , dest_obj , allow_null ) \
1415
+ Z_PARAM_PROLOGUE(0, 0); \
1416
+ if (UNEXPECTED(!zend_parse_arg_class_name_ce_or_obj(_arg, &dest_ce, &dest_obj, NULL, allow_null))) { \
1417
+ _expected_type = allow_null ? Z_EXPECTED_CLASS_NAME_OR_OBJECT_OR_NULL : Z_EXPECTED_CLASS_NAME_OR_OBJECT; \
1418
+ _error_code = ZPP_ERROR_WRONG_ARG; \
1419
+ break; \
1420
+ }
1421
+
1422
+ #define Z_PARAM_CLASS_NAME_CE_OR_OBJ (dest_ce , dest_obj ) \
1423
+ Z_PARAM_CLASS_NAME_CE_OR_OBJ_EX(dest_ce, dest_obj, 0);
1424
+
1425
+ #define Z_PARAM_CLASS_NAME_CE_OR_OBJ_OR_NULL (dest_ce , dest_obj ) \
1426
+ Z_PARAM_CLASS_NAME_CE_OR_OBJ_EX(dest_ce, dest_obj, 1);
1427
+
1428
+ #define Z_PARAM_CLASS_NAME_CE_OR_OBJ_OF_CLASS_EX (dest_ce , dest_obj , base_ce , allow_null ) \
1429
+ Z_PARAM_PROLOGUE(0, 0); \
1430
+ if (UNEXPECTED(!zend_parse_arg_class_name_ce_or_obj(_arg, &dest_ce, &dest_obj, base_ce, allow_null))) { \
1431
+ if (base_ce) { \
1432
+ _error = ZSTR_VAL((base_ce)->name); \
1433
+ _error_code = allow_null ? ZPP_ERROR_WRONG_CLASS_NAME_OR_CLASS_OR_NULL : ZPP_ERROR_WRONG_CLASS_NAME_OR_CLASS; \
1434
+ break; \
1435
+ } else { \
1436
+ _expected_type = allow_null ? Z_EXPECTED_CLASS_NAME_OR_OBJECT_OR_NULL : Z_EXPECTED_CLASS_NAME_OR_OBJECT_OR_NULL; \
1437
+ _error_code = ZPP_ERROR_WRONG_ARG; \
1438
+ break; \
1439
+ } \
1440
+ }
1441
+
1442
+ #define Z_PARAM_CLASS_NAME_CE_OR_OBJ_OF_CLASS (dest_ce , dest_obj , base_ce ) \
1443
+ Z_PARAM_CLASS_NAME_CE_OR_OBJ_OF_CLASS_EX(dest_ce, dest_obj, base_ce, 0);
1444
+
1445
+ #define Z_PARAM_CLASS_NAME_CE_OR_OBJ_OF_CLASS_OR_NULL (dest_ce , dest_obj , base_ce ) \
1446
+ Z_PARAM_CLASS_NAME_CE_OR_OBJ_OF_CLASS_EX(dest_ce, dest_obj, base_ce, 1);
1447
+
1410
1448
#define Z_PARAM_STR_OR_OBJ_EX (destination_string , destination_object , allow_null ) \
1411
1449
Z_PARAM_PROLOGUE(0, 0); \
1412
1450
if (UNEXPECTED(!zend_parse_arg_str_or_obj(_arg, &destination_string, &destination_object, NULL, allow_null))) { \
@@ -2002,6 +2040,31 @@ static zend_always_inline int zend_parse_arg_class_name_or_obj(
2002
2040
return 1 ;
2003
2041
}
2004
2042
2043
+ static zend_always_inline int zend_parse_arg_class_name_ce_or_obj (
2044
+ zval * arg , zend_class_entry * * destination_ce , zend_object * * destination_object , zend_class_entry * base_ce , int allow_null
2045
+ ) {
2046
+ if (EXPECTED (Z_TYPE_P (arg ) == IS_OBJECT )) {
2047
+ if (base_ce && UNEXPECTED (!instanceof_function (Z_OBJCE_P (arg ), base_ce ))) {
2048
+ return 0 ;
2049
+ }
2050
+
2051
+ * destination_object = Z_OBJ_P (arg );
2052
+ * destination_ce = NULL ;
2053
+ } else if (EXPECTED (Z_TYPE_P (arg ) == IS_STRING )) {
2054
+ * destination_object = NULL ;
2055
+ * destination_ce = zend_lookup_class (Z_STR_P (arg ));
2056
+
2057
+ return * destination_ce != NULL ;
2058
+ } else if (allow_null && EXPECTED (Z_TYPE_P (arg ) == IS_NULL )) {
2059
+ * destination_ce = NULL ;
2060
+ * destination_object = NULL ;
2061
+ } else {
2062
+ return 0 ;
2063
+ }
2064
+
2065
+ return 1 ;
2066
+ }
2067
+
2005
2068
static zend_always_inline int zend_parse_arg_str_or_obj (
2006
2069
zval * arg , zend_string * * destination_string , zend_object * * destination_object , zend_class_entry * base_ce , int allow_null
2007
2070
) {
0 commit comments