Skip to content

Commit eefd218

Browse files
RafaelFunchalmattgaldinorodrigoprimojrfnl
committed
Adding documentation for WordPress.Arrays.ArrayDeclarationSpacing
Co-authored-by: RafaelFunchal <RafaelFunchal@users.noreply.github.com> Co-authored-by: mattgaldino <mattgaldino@users.noreply.github.com> Co-authored-by: Rodrigo Primo <rodrigoprimo@users.noreply.github.com> Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com>
1 parent f48a181 commit eefd218

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0"?>
2+
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
4+
title="Array Declaration Spacing"
5+
>
6+
<standard>
7+
<![CDATA[
8+
Multi-item arrays with explicit keys must be declared as multi-line arrays.
9+
]]>
10+
</standard>
11+
<code_comparison>
12+
<code title="Valid: Multi-item array with explicit keys declared as multi-line.">
13+
<![CDATA[
14+
$args = array(
15+
<em>'cat' => 1</em>,
16+
<em>'paged' => 2</em>,
17+
);
18+
]]>
19+
</code>
20+
<code title="Invalid: Single line multi-item array with explicit keys.">
21+
<![CDATA[
22+
$args = array( <em>'cat' => 1, 'paged' => 2</em> );
23+
]]>
24+
</code>
25+
</code_comparison>
26+
<standard>
27+
<![CDATA[
28+
Each item in a multi-line array must be on a new line.
29+
]]>
30+
</standard>
31+
<code_comparison>
32+
<code title="Valid: Only one array item per line.">
33+
<![CDATA[
34+
$post_types = array(
35+
<em>'post'</em>,
36+
<em>'page'</em>,
37+
);
38+
39+
$args = array(
40+
<em>'cat' => 1</em>,
41+
<em>'paged' => 2</em>,
42+
);
43+
]]>
44+
</code>
45+
<code title="Invalid: More than one item per line in a multi-line array.">
46+
<![CDATA[
47+
$post_types = array(
48+
<em>'post', 'page'</em>,
49+
);
50+
51+
52+
$args = array(
53+
<em>'cat' => 1, 'paged' => 2</em>,
54+
);
55+
]]>
56+
</code>
57+
</code_comparison>
58+
</documentation>

0 commit comments

Comments
 (0)