~ubuntu-branches/ubuntu/trusty/php-codesniffer/trusty

« back to all changes in this revision

Viewing changes to PHP_CodeSniffer-1.0.1/CodeSniffer/Standards/Squiz/Docs/Arrays/ArrayDeclarationStandard.xml

  • Committer: Bazaar Package Importer
  • Author(s): Jan Wagner
  • Date: 2008-03-21 23:29:33 UTC
  • Revision ID: james.westby@ubuntu.com-20080321232933-za8kvi1bgvrvud6z
Tags: upstream-1.0.1
ImportĀ upstreamĀ versionĀ 1.0.1

Show diffs side-by-side

added added

removed removed

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