@@ -183,7 +183,7 @@ typedef struct _property_reference {
183
183
/* Struct for parameters */
184
184
typedef struct _parameter_reference {
185
185
uint32_t offset ;
186
- uint32_t required ;
186
+ zend_bool required ;
187
187
struct _zend_arg_info * arg_info ;
188
188
zend_function * fptr ;
189
189
} parameter_reference ;
@@ -670,10 +670,10 @@ static zend_op* _get_recv_op(zend_op_array *op_array, uint32_t offset)
670
670
/* }}} */
671
671
672
672
/* {{{ _parameter_string */
673
- static void _parameter_string (string * str , zend_function * fptr , struct _zend_arg_info * arg_info , uint32_t offset , uint32_t required , char * indent )
673
+ static void _parameter_string (string * str , zend_function * fptr , struct _zend_arg_info * arg_info , uint32_t offset , zend_bool required , char * indent )
674
674
{
675
675
string_printf (str , "Parameter #%d [ " , offset );
676
- if (offset >= required ) {
676
+ if (! required ) {
677
677
string_printf (str , "<optional> " );
678
678
} else {
679
679
string_printf (str , "<required> " );
@@ -708,7 +708,7 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg
708
708
} else {
709
709
string_printf (str , "$param%d" , offset );
710
710
}
711
- if (fptr -> type == ZEND_USER_FUNCTION && offset >= required ) {
711
+ if (fptr -> type == ZEND_USER_FUNCTION && ! required ) {
712
712
zend_op * precv = _get_recv_op ((zend_op_array * )fptr , offset );
713
713
if (precv && precv -> opcode == ZEND_RECV_INIT && precv -> op2_type != IS_UNUSED ) {
714
714
zval zv ;
@@ -747,7 +747,7 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg
747
747
static void _function_parameter_string (string * str , zend_function * fptr , char * indent )
748
748
{
749
749
struct _zend_arg_info * arg_info = fptr -> common .arg_info ;
750
- uint32_t i , num_args , required = fptr -> common .required_num_args ;
750
+ uint32_t i , num_args , num_required = fptr -> common .required_num_args ;
751
751
752
752
if (!arg_info ) {
753
753
return ;
@@ -761,7 +761,7 @@ static void _function_parameter_string(string *str, zend_function *fptr, char* i
761
761
string_printf (str , "%s- Parameters [%d] {\n" , indent , num_args );
762
762
for (i = 0 ; i < num_args ; i ++ ) {
763
763
string_printf (str , "%s " , indent );
764
- _parameter_string (str , fptr , arg_info , i , required , indent );
764
+ _parameter_string (str , fptr , arg_info , i , i < num_required , indent );
765
765
string_write (str , "\n" , sizeof ("\n" )- 1 );
766
766
arg_info ++ ;
767
767
}
@@ -1229,7 +1229,7 @@ static void reflection_extension_factory(zval *object, const char *name_str)
1229
1229
/* }}} */
1230
1230
1231
1231
/* {{{ reflection_parameter_factory */
1232
- static void reflection_parameter_factory (zend_function * fptr , zval * closure_object , struct _zend_arg_info * arg_info , uint32_t offset , uint32_t required , zval * object )
1232
+ static void reflection_parameter_factory (zend_function * fptr , zval * closure_object , struct _zend_arg_info * arg_info , uint32_t offset , zend_bool required , zval * object )
1233
1233
{
1234
1234
reflection_object * intern ;
1235
1235
parameter_reference * reference ;
@@ -2066,7 +2066,7 @@ ZEND_METHOD(reflection_function, returnsReference)
2066
2066
/* }}} */
2067
2067
2068
2068
/* {{{ proto public bool ReflectionFunction::getNumberOfParameters()
2069
- Gets the number of required parameters */
2069
+ Gets the number of parameters */
2070
2070
ZEND_METHOD (reflection_function , getNumberOfParameters )
2071
2071
{
2072
2072
reflection_object * intern ;
@@ -2121,7 +2121,14 @@ ZEND_METHOD(reflection_function, getParameters)
2121
2121
for (i = 0 ; i < num_args ; i ++ ) {
2122
2122
zval parameter ;
2123
2123
2124
- reflection_parameter_factory (_copy_function (fptr ), Z_ISUNDEF (intern -> obj )? NULL : & intern -> obj , arg_info , i , fptr -> common .required_num_args , & parameter );
2124
+ reflection_parameter_factory (
2125
+ _copy_function (fptr ),
2126
+ Z_ISUNDEF (intern -> obj ) ? NULL : & intern -> obj ,
2127
+ arg_info ,
2128
+ i ,
2129
+ i < fptr -> common .required_num_args ,
2130
+ & parameter
2131
+ );
2125
2132
add_next_index_zval (return_value , & parameter );
2126
2133
2127
2134
arg_info ++ ;
@@ -2533,7 +2540,7 @@ ZEND_METHOD(reflection_parameter, __construct)
2533
2540
ref = (parameter_reference * ) emalloc (sizeof (parameter_reference ));
2534
2541
ref -> arg_info = & arg_info [position ];
2535
2542
ref -> offset = (uint32_t )position ;
2536
- ref -> required = fptr -> common .required_num_args ;
2543
+ ref -> required = position < fptr -> common .required_num_args ;
2537
2544
ref -> fptr = fptr ;
2538
2545
/* TODO: copy fptr */
2539
2546
intern -> ptr = ref ;
@@ -2838,7 +2845,7 @@ ZEND_METHOD(reflection_parameter, isOptional)
2838
2845
}
2839
2846
GET_REFLECTION_OBJECT_PTR (param );
2840
2847
2841
- RETVAL_BOOL (param -> offset >= param -> required );
2848
+ RETVAL_BOOL (! param -> required );
2842
2849
}
2843
2850
/* }}} */
2844
2851
0 commit comments