Re: [RFC][Discussion] NotSerializable attribute
| From: | Rowan Tommins | Date: | Sat, 09 Dec 2023 17:15:55 +0000 |
| Subject: | Re: [RFC][Discussion] NotSerializable attribute | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-121977@lists.php.net to get a copy of this message | ||
On 9 December 2023 12:30:29 GMT, Max Semenik <maxsem.wiki@gmail.com> wrote:
>Hi, I'd like to propose a new attribute, #[NotSerializable]. This
>functionality is already available for internal classes - userspace should
>benefit from it, too.
If this ends up approximately the same as implementing serialisation as an exception, it feels quite
a thin feature. If you put __sleep and __wakeup as shown into a trait, it's already as short
and explicit as "use NotSerializable;"
What would make it more compelling is if the engine itself could do more with the attribute. For
instance, a direct isSerializable() on ReflectionClass that covered both internal and
attribute-marked classes.
It would also be useful to have some interface for classes that are *sometimes* serializable,
because they contain open-ended collections of other objects. An example being exceptions, which may
collect objects as part of the backtrace information. Such a class could iterate its contained
objects, checking if they are unserializable classes, or classes which should recursively be asked
if the instance is serializable.
Regards,
--
Rowan Tommins
[IMSoP]