@@ -1973,9 +1973,8 @@ ZEND_METHOD(ReflectionFunction, invoke)
1973
1973
{
1974
1974
zval retval;
1975
1975
zval *params;
1976
- int result, num_args;
1976
+ uint32_t num_args;
1977
1977
HashTable *named_params;
1978
- zend_fcall_info fci;
1979
1978
zend_fcall_info_cache fcc;
1980
1979
reflection_object *intern;
1981
1980
zend_function *fptr;
@@ -1986,14 +1985,6 @@ ZEND_METHOD(ReflectionFunction, invoke)
1986
1985
1987
1986
GET_REFLECTION_OBJECT_PTR(fptr);
1988
1987
1989
- fci.size = sizeof(fci);
1990
- ZVAL_UNDEF(&fci.function_name);
1991
- fci.object = NULL;
1992
- fci.retval = &retval;
1993
- fci.param_count = num_args;
1994
- fci.params = params;
1995
- fci.named_params = named_params;
1996
-
1997
1988
fcc.function_handler = fptr;
1998
1989
fcc.called_scope = NULL;
1999
1990
fcc.object = NULL;
@@ -2003,29 +1994,25 @@ ZEND_METHOD(ReflectionFunction, invoke)
2003
1994
Z_OBJ(intern->obj), &fcc.called_scope, &fcc.function_handler, &fcc.object, 0);
2004
1995
}
2005
1996
2006
- result = zend_call_function(&fci , &fcc );
1997
+ zend_call_known_fcc(&fcc , &retval, num_args, params, named_params );
2007
1998
2008
- if (result == FAILURE ) {
1999
+ if (Z_TYPE(retval) == IS_UNDEF && !EG(exception) ) {
2009
2000
zend_throw_exception_ex(reflection_exception_ptr, 0,
2010
2001
"Invocation of function %s() failed", ZSTR_VAL(fptr->common.function_name));
2011
2002
RETURN_THROWS();
2012
2003
}
2013
2004
2014
- if (Z_TYPE(retval) != IS_UNDEF) {
2015
- if (Z_ISREF(retval)) {
2016
- zend_unwrap_reference(&retval);
2017
- }
2018
- ZVAL_COPY_VALUE(return_value, &retval);
2005
+ if (Z_ISREF(retval)) {
2006
+ zend_unwrap_reference(&retval);
2019
2007
}
2008
+ ZVAL_COPY_VALUE(return_value, &retval);
2020
2009
}
2021
2010
/* }}} */
2022
2011
2023
2012
/* {{{ Invokes the function and pass its arguments as array. */
2024
2013
ZEND_METHOD(ReflectionFunction, invokeArgs)
2025
2014
{
2026
2015
zval retval;
2027
- int result;
2028
- zend_fcall_info fci;
2029
2016
zend_fcall_info_cache fcc;
2030
2017
reflection_object *intern;
2031
2018
zend_function *fptr;
@@ -2037,14 +2024,6 @@ ZEND_METHOD(ReflectionFunction, invokeArgs)
2037
2024
2038
2025
GET_REFLECTION_OBJECT_PTR(fptr);
2039
2026
2040
- fci.size = sizeof(fci);
2041
- ZVAL_UNDEF(&fci.function_name);
2042
- fci.object = NULL;
2043
- fci.retval = &retval;
2044
- fci.param_count = 0;
2045
- fci.params = NULL;
2046
- fci.named_params = params;
2047
-
2048
2027
fcc.function_handler = fptr;
2049
2028
fcc.called_scope = NULL;
2050
2029
fcc.object = NULL;
@@ -2054,20 +2033,18 @@ ZEND_METHOD(ReflectionFunction, invokeArgs)
2054
2033
Z_OBJ(intern->obj), &fcc.called_scope, &fcc.function_handler, &fcc.object, 0);
2055
2034
}
2056
2035
2057
- result = zend_call_function(&fci , &fcc );
2036
+ zend_call_known_fcc(&fcc , &retval, /* num_params */ 0, /* params */ NULL, params );
2058
2037
2059
- if (result == FAILURE ) {
2038
+ if (Z_TYPE(retval) == IS_UNDEF && !EG(exception) ) {
2060
2039
zend_throw_exception_ex(reflection_exception_ptr, 0,
2061
2040
"Invocation of function %s() failed", ZSTR_VAL(fptr->common.function_name));
2062
2041
RETURN_THROWS();
2063
2042
}
2064
2043
2065
- if (Z_TYPE(retval) != IS_UNDEF) {
2066
- if (Z_ISREF(retval)) {
2067
- zend_unwrap_reference(&retval);
2068
- }
2069
- ZVAL_COPY_VALUE(return_value, &retval);
2044
+ if (Z_ISREF(retval)) {
2045
+ zend_unwrap_reference(&retval);
2070
2046
}
2047
+ ZVAL_COPY_VALUE(return_value, &retval);
2071
2048
}
2072
2049
/* }}} */
2073
2050
@@ -3360,10 +3337,8 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
3360
3337
zval *params = NULL, *object;
3361
3338
HashTable *named_params = NULL;
3362
3339
reflection_object *intern;
3363
- zend_function *mptr;
3364
- int argc = 0, result;
3365
- zend_fcall_info fci;
3366
- zend_fcall_info_cache fcc;
3340
+ zend_function *mptr, *callback;
3341
+ uint32_t argc = 0;
3367
3342
zend_class_entry *obj_ce;
3368
3343
3369
3344
GET_REFLECTION_OBJECT_PTR(mptr);
@@ -3413,40 +3388,20 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
3413
3388
RETURN_THROWS();
3414
3389
}
3415
3390
}
3391
+ /* Copy the zend_function when calling via handler (e.g. Closure::__invoke()) */
3392
+ callback = _copy_function(mptr);
3393
+ zend_call_known_function(callback, (object ? Z_OBJ_P(object) : NULL), intern->ce, &retval, argc, params, named_params);
3416
3394
3417
- fci.size = sizeof(fci);
3418
- ZVAL_UNDEF(&fci.function_name);
3419
- fci.object = object ? Z_OBJ_P(object) : NULL;
3420
- fci.retval = &retval;
3421
- fci.param_count = argc;
3422
- fci.params = params;
3423
- fci.named_params = named_params;
3424
-
3425
- fcc.function_handler = mptr;
3426
- fcc.called_scope = intern->ce;
3427
- fcc.object = object ? Z_OBJ_P(object) : NULL;
3428
-
3429
- /*
3430
- * Copy the zend_function when calling via handler (e.g. Closure::__invoke())
3431
- */
3432
- if ((mptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
3433
- fcc.function_handler = _copy_function(mptr);
3434
- }
3435
-
3436
- result = zend_call_function(&fci, &fcc);
3437
-
3438
- if (result == FAILURE) {
3395
+ if (Z_TYPE(retval) == IS_UNDEF && !EG(exception)) {
3439
3396
zend_throw_exception_ex(reflection_exception_ptr, 0,
3440
3397
"Invocation of method %s::%s() failed", ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name));
3441
3398
RETURN_THROWS();
3442
3399
}
3443
3400
3444
- if (Z_TYPE(retval) != IS_UNDEF) {
3445
- if (Z_ISREF(retval)) {
3446
- zend_unwrap_reference(&retval);
3447
- }
3448
- ZVAL_COPY_VALUE(return_value, &retval);
3401
+ if (Z_ISREF(retval)) {
3402
+ zend_unwrap_reference(&retval);
3449
3403
}
3404
+ ZVAL_COPY_VALUE(return_value, &retval);
3450
3405
}
3451
3406
/* }}} */
3452
3407
0 commit comments