Skip to content

Commit d6456ee

Browse files
committed
Fix for fake closures
1 parent d4efa20 commit d6456ee

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Zend/tests/closures/closure_get_current.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ try {
2727
echo $e->getMessage(), "\n";
2828
}
2929

30+
function foo() {
31+
var_dump(Closure::getCurrent());
32+
}
33+
34+
try {
35+
foo(...)();
36+
} catch (Error $e) {
37+
echo $e->getMessage(), "\n";
38+
}
39+
3040
?>
3141
--EXPECT--
3242
int(1)
@@ -51,3 +61,4 @@ int(10)
5161
int(10)
5262
int(11)
5363
Current function is not a closure
64+
Current function is not a closure

Zend/zend_closures.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ ZEND_METHOD(Closure, getCurrent)
426426

427427
if (!prev_ex
428428
|| !prev_ex->func
429-
|| !(prev_ex->func->common.fn_flags & ZEND_ACC_CLOSURE)) {
429+
|| (prev_ex->func->common.fn_flags & (ZEND_ACC_CLOSURE|ZEND_ACC_FAKE_CLOSURE)) != ZEND_ACC_CLOSURE) {
430430
zend_throw_error(NULL, "Current function is not a closure");
431431
RETURN_THROWS();
432432
}

0 commit comments

Comments
 (0)