Re: [RFC][Discussion] Add #[NoSerialize] attribute for excluding properties or classes from serialization
| From: | Tim Düsterhus | Date: | Thu, 30 Oct 2025 08:23:03 +0000 |
| Subject: | Re: [RFC][Discussion] Add #[NoSerialize] attribute for excluding properties or classes from serialization | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129005@lists.php.net to get a copy of this message | ||
Hi
I am just noticing that your RFC still is marked as Draft, both within the RFC text and within the overview at https://wiki.php.net/rfc. Don't forget to adjust the status to “Under Discussion” for proper visibility.
Am 2025-10-29 23:23, schrieb Dmytro Kulyk:
It already makes no sense because the class-level attribute will be excluded from the RFC, and I have no plan to add something like this to #[NotSerializable]. It may be added in a future RFC.I am seeing that you adjusted the RFC to remove the support for applying
#[\NoSerialize] to classes. Given that we determined that serializing classes should either throw or work (i.e. that serializing them to null is never right), I don't think that two separate attributes are necessary. While a combined attribute would behave somewhat differently for classes and properties, the name of #[\NoSerialize] and #[\NotSerializable] is very similar and thus confusing in itself. I would suggest to merge the RFCs of #[\NoSerialize] and #[\NotSerializable] into a single attribute, since in both cases you are indicating “I don't want this serialized” and I think it is reasonable to expect from users to learn that there is some difference in behavior for properties compared to classes.
Best regards
Tim Düsterhus