PHP 8.6 Closure Optimizations

https://wiki.php.net/rfc/closure-optimizations

Article

  • PHP 8.6 RFC: static closures cached between uses if stateless
  • Non-static closures auto-promoted to static when $this unused
  • Roughly 3% performance gain from reduced allocations

Discussion

  • JS comparison: V8 always allocates new closure instance per evaluation vs PHP’s caching
  • Commenter noted ~3% gain felt modest; $this promotion logic was confusing
  • PHP old-timer questioned why use PHP over JS at this point

Discuss on HN


Type Link
Added Apr 16, 2026
Modified Apr 16, 2026