1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
<documentation title="Array Declarations">
<standard>
<![CDATA[
This standard covers all array declarations, regardless of the number and type of values contained within the array.
]]>
</standard>
<standard>
<![CDATA[
The <em>array</em> keyword must be lowercase.
]]>
</standard>
<code_comparison>
<code title="Valid: array keyword lowercase">
<![CDATA[
$array = <em>a</em>rray('val1', 'val2');
]]>
</code>
<code title="Invalid: first letter capitialised">
<![CDATA[
$array = <em>A</em>rray('val1', 'val2');
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
The first array key must begin on the line after the <em>array</em> keyword.
]]>
</standard>
<code_comparison>
<code title="Valid: first key on second line">
<![CDATA[
$array = array(
<em>'key1'</em> => 'value1',
'key2' => 'value2',
);
]]>
</code>
<code title="Invalid: first key on same line">
<![CDATA[
$array = array(<em>'key1'</em> => 'value1',
'key2' => 'value2',
);
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
All array keys must be indented to one space after the start of the <em>array</em> keyword. The closing parenthesis must be aligned with the start of the <em>array</em> keyword.
]]>
</standard>
<code_comparison>
<code title="Valid: aligned correctly">
<![CDATA[
$array = array(
<em> </em>'key1' => 'value1',
<em> </em>'key2' => 'value2',
);
]]>
</code>
<code title="Invalid: keys and parenthesis aligned incorrectly">
<![CDATA[
$array = array(
<em>'</em>key1' => 'value1',
<em>'</em>key2' => 'value2',
);
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
All double arrow symbols must be aligned to one space after the longest array key. Alignment must be achieved using spaces.
]]>
</standard>
<code_comparison>
<code title="Valid: keys and values aligned">
<![CDATA[
$array = array(
'keyTen'<em> </em>=> 'ValueTen',
'keyTwenty'<em> </em>=> 'ValueTwenty',
);
]]>
</code>
<code title="Invalid: alignment incorrect">
<![CDATA[
$array = array(
'keyTen'<em> </em>=> 'ValueTen',
'keyTwenty'<em> </em>=> 'ValueTwenty',
);
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
All array values must be followed by a comma, including the final value.
]]>
</standard>
<code_comparison>
<code title="Valid: comma after each value">
<![CDATA[
$array = array(
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3'<em>,</em>
);
]]>
</code>
<code title="Invalid: no comma after last value">
<![CDATA[
$array = array(
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3'<em> </em>
);
]]>
</code>
</code_comparison>
</documentation>
|