Re: [RFC][Discussion] NotSerializable attribute
| From: | Nicolas Grekas | Date: | Wed, 03 Jan 2024 07:11:44 +0000 |
| Subject: | Re: [RFC][Discussion] NotSerializable attribute | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-122087@lists.php.net to get a copy of this message | ||
Hi Max,
Hi, I'd like to propose a new attribute, #[NotSerializable]. This
> functionality is already available for internal classes - userspace should
> benefit from it, too.
>
> The RFC: https://wiki.php.net/rfc/not_serializable
> Proposed implementation:
> https://github.com/php/php-src/pull/12788
>
> Please let me know what you think.
>
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.
Cheers,
Nicolas