Skip to content

Commit

Permalink
Set called_scope in __callStatic closure trampoline
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jul 23, 2021
1 parent 338a47b commit a892647
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Zend/tests/first_class_callable_005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions Zend/zend_closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit a892647

Please sign in to comment.