PHP: use "arrays with keys" instead of "associative arrays" #156
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed with @jrfnl, I'm opening this PR to update the multi-line array formatting rule in the "Indentation" section, replacing "associative arrays" with "arrays with keys".
The related WPCS sniff (
WordPress.Arrays.ArrayDeclarationSpacing) has checked for arrays with explicit keys, whether string or numeric, since it was introduced. The term "associative arrays" implies string keys only, which doesn't match the actual behavior of the sniff.The handbook is being updated rather than the sniff because there is no reason to enforce this rule for an array like
array( '1' => 'a', '2' => 'b' )but not forarray( 1 => 'a', 2 => 'b' ). The sniff's current behavior makes sense, and changing it would alter what has been the practiced standard.This PR aligns the handbook with what is enforced by the sniff.
I checked the history of this repository, and the term "associative arrays" was already present when the handbook pages were initially imported here.
Additional context
Originally discussed in WordPress/WordPress-Coding-Standards#2489 (comment) and WordPress/WordPress-Coding-Standards#2682 (review).
Both @jrfnl and myself belive this change doesn't require a Make post, quoting her (WordPress/WordPress-Coding-Standards#2682 (review)):