<?xml version="1.0"?>
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
    title="Array Indentation"
    >
    <standard>
    <![CDATA[
    The array closing bracket indentation should line up with the start of the content on the line containing the array opener.
    ]]>
    </standard>
    <code_comparison>
        <code title="Valid: Closing bracket lined up correctly.">
        <![CDATA[
$args = array(
    'post_id' => 22,
<em>);</em>
        ]]>
        </code>
        <code title="Invalid: Closing bracket lined up incorrectly.">
        <![CDATA[
$args = array(
    'post_id' => 22,
        <em>);</em>
        ]]>
        </code>
    </code_comparison>
    <standard>
    <![CDATA[
    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.
    ]]>
    </standard>
    <code_comparison>
        <code title="Valid: Correctly indented array.">
        <![CDATA[
$args = array(
    'post_id'       => 22,
    'comment_count' => array(
        <em>'value'   => 25,
        'compare' => '>=',</em>
    ),
    'post_type' => array(
        'post',
        'page',
    ),
);
        ]]>
        </code>
        <code title="Invalid: Indented incorrectly; harder to read.">
        <![CDATA[
$args = array(
    'post_id'       => 22,
    'comment_count' => array(
    <em>'value'   => 25,
    'compare' => '>=',</em>
    ),
    'post_type' => array(
    <em>'post',
    'page',</em>
    ),
);
        ]]>
        </code>
    </code_comparison>
    <standard>
    <![CDATA[
    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.
    ]]>
    </standard>
    <code_comparison>
        <code title="Valid: Subsequent lines are indented correctly.">
        <![CDATA[
$args = array(
    'phrase' => 'start of phrase'
        . 'concatenated additional phrase'
        . 'more text',
);
        ]]>
        </code>
        <code title="Invalid: Subsequent items are indented before the first line item.">
        <![CDATA[
$args = array(
    'phrase' => 'start of phrase'
. 'concatenated additional phrase'
. 'more text',
);
        ]]>
        </code>
    </code_comparison>
    <code_comparison>
        <code title="Valid: Opener and comma after closer are indented correctly.">
        <![CDATA[
$text = array(
    <<<EOD
    start of phrase
    concatenated additional phrase
    more text
EOD
    ,
);
        ]]>
        </code>
        <code title="Invalid: Opener is aligned incorrectly to match the closer. The comma does not align correctly with the array indentation.">
        <![CDATA[
$text = array(
<em><<<EOD</em>
    start of phrase
    concatenated additional phrase
    more text
EOD
<em>,</em>
);
        ]]>
        </code>
    </code_comparison>
</documentation>
