Skip to content

Commit d85e5b4

Browse files
committed
PSR2/SwitchDeclaration: improve XML documentation
- Documentation title should match the sniff name. - Use different `<standard>` blocks for each error triggered by the sniff. - Minor changes to the text to make it more clear and consistent.
1 parent 2f3cfcb commit d85e5b4

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

src/Standards/PSR2/Docs/ControlStructures/SwitchDeclarationStandard.xml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
<documentation title="Switch Declarations">
1+
<documentation title="Switch Declaration">
22
<standard>
33
<![CDATA[
4-
Case statements should 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 statements must be followed by exactly one space.
55
]]>
66
</standard>
77
<code_comparison>
8-
<code title="Valid: Case statement followed by 1 space.">
8+
<code title="Valid: Case statement followed by one space.">
99
<![CDATA[
1010
switch ($foo) {
1111
case<em> </em>'bar':
1212
break;
1313
}
1414
]]>
1515
</code>
16-
<code title="Invalid: Case statement not followed by 1 space.">
16+
<code title="Invalid: Case statement not followed by one space.">
1717
<![CDATA[
1818
switch ($foo) {
1919
case<em></em>'bar':
@@ -22,8 +22,13 @@ switch ($foo) {
2222
]]>
2323
</code>
2424
</code_comparison>
25+
<standard>
26+
<![CDATA[
27+
There must be no whitespace between the case value or default keyword and the colon.
28+
]]>
29+
</standard>
2530
<code_comparison>
26-
<code title="Valid: Colons not prefixed by whitespace.">
31+
<code title="Valid: Colons not preceded by whitespace.">
2732
<![CDATA[
2833
switch ($foo) {
2934
case 'bar'<em></em>:
@@ -33,7 +38,7 @@ switch ($foo) {
3338
}
3439
]]>
3540
</code>
36-
<code title="Invalid: Colons prefixed by whitespace.">
41+
<code title="Invalid: Colons preceded by whitespace.">
3742
<![CDATA[
3843
switch ($foo) {
3944
case 'bar'<em> </em>:
@@ -44,6 +49,11 @@ switch ($foo) {
4449
]]>
4550
</code>
4651
</code_comparison>
52+
<standard>
53+
<![CDATA[
54+
Terminating statements must be indented four more spaces from the case statement.
55+
]]>
56+
</standard>
4757
<code_comparison>
4858
<code title="Valid: Break statement indented correctly.">
4959
<![CDATA[
@@ -53,7 +63,7 @@ switch ($foo) {
5363
}
5464
]]>
5565
</code>
56-
<code title="Invalid: Break statement not indented 4 spaces.">
66+
<code title="Invalid: Break statement not indented four spaces.">
5767
<![CDATA[
5868
switch ($foo) {
5969
case 'bar':
@@ -62,8 +72,13 @@ switch ($foo) {
6272
]]>
6373
</code>
6474
</code_comparison>
75+
<standard>
76+
<![CDATA[
77+
There must be a comment when fall-through is intentional in a non-empty case body.
78+
]]>
79+
</standard>
6580
<code_comparison>
66-
<code title="Valid: Comment marking intentional fall-through.">
81+
<code title="Valid: Comment marking intentional fall-through in a non-empty case body.">
6782
<![CDATA[
6883
switch ($foo) {
6984
case 'bar':
@@ -74,7 +89,7 @@ switch ($foo) {
7489
}
7590
]]>
7691
</code>
77-
<code title="Invalid: No comment marking intentional fall-through.">
92+
<code title="Invalid: No comment marking intentional fall-through in a non-empty case body.">
7893
<![CDATA[
7994
switch ($foo) {
8095
case 'bar':

0 commit comments

Comments
 (0)