[GIT-PULLS] [php-src] PR #23203: Add stateless closure cache
[email protected] (iluuu1994)
| Newsgroups | php.git-pulls |
|---|---|
| Message-ID | <[email protected]> |
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.