rfc:deprecate-json_encode-nonserializable
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:deprecate-json_encode-nonserializable [2024/09/05 08:20] – update to list affected classes and add exception for anonymous classes. pilif | rfc:deprecate-json_encode-nonserializable [2024/09/05 10:00] (current) – more detailed analysis of affected classes. Info about workaround for classes with public fields. pilif | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Deprecate json_encode() on classes marked as non-serializable ====== | ====== PHP RFC: Deprecate json_encode() on classes marked as non-serializable ====== | ||
- | * Version: 0.10 | + | * Version: 0.11 |
* Date: 2024-09-05 | * Date: 2024-09-05 | ||
* Author: Philip Hofstetter, phofstetter@sensational.ch | * Author: Philip Hofstetter, phofstetter@sensational.ch | ||
Line 45: | Line 45: | ||
At the time of writing this RFC, the following list of classes (and their subclasses) are affected by this RFC and calling < | At the time of writing this RFC, the following list of classes (and their subclasses) are affected by this RFC and calling < | ||
- | All of them are currently json-encoded as '' | + | Some of those are containers of a sort, where this encoding is especially misleading (aside of < |
+ | |||
+ | Most of the non-serializable classes have no public properties and thus encode as '' | ||
+ | |||
+ | Those which currently do have public properties are still mostly meant for internal usage and thus not ideal candidates to < | ||
+ | |||
+ | <code php> | ||
+ | $a = new SimpleXmlElement('< | ||
+ | echo json_encode($a); | ||
+ | echo json_enode((array) $a); // {" | ||
+ | </ | ||
+ | |||
+ | === Classes with public fields appearing in json_encode() output === | ||
+ | * CURLFile (has three public properties) | ||
+ | * PDORow (has one public property, queryString) | ||
+ | * PDOStatement (has one public property, queryString) | ||
+ | * SimpleXMLElement (might be useful) | ||
+ | * ReflectionAttribute | ||
+ | * ReflectionClass | ||
+ | * ReflectionClassConstant | ||
+ | * ReflectionConstant | ||
+ | * ReflectionExtension | ||
+ | * ReflectionFiber | ||
+ | * ReflectionFunctionAbstract | ||
+ | * ReflectionGenerator | ||
+ | * ReflectionParameter | ||
+ | * ReflectionProperty | ||
+ | * ReflectionReference | ||
+ | * ReflectionType | ||
+ | * ReflectionZendExtension | ||
=== Backed by temporary resources === | === Backed by temporary resources === | ||
* AddressInfo | * AddressInfo | ||
- | * CURLFile | ||
* Collator | * Collator | ||
* CurlHandle | * CurlHandle | ||
* CurlMultiHandle | * CurlMultiHandle | ||
* CurlShareHandle | * CurlShareHandle | ||
- | * DOMXPath | ||
* DOMXPath | * DOMXPath | ||
* Dba\Connection | * Dba\Connection | ||
Line 62: | Line 90: | ||
* Dom\TokenList | * Dom\TokenList | ||
* Dom\XPath | * Dom\XPath | ||
+ | * Dom\XMLDocument | ||
* EnchantBroker | * EnchantBroker | ||
* EnchantDictionary | * EnchantDictionary | ||
Line 91: | Line 120: | ||
* OpenSSLCertificateSigningRequest | * OpenSSLCertificateSigningRequest | ||
* PDO | * PDO | ||
- | * PDORow | ||
- | * PDOStatement | ||
* Pdo\Dblib | * Pdo\Dblib | ||
* Pdo\Firebird | * Pdo\Firebird | ||
Line 108: | Line 135: | ||
* SQLite3Stmt | * SQLite3Stmt | ||
* Shmop | * Shmop | ||
- | * SimpleXMLElement | ||
* Soap\Sdl | * Soap\Sdl | ||
* Soap\Url | * Soap\Url | ||
Line 128: | Line 154: | ||
* Generator | * Generator | ||
* InternalIterator | * InternalIterator | ||
- | * ReflectionAttribute | ||
- | * ReflectionClass | ||
- | * ReflectionClassConstant | ||
- | * ReflectionConstant | ||
- | * ReflectionExtension | ||
- | * ReflectionFiber | ||
- | * ReflectionFunctionAbstract | ||
- | * ReflectionGenerator | ||
- | * ReflectionParameter | ||
- | * ReflectionProperty | ||
- | * ReflectionReference | ||
- | * ReflectionType | ||
- | * ReflectionZendExtension | ||
* SensitiveParameterValue | * SensitiveParameterValue | ||
* WeakMap | * WeakMap | ||
* WeakReference | * WeakReference | ||
+ | |||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== |
rfc/deprecate-json_encode-nonserializable.1725524458.txt.gz · Last modified: 2024/09/05 08:20 by pilif