[php-src] Issue #8932: Wrong closure scope class reported for static methods

From: Date: Wed, 06 Jul 2022 08:32:15 +0000
Subject: [php-src] Issue #8932: Wrong closure scope class reported for static methods
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241865@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8932 Author: nicolas-grekas ### Description The following code: ```php 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 closures 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_

« previous php.bugs (#241865) next »