From c35014d440cae7c7df55c38b090b55793c824021 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 30 Jan 2026 14:49:08 -0300 Subject: [PATCH] PHP: use "arrays with keys" instead of "associative arrays" This commit updates 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 for `array( 1 => 'a', 2 => 'b' )`. The sniff's current behavior makes sense, and changing it would alter what has been the practiced standard. This commit 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. --- wordpress-coding-standards/php.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress-coding-standards/php.md b/wordpress-coding-standards/php.md index 5fc2962..30f6410 100644 --- a/wordpress-coding-standards/php.md +++ b/wordpress-coding-standards/php.md @@ -263,7 +263,7 @@ Exception: if you have a block of code that would be more readable if things are [tab]$foo5 = 'somevalue4'; ``` -For associative arrays, _each item_ should start on a new line when the array contains more than one item: +For arrays with keys, _each item_ should start on a new line when the array contains more than one item: ```php $query = new WP_Query( array( 'ID' => 123 ) );