PHP RFC: Closure optimizations
Summary
This RFC proposes two optimizations for PHP closures in PHP 8.6: inferring non-static closures as static when they do not use $this, and caching stateless closures that do not capture variables or declare static vars. The changes aim to improve performance but introduce backward-incompatible considerations, such as ReflectionFunction::getClosureThis() returning null for inferred statics and identicality of stateless closures from the same location. A Symfony Demo test reportedly inferred a majority of static closures, illustrating potential gains, balanced against BC risks and behavior changes.