Skip to content

Commit 5267c48

Browse files
krakjoenikic
authored andcommitted
preserve called scope
1 parent 177c32a commit 5267c48

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
First Class Callable preserve Called Scope
3+
--FILE--
4+
<?php
5+
class Foo {
6+
public static function method() {
7+
return static::class;
8+
}
9+
}
10+
11+
class Bar extends Foo {}
12+
13+
$bar = Bar::method(...);
14+
15+
echo $bar();
16+
?>
17+
--EXPECT--
18+
Bar

Zend/zend_closures.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ void zend_closure_from_frame(zval *return_value, zend_execute_data *call) { /* {
783783

784784
zend_create_fake_closure(return_value, mptr, mptr->common.scope, mptr->common.scope, &instance);
785785
} else {
786-
zend_create_fake_closure(return_value, mptr, mptr->common.scope, mptr->common.scope, NULL);
786+
zend_create_fake_closure(return_value, mptr, mptr->common.scope, Z_CE(call->This), NULL);
787787
}
788788
} /* }}} */
789789

0 commit comments

Comments
 (0)