Re: RFC: Deprecate json_encode() on classes marked as non-serializable
| From: | Philip Hofstetter | Date: | Thu, 05 Sep 2024 08:23:56 +0000 |
| Subject: | Re: RFC: Deprecate json_encode() on classes marked as non-serializable | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-125433@lists.php.net to get a copy of this message | ||
Hello Rob,
I think it would be good to list these non-serializable objects in the RFC.
> It doesn't have to be exhaustive, but the list includes throwables,
> weak-maps, weak-references, closures, fibers, etc. Some people may be
> relying on this behavior (and I'd be curious to know that use case myself).
>
Thank you for your note. As I went through to the code-base in order to
compile the list for the RFC, it also occurred to me that all anonymous
classes are marked as ZEND_ACC_NOT_SERIALIZABLE, but json_encode()-ing such
classes is unproblematic and probably very much desired for user land
classes.
I have updated the RFC and attached implementation to allow anonymous
classes to be json_encode()’d, provided their parent class is not marked as
ZEND_ACC_NOT_SERIALIZABLE.
Thank you very much
Philip