Array Declaration must be short array syntax
mbniebergall opened this issue · 5 comments
Currently all of the PSR/PER code examples show using PHP short array syntax $thing = [];
. PRs (ex: #18) also use short array syntax $arr = ['a' => 'A', 'b' => 'B', 'c' => 'C'];
. There is no rule though requiring short array syntax.
The short array syntax was adopted for good reasons. According to the RFC:
- Good for framework development when dealing with long parameterlists
- Other web languages have similar syntax
- Readable
Scouring Github repositories, PHP short array syntax is very prevalent in popular PHP frameworks. Using the old syntax $thing = array(...);
is relatively rare. Most occurrences are in old repositories or in conversion from old to short syntax tools.
Would creating a PR for adding a MUST use short array syntax section be welcomed?
I think that makes sense.
PR opened for this #47
#48 is better. For arrays need several rules and use separate section it's OK for me.
#48 has merged