[php-src] PR #23203: Add stateless closure cache
| From: | iluuu1994 | Date: | Mon, 10 Aug 2026 19:07:04 +0000 |
| Subject: | [php-src] PR #23203: Add stateless closure cache | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-37743@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/23203
Author: iluuu1994
https://wiki.php.net/rfc/closure-optimizations#stateless_closure_caching
Extracted from https://github.com/php/php-src/pull/19941.
Sadly, @DanielEScherzer discovered an edge-case I did not consider:
https://3v4l.org/uovSF#v8.5.9
```php
class Foo {
public function instanceCall() {
return $this;
}
public function test($c) {
return array_map($c, [1]);
}
}
$foo = new Foo();
var_dump($foo->test('Foo::instanceCall'));
```
Here, the internal function
array_map() can perform instance calls with just a named
closure. Same with ['Foo', 'instanceCall']. That's quite
esoteric, but this behavior should first be deprecated and removed before assuming it isn't
being used.
So, for the time being, let's merge only the latter half of the RFC. Code bases with
static properly annotated will still get the full performance benefit.