rfc:bare_name_array_dereference

Differences

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

Link to this comparison view

rfc:bare_name_array_dereference [2014/06/22 00:15]
ajf I couldn't syntax
rfc:bare_name_array_dereference [2017/09/22 13:28]
Line 1: Line 1:
-====== PHP RFC: Bare Name Array Dereference ====== 
-  * Version: 1.0 
-  * Date: 2014-06-01 
-  * Author: Andrea Faulds <​ajf@ajf.me>​ 
-  * Status: Under Discussion 
-  * First Published at: http://​wiki.php.net/​rfc/​bare_name_array_dereference 
  
-===== Introduction ===== 
- 
-The current array dereferencing syntax for string keys is somewhat cumbersome: 
- 
-<code php> 
-$myArray['​foobar'​]['​andSoOn'​]['​moreKeys'​] 
-</​code>​ 
- 
-To dereference an array with a string key requires four characters. By contrast, dereferencing objects is much shorter, as the key name does not need to be quoted most of the time: 
- 
-<code php> 
-$myObject->​foobar->​andSoOn->​moreKeys 
-</​code>​ 
- 
-That requires just two characters. So, this RFC proposes a similar syntax for dereferencing string keys fitting the IS_STRING profile: 
- 
-<code php> 
-$myArray:>​foobar:>​andSoOn:>​moreKeys 
-</​code>​ 
- 
-The :> syntax is just my initial proposal. If there is a better (less ugly?) alternative token, please suggest it. 
- 
-This complements the [[rfc:​bare_name_array_literal|Bare Name Array Literal]] RFC, as both this proposal and that one deal with using bare T_STRING names for array keys. 
- 
-===== Proposal ===== 
- 
-Along with the existing syntax for dereferencing a key in an array, the following new syntax is added: 
- 
-    array :> T_STRING 
- 
-This functions the same as dereferencing a quoted key in square brackets. 
- 
-===== Backward Incompatible Changes ===== 
- 
-None. This has no effect on existing code. 
- 
-===== Proposed PHP Version(s) ===== 
- 
-Proposed for the next PHP 5.x, which at the time of writing, is PHP 5.7. 
- 
-===== RFC Impact ===== 
- 
-SAPIs, extensions, opcache, constants and php.ini are unaffected. No new opcodes are added, this is purely a parsing change. 
- 
-===== Open Issues ===== 
- 
-The :> syntax might not be ideal, and I'm willing to take suggestions for better syntax. 
- 
-===== Unaffected PHP Functionality ===== 
- 
-$arr:>​foobar are the same $arr['​foobar'​],​ so it is completely optional and shouldn'​t break anything. 
- 
-===== Future Scope ===== 
- 
-None I can see. 
- 
-===== Vote ===== 
- 
-A 2/3 majority as it is a language change. Voting began on 2014-06-21 (after a hiccup it was restarted) and ends 2014-06-28. 
-<doodle title="​Merge array dereference into master/PHP 5.7?" auth="​user"​ voteType="​single"​ closed="​false">​ 
-   * Yes 
-   * No 
-</​doodle>​ 
- 
-===== Patches and Tests ===== 
- 
-There is a working and tested patch implementing this here: https://​github.com/​TazeTSchnitzel/​php-src/​compare/​bareNameArrayDereference 
- 
-The branch on my GitHub account is here: https://​github.com/​TazeTSchnitzel/​php-src/​tree/​bareNameArrayDereference 
- 
-===== Implementation ===== 
- 
-If/when the RFC is implemented,​ this section should contain ​ 
-  - the version(s) it was merged to 
-  - a link to the git commit(s) 
-  - a link to the PHP manual entry for the feature 
- 
-===== References ===== 
- 
-  * http://​phpsadness.com/​sad/​45 - one of my inspirations for this 
-  * The [[rfc:​bare_name_array_literal|Bare Name Array Literal]] RFC goes hand-in-hand with this one 
-  * http://​marc.info/?​t=140164578600002&​r=1&​w=2 - mailing list discussion on this RFC (it was originally a single RFC containing both this and the literals proposal, but was split into two) 
- 
-===== Rejected Features ===== 
- 
-None as yet. 
rfc/bare_name_array_dereference.txt · Last modified: 2017/09/22 13:28 (external edit)