Re: [RFC][Discussion] Add #[NoSerialize] attribute for excluding properties or classes from serialization

From: Date: Fri, 07 Nov 2025 00:13:01 +0000
Subject: Re: [RFC][Discussion] Add #[NoSerialize] attribute for excluding properties or classes from serialization
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-129122@lists.php.net to get a copy of this message
Hi all, I’ve updated the RFC to include the new class-level behavior — applying #[NoSerialize] to a class now forbids its serialization by throwing, using the same internal mechanism as built-in non-serializable classes (e.g., CurlHandle, Random\Engine\Secure). This update aligns the proposal with existing engine semantics and unifies both property-level skipping and class-level prohibition under a single attribute. The inheritance model has also been clarified: class-level #[NoSerialize] is inherited (“sticky”) and cannot be overridden in subclasses. Updated RFC: https://wiki.php.net/rfc/no_serialize_attribute Best regards, Dmytro Kulyk

« previous php.internals (#129122) next »