rfc:negative-string-offsets

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
rfc:negative-string-offsets [2016/02/01 17:17] francoisrfc:negative-string-offsets [2016/03/10 12:07] nikic
Line 1: Line 1:
 ====== PHP RFC: Generalize support of negative string offsets ====== ====== PHP RFC: Generalize support of negative string offsets ======
-  * Version: 1.2 +  * Version: 1.3 
-  * Date: 2016-02-01+  * Date: 2016-02-18
   * Author: François Laupretre <francois@php.net>   * Author: François Laupretre <francois@php.net>
-  * Status: Under discussion+  * Status: Implemented (in PHP 7.1)
   * First Published at: http://wiki.php.net/rfc/negative-string-offsets   * First Published at: http://wiki.php.net/rfc/negative-string-offsets
  
Line 55: Line 55:
 </code> </code>
  
-==== In functions ====+==== In built-in functions ====
  
 ^ Function ^ Add support for ^ ^ Function ^ Add support for ^
Line 70: Line 70:
 | mb_strpos| Negative offset | | mb_strpos| Negative offset |
 | mb_stripos| Negative offset | | mb_stripos| Negative offset |
- 
-==== In the documentation ==== 
- 
-As suggested during the discussion, authorizing the same '[]' syntax for strings and arrays is quite ambiguous, 
-especially with the addition of negative string offsets, which won't be supported on arrays. 
- 
-So, the documentation on www.php.net will be modified to recommend using the '{}' syntax when dealing with strings. This 
-will open the way for a potential future deprecation of the '[]' syntax on strings. 
  
 ==== Notes ==== ==== Notes ====
Line 113: Line 105:
 ===== Open Issues ===== ===== Open Issues =====
  
-  * Update documentation (waiting for RFC approval)+To do (waiting for RFC approval) 
 + 
 +  * Update documentation 
 +  * Update language specifications
  
 ===== Unaffected PHP Functionality ===== ===== Unaffected PHP Functionality =====
Line 121: Line 116:
 ===== Future Scope ===== ===== Future Scope =====
  
-None+==== Recommend using '{}' vs '[]' for string offsets ==== 
 + 
 +It was suggested during the discussion that, since array access and string 
 +offsets are very different operations, the official documentation should 
 +recommend using the '{}' syntax for string offsets, instead of the ambiguous 
 +'[]' syntax (and potentially deprecate '[]' for string offsets in the future). 
 + 
 +On the opposite side, it was also suggested that array access and string offsets 
 +are so closely-related concepts that we should recommend using '[]' in both 
 +cases and disable the alternate '{}' syntax for string offsets ! 
 + 
 +So, as the subject is controversial and very tangential to the subject of this RFC, 
 +it will be left for a future RFC.
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
  
 As this RFC adds support for negative string offsets in the language, it requires a 2/3 majority. As this RFC adds support for negative string offsets in the language, it requires a 2/3 majority.
 +
 +<doodle title="Generalize support of negative string offsets" auth="francois" voteType="single" closed="true">
 +   * Yes
 +   * No
 +</doodle>
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
rfc/negative-string-offsets.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1