rfc:array-to-string
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:array-to-string [2015/01/11 23:02] – francois | rfc:array-to-string [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Improve array to string conversion ====== | ====== Improve array to string conversion ====== | ||
- | * Version: | + | * Version: |
* Creation date: 2015-01-10 | * Creation date: 2015-01-10 | ||
- | * Last modification date : 2015-01-11 | + | * Last modification date : 2016-02-02 |
- | * Author: François Laupretre, francois@tekwire.net | + | * Author: François Laupretre, |
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
+ | |||
+ | This RFC is withdrawn because discussion shows that the subject is far from mature | ||
+ | and potential side effects require more discussions. It will probably be revived | ||
+ | in the future but potential BC breaks reserve such changes for a major release. | ||
===== Introduction ===== | ===== Introduction ===== | ||
Line 19: | Line 23: | ||
E_NOTICE and ' | E_NOTICE and ' | ||
- | I consider this as | + | We consider this as no more than a temporary |
- | a half-backed solution : we raise an error, which is not a ' | + | and we return a useless string. |
- | error (an E_WARNING would be) and we return a useless string | + | |
- | Off topic: I am personally against the existence of E_NOTICE and E_STRICT, which | + | |
- | are, IMO, half-backed solutions too. | + | |
- | The only possible justification I imagine for the current behavior | + | Now, the release of a new major version |
- | stopped | + | |
- | Now, the release of a new major version is the occasion | + | Note: the RFC originally proposed, either to fully support |
- | behaviors we have been pulling behind us for years. | + | |
- | + | So the other option was removed, | |
- | I think of two possible alternative | + | |
==== 1st alternative: | ==== 1st alternative: | ||
Here, we consider that array-to-string conversion was never actively supported nor | Here, we consider that array-to-string conversion was never actively supported nor | ||
- | encouraged and that it is time to disable it definitely. | + | encouraged, that, it most cases, its only effect is hiding bugs, and that it is time to disable it definitely. |
- | As noone ever agreed | + | Another argument is that there never was an agreement |
- | clean solution is to really disable it. | + | to convert an array to a string. |
- | Array-to-string | + | So, we propose that Array-to-string |
- | any conversion attempt generates | + | as object-to-string with no '__toString' method: |
- | if the program is still alive, the conversion returns ' | + | any conversion attempt generates |
+ | if the program is still alive, the conversion returns ' | ||
+ | message is suppressed. | ||
+ | No more worries about hiding bugs with this logic, as masking such an error level is a strong | ||
+ | user decision, definitely not the same as disabling E_NOTICE. | ||
- | We could go through a migration phase with an E_DEPRECATED but the 5.7 release was rejected | + | We could go through a migration phase using E_DEPRECATED, but we consider |
- | and we already raise an E_NOTICE. If 5.7 is revived, we'll replace the E_NOTICE | + | that, since an E_NOTICE is currently generated, it may be considered as a |
- | with E_DEPRECATED but, otherwise, this phase can probably be skipped. | + | deprecation notice, and we can directly switch to E_RECOVERABLE_ERROR. |
- | ==== 2nd alternative: | + | Another argument is that, while this one should not be very problematic, |
+ | always better to introduce a BC break in a major version. | ||
- | Here, we decide that array-to-string conversion | + | If 5.7 is revived, it will contain an interim version, |
- | standard algorithm to perform the conversion, fix it in stone and | + | |
- | encourage C and PHP code to use it with no restriction. | + | |
- | Of course, the first step is to remove the E_NOTICE. | + | ==== 2nd alternative: |
- | + | ||
- | The 2nd step is the choice of the conversion algorithm. We could for instance | + | |
- | convert the array to a | + | |
- | recursive concatenation of every non-array elements of the | + | |
- | array tree, each of them converted to a string (a recursive implode() with no ' | + | |
- | Array elements would be taken in array order, keys would be ignored. | + | |
- | Existing rules for non-array types to string conversions would be applied to all | + | Removed |
- | non-array members of the input array. | + | |
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | If we deprecate array-to-string, | + | The potential |
- | is an error. We just don't tolerate this error anymore. | + | are important because a lot of PHP code runs in E_NOTICE-disabled environments and |
- | important because a lot of PHP code runs in E_NOTICE-disabled environments and | + | |
the ' | the ' | ||
- | If we add full support, the removal of E_NOTICE | + | In balance of this, we can consider that raising |
- | probably agree that anybody relying on the ' | + | where E_NOTICE |
- | the overall BC break is minimal. | + | remained unnoticed because |
+ | |||
+ | Actually, during the discussion, the opinions seemed to converge towards | ||
+ | the position that discovering undetected bugs is probably more important than | ||
+ | potential BC breaks. | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
- | PHP 7 | + | 7.0 |
===== RFC Impact ===== | ===== RFC Impact ===== | ||
- | Touches every explicit or implicit array-to-string | + | Touches every explicit or implicit array-to-string |
+ | from extensions | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
- | None (yet) | + | None |
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
- | No other zval type conversion | + | No other type conversion |
===== Future Scope ===== | ===== Future Scope ===== | ||
Line 99: | Line 98: | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | Required majority | + | Basic Yes/ |
- | ===== Patches and Tests ===== | + | <doodle title=" |
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
- | Implementation is easy. | + | Voting will close March 6th, 00:00 (UTC). |
- | Patches and tests will be written as soon as we seem to agree on something. | + | Required majority : 2/3 of voters. |
+ | |||
+ | ===== Patches and Tests ===== | ||
+ | |||
+ | Patch provided, fixing existing | ||
===== Implementation ===== | ===== Implementation ===== | ||
Line 116: | Line 122: | ||
===== References ===== | ===== References ===== | ||
- | PR for comments | + | PR : https:// |
+ | |||
+ | 32 tests are broken by this change. The coresponding fixes are under way and not | ||
+ | included in the PR. | ||
===== Rejected Features ===== | ===== Rejected Features ===== |
rfc/array-to-string.1421017369.txt.gz · Last modified: 2017/09/22 13:28 (external edit)