Re: [RFC][Discussion] NotSerializable attribute
| From: | Max Semenik | Date: | Wed, 03 Jan 2024 13:17:19 +0000 |
| Subject: | Re: [RFC][Discussion] NotSerializable attribute | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-122094@lists.php.net to get a copy of this message | ||
On Wed, Jan 3, 2024 at 10:11 AM 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.
>
> To me, if this is really the behavior we want, then the attribute should
> be replaced by a maker interface.
> Then, a simple "instanceof NotSerializable" would be enough instead of
> adding yet another method to ReflectionClass.
>
As explained in the RFC, this implementation hooks to the already existing
feature. Additionally, checking a bit in zend_class_entry::ce_flags is much
faster than checking inheritance.
> this actively prevents writing a child class that'd make a parent
serializable if it wants to.
Wouldn't this violate LSP?
--
Best regards,
Max Semenik