You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong closure scope class reported for static methods #8932
class A
{
publicstaticfunctionb()
{
echostatic::class;
}
}
class B extends A
{
}
$c = ['B', 'b'];
$d = \Closure::fromCallable($c);
$r = new \ReflectionFunction($d);
var_dump($r->getClosureScopeClass());
$d();
Resulted in this output:
object(ReflectionClass)#41 (1) {
["name"]=>
string(1) "A"
}
B
But I expected this output instead:
object(ReflectionClass)#41 (1) {
["name"]=>
string(1) "B"
}
B
Right now, there is no way to turn back a named closure into a regular callable because reflection doesn't give back the "called class" ("B" here.)
Yeah, that looks like a bug. The problem is that we're loosing the called_scope during construction of the ReflectionFunction, and it seems there is currently no way to retrieve it later.
Activity
cmb69 commentedon Jul 6, 2022
Yeah, that looks like a bug. The problem is that we're loosing the
called_scopeduring construction of theReflectionFunction, and it seems there is currently no way to retrieve it later.Fix phpGH-8932: Wrong closure scope class reported for static methods
Fix phpGH-8932: Provide a way to get the called-scope of closures
bug #3722 Allow inherited magic method to still run with calling clas…
Fix GH-8932: Provide a way to get the called-scope of closures (#9299)
Merge branch 'PHP-8.0' into PHP-8.1
Merge branch 'PHP-8.1' into PHP-8.2
Merge branch 'PHP-8.2'
bug #3777 Fix optimizing closures callbacks (nicolas-grekas)