Closed
Description
Description
The following code:
class A
{
public static function b()
{
echo static::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.)
See code running at https://3v4l.org/OpEA9
PHP Version
PHP >= 7.1
Operating System
No response