1<documentation title="Self Member Reference"> 2 <standard> 3 <![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. 5 ]]> 6 </standard> 7 <code_comparison> 8 <code title="Valid: Lowercase self used."> 9 <![CDATA[ 10<em>self</em>::foo(); 11]]> 12 </code> 13 <code title="Invalid: Uppercase self used."> 14 <![CDATA[ 15<em>SELF</em>::foo(); 16]]> 17 </code> 18 </code_comparison> 19 <code_comparison> 20 <code title="Valid: Correct spacing used."> 21 <![CDATA[ 22self<em></em>::<em></em>foo(); 23]]> 24 </code> 25 <code title="Invalid: Incorrect spacing used."> 26 <![CDATA[ 27self<em> </em>::<em> </em>foo(); 28]]> 29 </code> 30 </code_comparison> 31 <code_comparison> 32 <code title="Valid: Self used as reference."> 33 <![CDATA[ 34class Foo 35{ 36 public static function bar() 37 { 38 } 39 40 public static function baz() 41 { 42 <em>self</em>::bar(); 43 } 44} 45]]> 46 </code> 47 <code title="Invalid: Local class name used as reference."> 48 <![CDATA[ 49class <em>Foo</em> 50{ 51 public static function bar() 52 { 53 } 54 55 public static function baz() 56 { 57 <em>Foo</em>::bar(); 58 } 59} 60]]> 61 </code> 62 </code_comparison> 63</documentation> 64