diff --git a/Zend/tests/closure_call_internal.phpt b/Zend/tests/closure_call_internal.phpt new file mode 100644 index 00000000000..b0d71054256 --- /dev/null +++ b/Zend/tests/closure_call_internal.phpt @@ -0,0 +1,10 @@ +--TEST-- +Closure::call() on internal method +--FILE-- +call(new DateTime('@123'))); + +?> +--EXPECT-- +int(123) diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index d29feb3a951..a5ae8cde359 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -152,6 +152,9 @@ ZEND_METHOD(Closure, call) my_function.common.fn_flags &= ~ZEND_ACC_CLOSURE; /* use scope of passed object */ my_function.common.scope = newclass; + if (closure->func.type == ZEND_INTERNAL_FUNCTION) { + my_function.internal_function.handler = closure->orig_internal_handler; + } fci_cache.function_handler = &my_function; /* Runtime cache relies on bound scope to be immutable, hence we need a separate rt cache in case scope changed */