You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Case statements should be indented 4 spaces from the switch keyword. It should also be followed by a space. Colons in switch declarations should not be preceded by whitespace. Break statements should be indented 4 more spaces from the case statement. There must be a comment when falling through from one case into the next.
4
+
Case and default keywords must be lowercase.
5
5
]]>
6
6
</standard>
7
7
<code_comparison>
8
-
<codetitle="Valid: Case statement indented correctly.">
8
+
<codetitle="Valid: Keywords in lowercase.">
9
9
<![CDATA[
10
10
switch ($foo) {
11
-
<em> </em>case 'bar':
11
+
<em>case</em> 'bar':
12
+
break;
13
+
<em>default</em>:
12
14
break;
13
15
}
14
16
]]>
15
17
</code>
16
-
<codetitle="Invalid: Case statement not indented 4 spaces.">
18
+
<codetitle="Invalid: Keywords not in lowercase.">
17
19
<![CDATA[
18
20
switch ($foo) {
19
-
<em></em>case 'bar':
20
-
break;
21
+
<em>CASE</em> 'bar':
22
+
break;
23
+
<em>Default</em>:
24
+
break;
21
25
}
22
26
]]>
23
27
</code>
24
28
</code_comparison>
29
+
<standard>
30
+
<![CDATA[
31
+
Case statements must be followed by exactly one space.
32
+
]]>
33
+
</standard>
25
34
<code_comparison>
26
-
<codetitle="Valid: Case statement followed by 1 space.">
35
+
<codetitle="Valid: Case statement followed by one space.">
27
36
<![CDATA[
28
37
switch ($foo) {
29
38
case<em> </em>'bar':
30
39
break;
31
40
}
32
41
]]>
33
42
</code>
34
-
<codetitle="Invalid: Case statement not followed by 1 space.">
43
+
<codetitle="Invalid: Case statement not followed by one space.">
35
44
<![CDATA[
36
45
switch ($foo) {
37
46
case<em></em>'bar':
@@ -40,8 +49,13 @@ switch ($foo) {
40
49
]]>
41
50
</code>
42
51
</code_comparison>
52
+
<standard>
53
+
<![CDATA[
54
+
There must be no whitespace between the case value or default keyword and the colon.
55
+
]]>
56
+
</standard>
43
57
<code_comparison>
44
-
<codetitle="Valid: Colons not prefixed by whitespace.">
58
+
<codetitle="Valid: Colons not preceded by whitespace.">
45
59
<![CDATA[
46
60
switch ($foo) {
47
61
case 'bar'<em></em>:
@@ -51,7 +65,7 @@ switch ($foo) {
51
65
}
52
66
]]>
53
67
</code>
54
-
<codetitle="Invalid: Colons prefixed by whitespace.">
68
+
<codetitle="Invalid: Colons preceded by whitespace.">
55
69
<![CDATA[
56
70
switch ($foo) {
57
71
case 'bar'<em> </em>:
@@ -62,6 +76,57 @@ switch ($foo) {
62
76
]]>
63
77
</code>
64
78
</code_comparison>
79
+
<standard>
80
+
<![CDATA[
81
+
The case or default body must start on the line following the statement.
82
+
]]>
83
+
</standard>
84
+
<code_comparison>
85
+
<codetitle="Valid: Body starts on the next line.">
86
+
<![CDATA[
87
+
switch ($foo) {
88
+
case 'bar':
89
+
<em></em> break;
90
+
}
91
+
]]>
92
+
</code>
93
+
<codetitle="Invalid: Body on the same line as the case statement.">
94
+
<![CDATA[
95
+
switch ($foo) {
96
+
case 'bar':<em></em> break;
97
+
}
98
+
]]>
99
+
</code>
100
+
</code_comparison>
101
+
<standard>
102
+
<![CDATA[
103
+
Terminating statements must be on a line by themselves.
104
+
]]>
105
+
</standard>
106
+
<code_comparison>
107
+
<codetitle="Valid: Terminating statement on its own line.">
108
+
<![CDATA[
109
+
switch ($foo) {
110
+
case 'bar':
111
+
echo $foo;
112
+
<em>return;</em>
113
+
}
114
+
]]>
115
+
</code>
116
+
<codetitle="Invalid: Terminating statement not on its own line.">
117
+
<![CDATA[
118
+
switch ($foo) {
119
+
case 'bar':
120
+
<em>echo $foo; return;</em>
121
+
}
122
+
]]>
123
+
</code>
124
+
</code_comparison>
125
+
<standard>
126
+
<![CDATA[
127
+
Terminating statements must be indented four more spaces from the case statement.
0 commit comments