Commit b074c5cc551 for php.net
commit b074c5cc551f3f985cefe0267e50968191403114
Author: Niels Dossche <7771979+ndossche@users.noreply.github.com>
Date: Fri Nov 28 18:45:32 2025 +0100
reflection: Remove dead code
Since the executor needs to be active at this point, the only way you
could get an UNDEF return value is by having an exception.
Therefore, `!EG(exception)` is always false.
The check doesn't make sense, remove it.
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index a86ce16feb4..3327fdc7f6f 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -2141,12 +2141,6 @@ ZEND_METHOD(ReflectionFunction, invoke)
zend_call_known_fcc(&fcc, &retval, num_args, params, named_params);
- if (Z_TYPE(retval) == IS_UNDEF && !EG(exception)) {
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Invocation of function %s() failed", ZSTR_VAL(fptr->common.function_name));
- RETURN_THROWS();
- }
-
if (Z_ISREF(retval)) {
zend_unwrap_reference(&retval);
}
@@ -2180,12 +2174,6 @@ ZEND_METHOD(ReflectionFunction, invokeArgs)
zend_call_known_fcc(&fcc, &retval, /* num_params */ 0, /* params */ NULL, params);
- if (Z_TYPE(retval) == IS_UNDEF && !EG(exception)) {
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Invocation of function %s() failed", ZSTR_VAL(fptr->common.function_name));
- RETURN_THROWS();
- }
-
if (Z_ISREF(retval)) {
zend_unwrap_reference(&retval);
}
@@ -3496,12 +3484,6 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
callback = _copy_function(mptr);
zend_call_known_function(callback, (object ? Z_OBJ_P(object) : NULL), intern->ce, &retval, argc, params, named_params);
- if (Z_TYPE(retval) == IS_UNDEF && !EG(exception)) {
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Invocation of method %s::%s() failed", ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name));
- RETURN_THROWS();
- }
-
if (Z_ISREF(retval)) {
zend_unwrap_reference(&retval);
}