rfc:short_list_syntax
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:short_list_syntax [2016/04/05 14:02] – ] ajf | rfc:short_list_syntax [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Square bracket syntax for array destructuring assignment ====== | ====== PHP RFC: Square bracket syntax for array destructuring assignment ====== | ||
* Version: 1.0 | * Version: 1.0 | ||
- | * Date: 2016-04-03 | + | * Date: 2016-04-07 |
* Authors: Andrea Faulds < | * Authors: Andrea Faulds < | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 72: | Line 72: | ||
This syntax is more concise, and like the < | This syntax is more concise, and like the < | ||
- | Importantly, | + | Importantly, |
<code php> | <code php> | ||
<?php | <?php | ||
- | // These two statements | + | // The two lines in each of the following pairs are equivalent |
list($a, $b, $c) = array(1, 2, 3); | list($a, $b, $c) = array(1, 2, 3); | ||
[$a, $b, $c] = [1, 2, 3]; | [$a, $b, $c] = [1, 2, 3]; | ||
- | // These two statements are also equivalent: | ||
list(" | list(" | ||
[" | [" | ||
+ | |||
+ | list($a, $b) = array($b, $a); | ||
+ | [$a, $b] = [$b, $a]; | ||
</ | </ | ||
Line 98: | Line 101: | ||
===== Details ===== | ===== Details ===== | ||
- | The < | + | The < |
<code php> | <code php> | ||
Line 118: | Line 121: | ||
// This is also not allowed: | // This is also not allowed: | ||
[list($a, $b), list($c, $d)] = [[1, 2], [3, 4]]; | [list($a, $b), list($c, $d)] = [[1, 2], [3, 4]]; | ||
+ | |||
+ | // This, however, is allowed: | ||
+ | [[$a, $b], [$c, $d]] = [[1, 2], [3, 4]]; | ||
</ | </ | ||
+ | |||
+ | Aside from this restriction, | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 136: | Line 144: | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
- | Currently, the patch permits nesting the < | + | None. |
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
- | The existing < | + | This RFC does not remove nor deprecate the existing < |
===== Future Scope ===== | ===== Future Scope ===== | ||
Line 146: | Line 154: | ||
We may wish to introduce destructuring assignment syntax for objects in future. | We may wish to introduce destructuring assignment syntax for objects in future. | ||
- | ===== Proposed Voting Choices | + | ===== Vote ===== |
Because this proposal affects the language syntax (and also therefore the specification), | Because this proposal affects the language syntax (and also therefore the specification), | ||
The vote will be a simple Yes/No vote on whether or not to accept the RFC for PHP 7.1 and merge the patch into master. | The vote will be a simple Yes/No vote on whether or not to accept the RFC for PHP 7.1 and merge the patch into master. | ||
+ | |||
+ | Voting started on 2016-04-27 and ended on 2016-05-08. | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | TODO php-src | + | There is a pull request, with tests, for the PHP interpreter ('' |
- | TODO php-langspec | + | There is not yet a patch or pull request for the language specification ('' |
===== Implementation ===== | ===== Implementation ===== | ||
+ | Merged into master for PHP 7.1: http:// | ||
+ | |||
+ | Not yet in the language specification. | ||
+ | |||
After the project is implemented, | After the project is implemented, | ||
- | - the version(s) it was merged to | ||
- | - a link to the git commit(s) | ||
- a link to the PHP manual entry for the feature | - a link to the PHP manual entry for the feature | ||
rfc/short_list_syntax.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1