Re: [PHP-DEV] [RFC] [Discussion] Serializable closures from constant expressions
[email protected] (Pierre) Sat, 4 Jul 2026 11:37:36 +0200
| Newsgroups | php.internals |
|---|---|
| Message-ID | <[email protected]> |
Le 10/06/2026 à 19:02, Nicolas Grekas a écrit : > Hi, > > I'd like to open the discussion on a new RFC: > https://wiki.php.net/rfc/serializable_closures > > PHP 8.5 allowed closures in attribute arguments and parameter > defaults. These closures are static and capture nothing, yet they > cannot be serialized, which silently breaks every > serialize()-based metadata cache that meets them. > > The RFC proposes to make them serializable as references to their > declaration site. > > Feedback welcome. > > Cheers, > Nicolas Please forget my previous email, this was answered in the RFC: > Unserializing autoloads the class if needed and recreates the closure /as if its constant expression had just been evaluated/: same code, statically scoped to its declaring class (|self::|, private member access and |static::| behave identically), Sorry for the noise! Regards, -- Pierre