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.

Would this mean that if you serialize such object (in some cache for 
example) then change the object default value in code in between, deploy 
your new code version then load the outdated cache, your object would 
behave inconsistently, because the default value has been changed, but 
the loaded object would not honor the new default behavior ?

For caches it's not that much a problem because you mostly clear caches 
when you deploy, but considering, let's say for example, Symfony 
messenger messages, which are basically serialize()'d per default, it 
becomes a major problem.

--

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.