rfc:negative_array_index

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rfc:negative_array_index [2017/09/22 13:28]
127.0.0.1 external edit
rfc:negative_array_index [2018/03/16 17:45]
pmmaga Closed vote
Line 1: Line 1:
 ====== PHP RFC: Arrays starting with a negative index ====== ====== PHP RFC: Arrays starting with a negative index ======
-  * Version: 0.3+  * Version: 0.4
   * Date: 2017-04-20   * Date: 2017-04-20
-  * Author: Pedro Magalhães, ​mail at pmmaga ​dot net +  * Author: Pedro Magalhães, pmmaga@php.net 
-  * Status: ​Under Discussion+  * Status: ​Accepted
   * First Published at: http://​wiki.php.net/​rfc/​negative_array_index   * First Published at: http://​wiki.php.net/​rfc/​negative_array_index
  
Line 16: Line 16:
  
 This RFC proposes to eliminate the parenthesis part of that sentence. Which is an exception to a rule, that people have to learn one way or the other. This RFC proposes to eliminate the parenthesis part of that sentence. Which is an exception to a rule, that people have to learn one way or the other.
 +
 +This proposal targets 8.0. However, to ease the transition and find places where this may become an issue, there is a secondary vote for emitting a deprecation notice in cases where the behavior will change.
  
 All the variables in this code: All the variables in this code:
Line 45: Line 47:
  
 <​blockquote>​ <​blockquote>​
-NOTE: During ​the deprecation phase the following ''​E_DEPRECATED''​ notice ​will be emitted in cases where the behavior will change:+NOTE: If accepted, during ​the deprecation phase the following ''​E_DEPRECATED''​ notice ​would be emitted in cases where the behavior will change:
  
 <​code>​ <​code>​
Line 71: Line 73:
 <?php <?php
  
-$a[-2] = true; +$a[-2] = true; // Current: Key is -2, RFC: Key is -2 
-$a[] = true; +$a[] = true; // Current: Key is 0, RFC: Key is -1 
-$a[] = true;+$a[] = true; // Current: Key is 1, RFC: Key is 0
  
 if ($a[1] === true) { if ($a[1] === true) {
-    echo 'Save the world.';+    echo 'Accessing key 1 explicitly';
 } }
 </​code>​ </​code>​
  
-Will no longer ​save the world.+Will no longer ​output ''​Accessing key 1 explicitly''​. 
 + 
 +<​blockquote>​ 
 +NOTE: If accepted, during the deprecation phase the ''​E_DEPRECATED''​ notice mentioned in the previous section would be emitted. 
 +</​blockquote>​
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
 PHP 8.0 PHP 8.0
 +(Deprecation notice for 7.3)
  
 ===== Unaffected PHP Functionality ===== ===== Unaffected PHP Functionality =====
-Arrays with explicit keys, string keys, or an initial numeric index ''>​= ​0''​ are not affected. This also means that arrays that never use explicit keys will still start with ''​0''​.+Arrays with explicit keys, string keys, or an initial numeric index ''>​= ​-1''​ are not affected. This also means that arrays that never use explicit keys will still start with ''​0''​.
  
 Furthermore,​ iterating over arrays without explicit keys (ie. ''​foreach''​) is not affected. Furthermore,​ iterating over arrays without explicit keys (ie. ''​foreach''​) is not affected.
  
 ===== Voting Choices ===== ===== Voting Choices =====
-This RFC requires ​a 2/3 majority.+Both votes require ​a 2/3 majority.
  
-<del>​Voting opened on 13/6/2017 19:00 UTC and will close on 28/6/2017 19:00 UTC.</del+<doodle title="​Arrays starting with a negative index for 8.0" auth="​pmmaga"​ voteType="​single"​ closed="​true"​
-<​blockquote>​Voting suspended pending discussion on the deprecation notice</blockquote>+   * Yes 
 +   * No 
 +</doodle> 
 + 
 +----
  
-<doodle title="​Arrays starting with a negative index for PHP 8.0" auth="​pmmaga"​ voteType="​single"​ closed="​true">​+<doodle title="​Deprecation notice ​for 7.3" auth="​pmmaga"​ voteType="​single"​ closed="​true">​
    * Yes    * Yes
    * No    * No
Line 109: Line 120:
  
 ===== References ===== ===== References =====
-Discussion on the mailing list: https://​externals.io/​thread/712+Version 0.3: 
 + 
 +Discussion on the mailing list: https://​externals.io/​message/​98302 
 + 
 +First proposal Voting period discussion: https://​externals.io/​message/​99412 
 + 
 +Second proposal Voting period discussion: https://​externals.io/​message/99511
  
-First proposal Voting period discussionhttps://​externals.io/​thread/​928+---- 
 +Version 0.4:
  
 +Discussion on the mailing list: https://​externals.io/​message/​101861
rfc/negative_array_index.txt · Last modified: 2018/03/16 17:45 by pmmaga