From a8926474cb2c68cde2a7c0d19bcd95cdbda55ad2 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 23 Jul 2021 10:58:05 +0200 Subject: [PATCH] Set called_scope in __callStatic closure trampoline --- Zend/tests/first_class_callable_005.phpt | 14 ++++++++++---- Zend/zend_closures.c | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Zend/tests/first_class_callable_005.phpt b/Zend/tests/first_class_callable_005.phpt index c5dc0b0152a..33c7860d848 100644 --- a/Zend/tests/first_class_callable_005.phpt +++ b/Zend/tests/first_class_callable_005.phpt @@ -8,19 +8,25 @@ class Foo { } public static function __callStatic($method, $args) { - return $method; + return static::class . "::" . $method; } } +class Bar extends Foo {} + $foo = new Foo; $bar = $foo->anythingInstance(...); -echo $bar() . PHP_EOL; +echo $bar(), "\n"; $qux = Foo::anythingStatic(...); +echo $qux(), "\n"; + +$qux2 = Bar::anythingStatic(...); +echo $qux2(), "\n"; -echo $qux(); ?> --EXPECT-- anythingInstance -anythingStatic +Foo::anythingStatic +Bar::anythingStatic diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 13eb86e09bd..ceeac23531c 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -282,6 +282,7 @@ static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ { } fcc.object = fci.object = Z_OBJ_P(ZEND_THIS); + fcc.called_scope = zend_get_called_scope(EG(current_execute_data)); zend_call_function(&fci, &fcc);