Skip to content

Commit 674ff89

Browse files
committed
Apply suggestions from code review and use variable and key names commom
in the WP ecosystem
1 parent 1c714ef commit 674ff89

1 file changed

Lines changed: 19 additions & 36 deletions

File tree

WordPress/Docs/Arrays/ArrayDeclarationSpacingStandard.xml

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@
55
>
66
<standard>
77
<![CDATA[
8-
When an array uses keys, each key/value pair must start on a new line.
8+
When a multi-item array uses keys, each key/value pair must start on a new line.
99
]]>
1010
</standard>
1111
<code_comparison>
12-
<code title="Valid: There is only one key/value pair per line.">
12+
<code title="Valid: Only one key/value pair per line on a multi-item array.">
1313
<![CDATA[
1414
$args = array(
15-
<em>'post_id' => 22</em>,
16-
<em>'category' => 1</em>,
15+
<em>'cat' => 1</em>,
16+
<em>'paged' => 2</em>,
1717
);
1818
]]>
1919
</code>
20-
<code title="Invalid: More than one key/value pair per line.">
20+
<code title="Invalid: Single line multi-item array using keys.">
2121
<![CDATA[
22-
$args = array(
23-
<em>'post_id' => 22, 'category' => 1</em>,
24-
);
22+
$args = array( <em>'cat' => 1, 'paged' => 2</em> );
2523
]]>
2624
</code>
2725
</code_comparison>
@@ -33,41 +31,26 @@ $args = array(
3331
<code_comparison>
3432
<code title="Valid: Only one array item per line.">
3533
<![CDATA[
36-
$args = array(
37-
<em>'post_id'</em>,
38-
<em>'comment_count'</em>,
39-
<em>'post_type'</em>,
34+
$post_types = array(
35+
<em>'post'</em>,
36+
<em>'page'</em>,
4037
);
41-
]]>
42-
</code>
43-
<code title="Invalid: More than one item per line in a multi-line array.">
44-
<![CDATA[
38+
4539
$args = array(
46-
<em>'post_id', 'comment_count', 'post_type'</em>,
40+
<em>'cat' => 1</em>,
41+
<em>'paged' => 2</em>,
4742
);
4843
]]>
4944
</code>
50-
</code_comparison>
51-
<standard>
52-
<![CDATA[
53-
Associative arrays with multiple key-value pairs must also follow this rule.
54-
]]>
55-
</standard>
56-
<code_comparison>
57-
<code title="Valid: Each key-value pair on its own line.">
45+
<code title="Invalid: More than one item per line in a multi-line array.">
5846
<![CDATA[
59-
$settings = array(
60-
<em>'width' => 300</em>,
61-
<em>'height' => 200</em>,
62-
<em>'color' => 'blue'</em>,
47+
$post_types = array(
48+
<em>'post', 'page'</em>,
6349
);
64-
]]>
65-
</code>
66-
<code title="Invalid: Multiple key-value pairs on the same line in a multi-line array.">
67-
<![CDATA[
68-
$settings = array(
69-
<em>'width' => 300, 'height' => 200</em>,
70-
<em>'color' => 'blue'</em>,
50+
51+
52+
$args = array(
53+
<em>'cat' => 1, 'paged' => 2</em>,
7154
);
7255
]]>
7356
</code>

0 commit comments

Comments
 (0)