rfc:normalize-array-auto-increment-on-copy-on-write
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:normalize-array-auto-increment-on-copy-on-write [2019/06/19 22:42] – wesnetmo | rfc:normalize-array-auto-increment-on-copy-on-write [2019/06/28 21:01] – wesnetmo | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC: Normalize | + | ====== PHP RFC: Normalize |
* Version: 0.1 | * Version: 0.1 | ||
* Date: 2019-06-19 | * Date: 2019-06-19 | ||
* Author: Wes (@WesNetmo) | * Author: Wes (@WesNetmo) | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 18: | Line 18: | ||
</ | </ | ||
- | This is currently not guaranteed, and due to PHP arrays' nature, it is not possible to | + | This is currently not guaranteed, and because of '' |
- | always enforce this property -- but it should be, at least in some dangerous cases. | + | possible to always enforce this property -- but it should be in some dangerous cases, |
+ | namely when functions from (potential) different authors are interacting. | ||
+ | |||
+ | ----- | ||
When an '' | When an '' | ||
- | due to the copy-on-write behavior, it will result in an array that is identical in any way | + | due to the copy-on-write behavior, it will result in an '' |
- | to the original one; in fact, the copy also covers the " | + | way to the original one, inclusive of its " |
<PHP> | <PHP> | ||
Line 41: | Line 44: | ||
</ | </ | ||
- | This behavior | + | |
- | receive " | + | This happens also between different |
- | but that in reality are not, because they were misused during their lifetime (for example, | + | '' |
- | it was used '' | + | reality are not, because they were misused during their lifetime (classic |
+ | used '' | ||
As result of that, despite "copy on write", | As result of that, despite "copy on write", | ||
Line 68: | Line 72: | ||
write", | write", | ||
" | " | ||
- | " | + | " |
as follows: | as follows: | ||
Line 90: | Line 94: | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | This change is not backward compatible; code relying on the next element index being | + | This change is not backward compatible; code relying on the " |
- | remembered between copies of copy-on-write will break. However, the proposed change | + | remembered between copies of copy-on-write will break. However, the proposed change should |
- | should be considered a bug-fix, rather than a behavior change. In fact, it offers | + | be considered a bug-fix, rather than a behavior change; it offers protection against |
- | protection against '' | + | '' |
- | '' | + | and thus will only affect code that is already a candidate for improvements. Furthermore, |
+ | the " | ||
+ | |||
+ | < | ||
+ | $a = [0, 1]; | ||
+ | unset($a[1]); | ||
+ | $b = $a; | ||
+ | $b[] = 2; | ||
+ | // $b is [0 => 0, 2 => 2] | ||
+ | |||
+ | $a = [0, 1]; | ||
+ | unset($a[0], | ||
+ | $b = $a; | ||
+ | $b[] = 2; | ||
+ | // $b is [0 => 2], rather than [2 => 2] | ||
+ | </ | ||
+ | |||
+ | The proposed change would make the behavior consistent and safer. | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
- | Next PHP minor version | + | 7.4 |
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
Line 104: | Line 125: | ||
Vote will require 2/3 majority | Vote will require 2/3 majority | ||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | |||
+ | ===== References | ||
+ | |||
+ | * [[https:// |
rfc/normalize-array-auto-increment-on-copy-on-write.txt · Last modified: 2019/06/28 21:13 by wesnetmo