Skip to content

Commit 2467f75

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix Closure::call() on internal method closure
2 parents 35e1f13 + eda9f5f commit 2467f75

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Zend/tests/closure_call_internal.phpt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Closure::call() on internal method
3+
--FILE--
4+
<?php
5+
6+
var_dump(Closure::fromCallable([new DateTime(), 'getTimestamp'])->call(new DateTime('@123')));
7+
8+
?>
9+
--EXPECT--
10+
int(123)

Zend/zend_closures.c

+3
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ ZEND_METHOD(Closure, call)
155155
my_function.common.fn_flags &= ~ZEND_ACC_CLOSURE;
156156
/* use scope of passed object */
157157
my_function.common.scope = Z_OBJCE_P(newthis);
158+
if (closure->func.type == ZEND_INTERNAL_FUNCTION) {
159+
my_function.internal_function.handler = closure->orig_internal_handler;
160+
}
158161
fci_cache.function_handler = &my_function;
159162

160163
/* Runtime cache relies on bound scope to be immutable, hence we need a separate rt cache in case scope changed */

0 commit comments

Comments
 (0)