Skip to content

Commit 7af44a3

Browse files
authored
Squiz/SelfMemberReference: update XML doc (#1108)
- Improve sniff description explicitly mentioning where the spaces are checked and adding context as to when the `self` keyword is verified. - Fix the code examples for checking `self` case and spaces around the double colon to ensure they trigger the sniff (the sniff checks if the call is made within a class). - Improve the titles of the code examples related to spacing around double colons. - Remove unnecessary methods from the code examples related to using `self` instead of the class name when referencing a static member.
1 parent 3a9a4b2 commit 7af44a3

File tree

1 file changed

+39
-21
lines changed

1 file changed

+39
-21
lines changed

src/Standards/Squiz/Docs/Classes/SelfMemberReferenceStandard.xml

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,77 @@
11
<documentation title="Self Member Reference">
22
<standard>
33
<![CDATA[
4-
The self keyword should be used instead of the current class name, should be lowercase, and should not have spaces before or after it.
4+
The self keyword must be lowercase.
55
]]>
66
</standard>
77
<code_comparison>
88
<code title="Valid: Lowercase self used.">
99
<![CDATA[
10-
<em>self</em>::foo();
10+
class Bar {
11+
public function baz() {
12+
<em>self</em>::foo();
13+
}
14+
}
1115
]]>
1216
</code>
1317
<code title="Invalid: Uppercase self used.">
1418
<![CDATA[
15-
<em>SELF</em>::foo();
19+
class Bar {
20+
public function baz() {
21+
<em>SELF</em>::foo();
22+
}
23+
}
1624
]]>
1725
</code>
1826
</code_comparison>
27+
<standard>
28+
<![CDATA[
29+
There must be no spaces before or after the double colon operator.
30+
]]>
31+
</standard>
1932
<code_comparison>
20-
<code title="Valid: Correct spacing used.">
33+
<code title="Valid: No spaces around the double colon operator.">
2134
<![CDATA[
22-
self<em></em>::<em></em>foo();
35+
class Bar {
36+
public function baz() {
37+
self<em></em>::<em></em>foo();
38+
}
39+
}
2340
]]>
2441
</code>
25-
<code title="Invalid: Incorrect spacing used.">
42+
<code title="Invalid: Spaces around double colon operator.">
2643
<![CDATA[
27-
self<em> </em>::<em> </em>foo();
44+
class Bar {
45+
public function baz() {
46+
self<em> </em>::<em> </em>foo();
47+
}
48+
}
2849
]]>
2950
</code>
3051
</code_comparison>
52+
<standard>
53+
<![CDATA[
54+
The self keyword must be used instead of the current class name.
55+
]]>
56+
</standard>
3157
<code_comparison>
3258
<code title="Valid: Self used as reference.">
3359
<![CDATA[
34-
class Foo
35-
{
36-
public static function bar()
37-
{
38-
}
60+
class Foo {
61+
public function bar() {}
3962
40-
public static function baz()
41-
{
63+
public function baz() {
4264
<em>self</em>::bar();
4365
}
4466
}
4567
]]>
4668
</code>
4769
<code title="Invalid: Local class name used as reference.">
4870
<![CDATA[
49-
class <em>Foo</em>
50-
{
51-
public static function bar()
52-
{
53-
}
71+
class <em>Foo</em> {
72+
public function bar() {}
5473
55-
public static function baz()
56-
{
74+
public function baz() {
5775
<em>Foo</em>::bar();
5876
}
5977
}

0 commit comments

Comments
 (0)