Self Member Reference

The self keyword should be used instead of the current class name, should be lowercase, and should not have spaces before or after it.

Valid: Lowercase self used.

<em>self</em>::foo();

Invalid: Uppercase self used.

<em>SELF</em>::foo();

Valid: Correct spacing used.

self<em></em>::<em></em>foo();

Invalid: Incorrect spacing used.

self<em> </em>::<em> </em>foo();

Valid: Self used as reference.

class Foo { public static function bar() { }

public static function baz() { <em>self</em>::bar(); } }

Invalid: Local class name used as reference.

class <em>Foo</em> { public static function bar() { }

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