Skip to content

Commit

Permalink
Add the documentation for WordPress.Arrays.CommaAfterArrayItem
Browse files Browse the repository at this point in the history
  • Loading branch information
marconmartins committed Jun 20, 2019
1 parent d202e46 commit aecb113
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions WordPress/Docs/Arrays/CommaAfterArrayItemStandard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<documentation title="Comma After Array Item">
<standard>
<![CDATA[
Enforces a comma after each array item and the spacing around it.
]]>
</standard>
<code_comparison>
<code title="Valid: Items inline, comma not needed.">
<![CDATA[
$arr = <em>[</em> 'a', 'b', 'c' <em>]</em>;
]]>
</code>
<code title="Invalid: Items inline, comma not needed.">
<![CDATA[
$arr = <em>[</em> 'a', 'b', 'c', <em>]</em>;
]]>
</code>
</code_comparison>

<code_comparison>
<code title="Valid: Comma after item on their own line.">
<![CDATA[
$arr = <em>[</em>
'a',
'b',
'c',
<em>]</em>;
]]>
</code>

<code title="Invalid: Missing comma after item on their own line.">
<![CDATA[
$arr = <em>[</em>
'a',
'b',
'c'
<em>]</em>;
]]>
</code>
</code_comparison>

<code_comparison>
<code title="Valid: Comma after item on their own line (associative array).">
<![CDATA[
$arr = <em>[</em>
1 => 'value',
2 => <em>[</em> 1 <em>]</em>,
3 => 'c',
<em>]</em>;
]]>
</code>
<code title="Invalid: Missing comma after item on their own line (associative array)">
<![CDATA[
$arr = <em>[</em>
1 => 'value',
2 => <em>[</em> 1 <em>]</em>,
3 => 'c'
<em>]</em>;
]]>
</code>
</code_comparison>

<code_comparison>
<code title="Valid: No spacing before comma.">
<![CDATA[
$arr = <em>[</em>
1 => 'value',
2 => <em>[</em> 1 <em>]</em>,
3 => 'c',
<em>]</em>;
]]>
</code>
<code title="Invalid: Spacing before comma.">
<![CDATA[
$arr = <em>[</em>
1 => 'value' ,
2 => <em>[</em> 1 <em>]</em>,
3 => 'c' , /* Comment. */
<em>]</em>;
]]>
</code>
</code_comparison>

<code_comparison>
<code title="Valid: Single spacing after comma.">
<![CDATA[
$arr = <em>[</em> 'a', 'b', 'c' <em>]</em>;
]]>
</code>
<code title="Invalid: Multiple or no spacing after comma.">
<![CDATA[
$arr = <em>[</em> 'a','b', 'c' <em>]</em>;
]]>
</code>
</code_comparison>
</documentation>

0 comments on commit aecb113

Please sign in to comment.