rfc:deprecate_curly_braces_array_access
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:deprecate_curly_braces_array_access [2019/07/02 17:17] – Improve RFC introduction and discussion sections theodorejb | rfc:deprecate_curly_braces_array_access [2019/07/19 15:30] – Add link to voting discussion thread theodorejb | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Deprecate curly brace syntax for accessing array elements and string offsets ====== | ====== PHP RFC: Deprecate curly brace syntax for accessing array elements and string offsets ====== | ||
* Date: 2019-03-12 | * Date: 2019-03-12 | ||
- | * Author: Andrey Gromov < | + | * Author: Andrey Gromov < |
- | * Status: | + | * Status: |
* Discussion: https:// | * Discussion: https:// | ||
* Target version: PHP 7.4 | * Target version: PHP 7.4 | ||
- | * Implementation: | + | * Implementation: |
===== Introduction ===== | ===== Introduction ===== | ||
Line 54: | Line 54: | ||
{$one, $two} = $array; // Parse error: syntax error, unexpected ',' | {$one, $two} = $array; // Parse error: syntax error, unexpected ',' | ||
</ | </ | ||
- | |||
- | Finally, supporting the curly brace syntax prevents using this syntax | ||
- | for more valuable features in the future (e.g. array/ | ||
- | offset access, " | ||
Line 71: | Line 67: | ||
< | < | ||
- | Warning: Array and string offset access syntax with curly braces is deprecated in test.php | + | Deprecated: Array and string offset access syntax with curly braces is deprecated in test.php line 3 |
int(2) | int(2) | ||
</ | </ | ||
Line 95: | Line 91: | ||
should be used instead of relying on syntax that can be used for both strings | should be used instead of relying on syntax that can be used for both strings | ||
and arrays (and thus doesn' | and arrays (and thus doesn' | ||
+ | |||
+ | |||
+ | ==== How frequently is the curly brace syntax used? ==== | ||
+ | Nikita Popov checked the top 2k Composer packages, and found ~2.2k | ||
+ | individual uses of the curly brace array syntax. Compared to the 888.3k | ||
+ | total array accesses in the data set, usage of the alternative syntax is | ||
+ | about 0.25%. However, even this number is inflated somewhat due to | ||
+ | duplicate packages (for example, there are two packages that mirror the | ||
+ | WordPress Core repository, each with 182 usages). 92% of usages in the | ||
+ | top 2k packages are in just 25 unique projects. | ||
==== Will it be too much work for people to migrate code away from the curly brace syntax? ==== | ==== Will it be too much work for people to migrate code away from the curly brace syntax? ==== | ||
A migration script has been implemented alongside the deprecation patch: | A migration script has been implemented alongside the deprecation patch: | ||
- | https:// | + | https://gist.github.com/theodorejb/763b83a43522b0fc1755a537663b1863 |
Line 107: | Line 113: | ||
===== Vote ===== | ===== Vote ===== | ||
- | Deprecate curly brace array and string offset syntax in PHP 7.4? Yes/No. | + | Started 3 July 2019. Ends 17th July 2019 |
+ | <doodle title=" | ||
+ | | ||
+ | | ||
+ | </ | ||
===== Future Scope ===== | ===== Future Scope ===== | ||
Remove the feature entirely (replacing the deprecation warning | Remove the feature entirely (replacing the deprecation warning | ||
with a compiler error) in PHP 8 or another future release. | with a compiler error) in PHP 8 or another future release. | ||
- | |||
===== References ===== | ===== References ===== | ||
+ | Current discussion: https:// | ||
+ | |||
Discussion about deprecation in June 2008: https:// | Discussion about deprecation in June 2008: https:// | ||
Discussion about deprecation in November 2005: https:// | Discussion about deprecation in November 2005: https:// | ||
rfc/deprecate_curly_braces_array_access.txt · Last modified: 2019/08/10 23:19 by derick