Skip to content

Squiz/SelfMemberReference: update XML doc #1108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 39 additions & 21 deletions src/Standards/Squiz/Docs/Classes/SelfMemberReferenceStandard.xml
Original file line number Diff line number Diff line change
@@ -1,59 +1,77 @@
<documentation title="Self Member Reference">
<standard>
<![CDATA[
The self keyword should be used instead of the current class name, should be lowercase, and should not have spaces before or after it.
The self keyword must be lowercase.
]]>
</standard>
<code_comparison>
<code title="Valid: Lowercase self used.">
<![CDATA[
<em>self</em>::foo();
class Bar {
public function baz() {
<em>self</em>::foo();
}
}
]]>
</code>
<code title="Invalid: Uppercase self used.">
<![CDATA[
<em>SELF</em>::foo();
class Bar {
public function baz() {
<em>SELF</em>::foo();
}
}
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
There must be no spaces before or after the double colon operator.
]]>
</standard>
<code_comparison>
<code title="Valid: Correct spacing used.">
<code title="Valid: No spaces around the double colon operator.">
<![CDATA[
self<em></em>::<em></em>foo();
class Bar {
public function baz() {
self<em></em>::<em></em>foo();
}
}
]]>
</code>
<code title="Invalid: Incorrect spacing used.">
<code title="Invalid: Spaces around double colon operator.">
<![CDATA[
self<em> </em>::<em> </em>foo();
class Bar {
public function baz() {
self<em> </em>::<em> </em>foo();
}
}
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
The self keyword must be used instead of the current class name.
]]>
</standard>
<code_comparison>
<code title="Valid: Self used as reference.">
<![CDATA[
class Foo
{
public static function bar()
{
}
class Foo {
public function bar() {}

public static function baz()
{
public function baz() {
<em>self</em>::bar();
}
}
]]>
</code>
<code title="Invalid: Local class name used as reference.">
<![CDATA[
class <em>Foo</em>
{
public static function bar()
{
}
class <em>Foo</em> {
public function bar() {}

public static function baz()
{
public function baz() {
<em>Foo</em>::bar();
}
}
Expand Down