Array Indentation

The array closing bracket indentation should line up with the start of the content on the line containing the array opener.

Valid: Closing bracket lined up correctly

$args = array( 'post_id' => 22, <em>);</em>

Invalid: Closing bracket lined up incorrectly

$args = array( 'post_id' => 22, <em>);</em>
In multi-line arrays, array items should be indented by a 4-space tab for each level of nested array, so that the array visually matches its structure.

Valid: Correctly indented array

$args = array( 'post_id' => 22, 'comment_count' => array( <em>'value' => 25, 'compare' => '>=',</em> ), 'post_type' => array( 'post', 'page', ), );

Invalid: Indented incorrectly; harder to read.

$args = array( 'post_id' => 22, 'comment_count' => array( <em>'value' => 25, 'compare' => '>=',</em> ), 'post_type' => array( <em>'post', 'page',</em> ), );
Subsequent lines in multiline array items should be indented at least as much as the first line of the array item. For heredocs/nowdocs, this does not apply to the content of the heredoc/nowdoc or the closer, but it does apply to the comma separating the item from the next.

Valid: Subsequent lines are indented correctly.

$args = array( 'phrase' => 'start of phrase' . 'concatented additional phrase' . 'more text', );

Invalid: Subsequent items are indented before the first line item.

$args = array( 'phrase' => 'start of phrase' . 'concatented additional phrase' . 'more text', );

Valid: Opener and comma after closer are indented correctly

$text = array( <<<EOD start of phrase concatented additional phrase more text EOD , );

Invalid: Opener is aligned incorrectly to match the closer. The comma does not align correctly with the array indentation.

$text = array( <em><<<EOD</em> start of phrase concatented additional phrase more text EOD <em>,</em> );