@@ -1217,8 +1217,8 @@ static zend_always_inline zval *zend_try_array_init(zval *zv)
1217
1217
_(Z_EXPECTED_STRING_OR_ARRAY_OR_NULL, "of type string|array|null") \
1218
1218
_(Z_EXPECTED_STRING_OR_LONG, "of type string|int") \
1219
1219
_(Z_EXPECTED_STRING_OR_LONG_OR_NULL, "of type string|int|null") \
1220
- _(Z_EXPECTED_STRING_OR_OBJECT , "of type string| object") \
1221
- _(Z_EXPECTED_STRING_OR_OBJECT_OR_NULL , "of type string| object| null") \
1220
+ _(Z_EXPECTED_CLASS_NAME_OR_OBJECT , "a valid class name or object") \
1221
+ _(Z_EXPECTED_CLASS_NAME_OR_OBJECT_OR_NULL , "a valid class name, object, or null") \
1222
1222
1223
1223
#define Z_EXPECTED_TYPE
1224
1224
@@ -1397,6 +1397,20 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num
1397
1397
#define Z_PARAM_CLASS (dest ) \
1398
1398
Z_PARAM_CLASS_EX(dest, 0, 0)
1399
1399
1400
+ #define Z_PARAM_CLASS_NAME_OR_OBJ_EX (dest_str , dest_object , allow_null ) \
1401
+ Z_PARAM_PROLOGUE(0, 0); \
1402
+ if (UNEXPECTED(!zend_parse_arg_class_name_or_obj(_arg, &dest_str, &dest_object, _i, allow_null))) { \
1403
+ _expected_type = allow_null ? Z_EXPECTED_CLASS_NAME_OR_OBJECT_OR_NULL : Z_EXPECTED_CLASS_NAME_OR_OBJECT; \
1404
+ _error_code = ZPP_ERROR_WRONG_ARG; \
1405
+ break; \
1406
+ }
1407
+
1408
+ #define Z_PARAM_CLASS_NAME_OR_OBJ (dest_str , dest_object ) \
1409
+ Z_PARAM_CLASS_NAME_OR_OBJ_EX(dest_str, dest_object, 0);
1410
+
1411
+ #define Z_PARAM_CLASS_NAME_OR_OBJ_OR_NULL (dest_str , dest_object ) \
1412
+ Z_PARAM_CLASS_NAME_OR_OBJ_EX(dest_str, dest_object, 1);
1413
+
1400
1414
/* old "d" */
1401
1415
#define Z_PARAM_DOUBLE_EX2 (dest , is_null , check_null , deref , separate ) \
1402
1416
Z_PARAM_PROLOGUE(deref, separate); \
@@ -1682,20 +1696,6 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num
1682
1696
#define Z_PARAM_STR_OR_LONG_OR_NULL (dest_str , dest_long , is_null ) \
1683
1697
Z_PARAM_STR_OR_LONG_EX(dest_str, dest_long, is_null, 1);
1684
1698
1685
- #define Z_PARAM_STR_OR_OBJ_EX (dest_str , dest_object , allow_null ) \
1686
- Z_PARAM_PROLOGUE(0, 0); \
1687
- if (UNEXPECTED(!zend_parse_arg_str_or_obj(_arg, &dest_str, &dest_object, allow_null))) { \
1688
- _expected_type = allow_null ? Z_EXPECTED_STRING_OR_OBJECT_OR_NULL : Z_EXPECTED_STRING_OR_OBJECT; \
1689
- _error_code = ZPP_ERROR_WRONG_ARG; \
1690
- break; \
1691
- }
1692
-
1693
- #define Z_PARAM_STR_OR_OBJ (dest_str , dest_object ) \
1694
- Z_PARAM_STR_OR_OBJ_EX(dest_str, dest_object, 0);
1695
-
1696
- #define Z_PARAM_STR_OR_OBJ_OR_NULL (dest_str , dest_object ) \
1697
- Z_PARAM_STR_OR_OBJ_EX(dest_str, dest_object, 1);
1698
-
1699
1699
/* End of new parameter parsing API */
1700
1700
1701
1701
/* Inlined implementations shared by new and old parameter parsing APIs */
@@ -1954,21 +1954,24 @@ static zend_always_inline int zend_parse_arg_str_or_long(zval *arg, zend_string
1954
1954
return 1 ;
1955
1955
}
1956
1956
1957
- static zend_always_inline int zend_parse_arg_str_or_obj (
1958
- zval * arg , zend_string * * dest_str , zend_object * * dest_object , int allow_null
1957
+ static zend_always_inline int zend_parse_arg_class_name_or_obj (
1958
+ zval * arg , zend_string * * dest_str , zend_object * * dest_object , int num , int allow_null
1959
1959
) {
1960
- if (EXPECTED (Z_TYPE_P (arg ) == IS_STRING )) {
1961
- * dest_str = Z_STR_P (arg );
1960
+ zend_class_entry * class_entry ;
1961
+
1962
+ if (EXPECTED (Z_TYPE_P (arg ) == IS_STRING ) && (class_entry = zend_lookup_class (Z_STR_P (arg )))) {
1963
+ * dest_str = class_entry -> name ;
1962
1964
* dest_object = NULL ;
1963
1965
} else if (EXPECTED (Z_TYPE_P (arg ) == IS_OBJECT )) {
1964
- * dest_object = Z_OBJ_P (arg );
1965
1966
* dest_str = NULL ;
1967
+ * dest_object = Z_OBJ_P (arg );
1966
1968
} else if (allow_null && EXPECTED (Z_TYPE_P (arg ) == IS_NULL )) {
1967
- * dest_object = NULL ;
1968
1969
* dest_str = NULL ;
1970
+ * dest_object = NULL ;
1969
1971
} else {
1972
+ * dest_str = NULL ;
1970
1973
* dest_object = NULL ;
1971
- return zend_parse_arg_str_slow ( arg , dest_str ) ;
1974
+ return 0 ;
1972
1975
}
1973
1976
1974
1977
return 1 ;
0 commit comments