@@ -758,15 +758,19 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg
758
758
static void _function_parameter_string (string * str , zend_function * fptr , char * indent )
759
759
{
760
760
struct _zend_arg_info * arg_info = fptr -> common .arg_info ;
761
- uint32_t i , required = fptr -> common .required_num_args ;
761
+ uint32_t i , num_args , required = fptr -> common .required_num_args ;
762
762
763
763
if (!arg_info ) {
764
764
return ;
765
765
}
766
766
767
+ num_args = fptr -> common .num_args ;
768
+ if (fptr -> common .fn_flags & ZEND_ACC_VARIADIC ) {
769
+ num_args ++ ;
770
+ }
767
771
string_printf (str , "\n" );
768
- string_printf (str , "%s- Parameters [%d] {\n" , indent , fptr -> common . num_args );
769
- for (i = 0 ; i < fptr -> common . num_args ; i ++ ) {
772
+ string_printf (str , "%s- Parameters [%d] {\n" , indent , num_args );
773
+ for (i = 0 ; i < num_args ; i ++ ) {
770
774
string_printf (str , "%s " , indent );
771
775
_parameter_string (str , fptr , arg_info , i , required , indent );
772
776
string_write (str , "\n" , sizeof ("\n" )- 1 );
@@ -2019,11 +2023,17 @@ ZEND_METHOD(reflection_function, getNumberOfParameters)
2019
2023
{
2020
2024
reflection_object * intern ;
2021
2025
zend_function * fptr ;
2026
+ uint32_t num_args ;
2022
2027
2023
2028
METHOD_NOTSTATIC (reflection_function_abstract_ptr );
2024
2029
GET_REFLECTION_OBJECT_PTR (fptr );
2025
2030
2026
- RETURN_LONG (fptr -> common .num_args );
2031
+ num_args = fptr -> common .num_args ;
2032
+ if (fptr -> common .fn_flags & ZEND_ACC_VARIADIC ) {
2033
+ num_args ++ ;
2034
+ }
2035
+
2036
+ RETURN_LONG (num_args );
2027
2037
}
2028
2038
/* }}} */
2029
2039
@@ -2047,16 +2057,20 @@ ZEND_METHOD(reflection_function, getParameters)
2047
2057
{
2048
2058
reflection_object * intern ;
2049
2059
zend_function * fptr ;
2050
- uint32_t i ;
2060
+ uint32_t i , num_args ;
2051
2061
struct _zend_arg_info * arg_info ;
2052
2062
2053
2063
METHOD_NOTSTATIC (reflection_function_abstract_ptr );
2054
2064
GET_REFLECTION_OBJECT_PTR (fptr );
2055
2065
2056
2066
arg_info = fptr -> common .arg_info ;
2067
+ num_args = fptr -> common .num_args ;
2068
+ if (fptr -> common .fn_flags & ZEND_ACC_VARIADIC ) {
2069
+ num_args ++ ;
2070
+ }
2057
2071
2058
2072
array_init (return_value );
2059
- for (i = 0 ; i < fptr -> common . num_args ; i ++ ) {
2073
+ for (i = 0 ; i < num_args ; i ++ ) {
2060
2074
zval parameter ;
2061
2075
2062
2076
reflection_parameter_factory (_copy_function (fptr ), Z_ISUNDEF (intern -> obj )? NULL : & intern -> obj , arg_info , i , fptr -> common .required_num_args , & parameter );
@@ -2135,6 +2149,7 @@ ZEND_METHOD(reflection_parameter, __construct)
2135
2149
zend_function * fptr ;
2136
2150
struct _zend_arg_info * arg_info ;
2137
2151
int position ;
2152
+ uint32_t num_args ;
2138
2153
zend_class_entry * ce = NULL ;
2139
2154
zend_bool is_closure = 0 ;
2140
2155
zend_bool is_invoke = 0 ;
@@ -2235,9 +2250,13 @@ ZEND_METHOD(reflection_parameter, __construct)
2235
2250
2236
2251
/* Now, search for the parameter */
2237
2252
arg_info = fptr -> common .arg_info ;
2253
+ num_args = fptr -> common .num_args ;
2254
+ if (fptr -> common .fn_flags & ZEND_ACC_VARIADIC ) {
2255
+ num_args ++ ;
2256
+ }
2238
2257
if (Z_TYPE_P (parameter ) == IS_LONG ) {
2239
2258
position = (int )Z_LVAL_P (parameter );
2240
- if (position < 0 || (uint32_t )position >= fptr -> common . num_args ) {
2259
+ if (position < 0 || (uint32_t )position >= num_args ) {
2241
2260
if (fptr -> common .fn_flags & ZEND_ACC_CALL_VIA_HANDLER ) {
2242
2261
if (fptr -> type != ZEND_OVERLOADED_FUNCTION ) {
2243
2262
zend_string_release (fptr -> common .function_name );
@@ -2256,7 +2275,7 @@ ZEND_METHOD(reflection_parameter, __construct)
2256
2275
position = -1 ;
2257
2276
convert_to_string_ex (parameter );
2258
2277
if (!is_invoke && fptr -> type == ZEND_INTERNAL_FUNCTION ) {
2259
- for (i = 0 ; i < fptr -> common . num_args ; i ++ ) {
2278
+ for (i = 0 ; i < num_args ; i ++ ) {
2260
2279
if (arg_info [i ].name ) {
2261
2280
if (strcmp (((zend_internal_arg_info * )arg_info )[i ].name , Z_STRVAL_P (parameter )) == 0 ) {
2262
2281
position = i ;
@@ -2266,7 +2285,7 @@ ZEND_METHOD(reflection_parameter, __construct)
2266
2285
}
2267
2286
}
2268
2287
} else {
2269
- for (i = 0 ; i < fptr -> common . num_args ; i ++ ) {
2288
+ for (i = 0 ; i < num_args ; i ++ ) {
2270
2289
if (arg_info [i ].name ) {
2271
2290
if (strcmp (arg_info [i ].name -> val , Z_STRVAL_P (parameter )) == 0 ) {
2272
2291
position = i ;
0 commit comments