Skip to content

Commit cb8c2c4

Browse files
committed
[Doc] Cover all errors of PEAR ClassDeclaration
While reviewing PR PHPCSStandards#844 for the Squiz version of this sniff, jrfnl discovered that the PEAR sniff's documentation did not cover all error conditions. This adds code examples for all missing errors that should be caught by this sniff.
1 parent 894bf72 commit cb8c2c4

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

src/Standards/PEAR/Docs/Classes/ClassDeclarationStandard.xml

+74
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,78 @@ class Foo <em>{</em>
1919
]]>
2020
</code>
2121
</code_comparison>
22+
<code_comparison>
23+
<code title="Valid: Opening brace on the correct line.">
24+
<![CDATA[
25+
class Foo
26+
<em>{</em>
27+
}
28+
]]>
29+
</code>
30+
<code title="Invalid: Newline between declaration and opening brace.">
31+
<![CDATA[
32+
class Foo
33+
<em></em>
34+
{
35+
}
36+
]]>
37+
</code>
38+
</code_comparison>
39+
<code_comparison>
40+
<code title="Valid: Opening brace is on a line by itself.">
41+
<![CDATA[
42+
class Foo
43+
<em>{</em>
44+
}
45+
]]>
46+
</code>
47+
<code title="Invalid: Opening brace is not alone on its line.">
48+
<![CDATA[
49+
class Foo
50+
{<em> public function __construct() {}</em>
51+
}
52+
]]>
53+
</code>
54+
</code_comparison>
55+
<standard>
56+
<![CDATA[
57+
The opening brace must be indented to the same depth as the class declaration.
58+
]]>
59+
</standard>
60+
<code_comparison>
61+
<code title="Valid: Opening brace indentation depth matches the class definition.">
62+
<![CDATA[
63+
if (!class_exists('Foo')) {
64+
abstract class Foo
65+
<em>{</em>
66+
}
67+
}
68+
]]>
69+
</code>
70+
<code title="Invalid: Expected 4 spaces before opening brace; 0 found.">
71+
<![CDATA[
72+
if (!class_exists('Foo')) {
73+
abstract class Foo
74+
<em>{</em>
75+
}
76+
}
77+
]]>
78+
</code>
79+
</code_comparison>
80+
<code_comparison>
81+
<code title="Valid: Opening brace indentation depth matches the class definition.">
82+
<![CDATA[
83+
class Foo
84+
<em>{</em>
85+
}
86+
]]>
87+
</code>
88+
<code title="Invalid: Expected 0 spaces before opening brace; 4 found.">
89+
<![CDATA[
90+
class Foo
91+
<em>{</em>
92+
}
93+
]]>
94+
</code>
95+
</code_comparison>
2296
</documentation>

0 commit comments

Comments
 (0)