Re: [RFC][Discussion] Add #[NoSerialize] attribute for excluding properties or classes from serialization
| From: | Tim Düsterhus | Date: | Fri, 31 Oct 2025 08:44:07 +0000 |
| Subject: | Re: [RFC][Discussion] Add #[NoSerialize] attribute for excluding properties or classes from serialization | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129015@lists.php.net to get a copy of this message | ||
Hi
Am 2025-10-30 23:24, schrieb Dmytro Kulyk:
If we go in that direction, I’d suggest keeping the name #[NoSerialize], because it’s more general and clearly describes the action rather than the failure mode. #[NotSerializable] reads more like an error state, while #[NoSerialize] works naturally for both contexts — skipping properties silently and preventing class serialization (by throwing). This way, the attribute name remains short and declarative, while the actual behavior (throwing vs skipping) can be determined by where it’s applied — on a class or on a property — without introducing another attribute.That makes sense to me and I don't have a suggestion for a better name. Best regards Tim Düsterhus