Re: [RFC][Discussion] NotSerializable attribute

From: Date: Wed, 03 Jan 2024 08:34:43 +0000
Subject: Re: [RFC][Discussion] NotSerializable attribute
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-122089@lists.php.net to get a copy of this message
On Jan 2, 2024, at 23:11, Nicolas Grekas <nicolas.grekas+php@gmail.com> wrote: > Regarding the inheritance-related behavior ("The non-serializable flag is > inherited by descendants"), this is very unlike any other attributes, and > this actively prevents writing a child class that'd make a parent > serializable if it wants to. That seems appropriate. Consider a class which has set itself as #[NotSerializable] because it contains something which mustn't be serialized (like a secret or an identifier returned by an FFI library), or because the lifecycle of objects of that class needs to be tightly controlled (like a singleton or a scope guard). It shouldn't be possible to make any of these serializable by creating a subclass.

« previous php.internals (#122089) next »