RFC: Deprecate json_encode() on classes marked as non-serializable

From: Date: Tue, 03 Sep 2024 11:24:55 +0000
Subject: RFC: Deprecate json_encode() on classes marked as non-serializable
Groups: php.internals 
Request: Send a blank email to internals+get-125407@lists.php.net to get a copy of this message
Hello, As per my previous email to the list, I have now created the official RFC to deprecate calling json_serialize() on instances of classes marked with ZEND_ACC_NOT_SERIALIZABLE. https://wiki.php.net/rfc/deprecate-json_encode-nonserializable I have also created a PR with the implementation here: https://github.com/php/php-src/pull/15724 I have considered other options, both constraining the implementation to just Generator and/or to add special cases for Generator (and maybe Iterator), but they either continue to keep the asymmetry between serialize() and json_encode() and/or are making things even more inconsistent. Please tell me what you think, especially, if you agree that blanked-deprecating all of ZEND_ACC_NOT_SERIALIZABLE classes is acceptable BC-wise (after a bit of deliberation over the weekend, I think it is and most json-serializations of such marked classes are probably unintentional). Thanks in advance for all comments Philip

« previous php.internals (#125407) next »