Re: [PHP-DEV] [RFC] [Discussion] Serializable closures from constant expressions

Pierre <[email protected]>
Newsgroups gmane.comp.php.devel
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.