@@ -1163,6 +1163,8 @@ static zend_always_inline zval *zend_try_array_init(zval *zv)
1163
1163
_(Z_EXPECTED_NUMBER_OR_NULL, "of type int|float|null") \
1164
1164
_(Z_EXPECTED_STRING_OR_ARRAY, "of type string|array") \
1165
1165
_(Z_EXPECTED_STRING_OR_ARRAY_OR_NULL, "of type string|array|null") \
1166
+ _(Z_EXPECTED_STRING_OR_LONG, "of type string|int") \
1167
+ _(Z_EXPECTED_STRING_OR_LONG_OR_NULL, "of type string|int|null") \
1166
1168
1167
1169
#define Z_EXPECTED_TYPE
1168
1170
@@ -1598,6 +1600,19 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num
1598
1600
#define Z_PARAM_STR_OR_ARRAY_HT_OR_NULL (dest_str , dest_ht ) \
1599
1601
Z_PARAM_STR_OR_ARRAY_HT_EX(dest_str, dest_ht, 1);
1600
1602
1603
+ #define Z_PARAM_STR_OR_LONG_EX (dest_str , dest_long , is_null , allow_null ) \
1604
+ Z_PARAM_PROLOGUE(0, 0); \
1605
+ if (UNEXPECTED(!zend_parse_arg_str_or_long(_arg, &dest_str, &dest_long, &is_null, allow_null))) { \
1606
+ _expected_type = allow_null ? Z_EXPECTED_STRING_OR_LONG_OR_NULL : Z_EXPECTED_STRING_OR_LONG; \
1607
+ _error_code = ZPP_ERROR_WRONG_ARG; \
1608
+ break; \
1609
+ }
1610
+
1611
+ #define Z_PARAM_STR_OR_LONG (dest_str , dest_long ) \
1612
+ Z_PARAM_STR_OR_LONG_EX(dest_str, dest_long, _dummy, 0);
1613
+
1614
+ #define Z_PARAM_STR_OR_LONG_OR_NULL (dest_str , dest_long , is_null ) \
1615
+ Z_PARAM_STR_OR_LONG_EX(dest_str, dest_long, is_null, 1);
1601
1616
/* End of new parameter parsing API */
1602
1617
1603
1618
/* Inlined implementations shared by new and old parameter parsing APIs */
@@ -1612,6 +1627,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest);
1612
1627
ZEND_API int ZEND_FASTCALL zend_parse_arg_str_slow (zval * arg , zend_string * * dest );
1613
1628
ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak (zval * arg , zend_string * * dest );
1614
1629
ZEND_API int ZEND_FASTCALL zend_parse_arg_number_slow (zval * arg , zval * * dest );
1630
+ ZEND_API int ZEND_FASTCALL zend_parse_arg_str_or_long_slow (zval * arg , zend_string * * dest_str , zend_long * dest_long );
1615
1631
1616
1632
static zend_always_inline int zend_parse_arg_bool (zval * arg , zend_bool * dest , zend_bool * is_null , int check_null )
1617
1633
{
@@ -1835,6 +1851,26 @@ static zend_always_inline int zend_parse_arg_str_or_array_ht(
1835
1851
return 1 ;
1836
1852
}
1837
1853
1854
+ static zend_always_inline int zend_parse_arg_str_or_long (zval * arg , zend_string * * dest_str , zend_long * dest_long ,
1855
+ zend_bool * is_null , int allow_null )
1856
+ {
1857
+ if (allow_null ) {
1858
+ * is_null = 0 ;
1859
+ }
1860
+ if (EXPECTED (Z_TYPE_P (arg ) == IS_STRING )) {
1861
+ * dest_str = Z_STR_P (arg );
1862
+ } else if (EXPECTED (Z_TYPE_P (arg ) == IS_LONG )) {
1863
+ * dest_str = NULL ;
1864
+ * dest_long = Z_LVAL_P (arg );
1865
+ } else if (allow_null && EXPECTED (Z_TYPE_P (arg ) == IS_NULL )) {
1866
+ * dest_str = NULL ;
1867
+ * is_null = 1 ;
1868
+ } else {
1869
+ return zend_parse_arg_str_or_long_slow (arg , dest_str , dest_long );
1870
+ }
1871
+ return 1 ;
1872
+ }
1873
+
1838
1874
END_EXTERN_C ()
1839
1875
1840
1876
#endif /* ZEND_API_H */
0 commit comments