|  | 
| 1 | 1 | <documentation title="Self Member Reference"> | 
| 2 | 2 |     <standard> | 
| 3 | 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. | 
|  | 4 | +    The self keyword must be lowercase. | 
| 5 | 5 |     ]]> | 
| 6 | 6 |     </standard> | 
| 7 | 7 |     <code_comparison> | 
| 8 | 8 |         <code title="Valid: Lowercase self used."> | 
| 9 | 9 |         <![CDATA[ | 
| 10 |  | -<em>self</em>::foo(); | 
|  | 10 | +class Bar { | 
|  | 11 | +    public function baz() { | 
|  | 12 | +        <em>self</em>::foo(); | 
|  | 13 | +    } | 
|  | 14 | +} | 
| 11 | 15 |         ]]> | 
| 12 | 16 |         </code> | 
| 13 | 17 |         <code title="Invalid: Uppercase self used."> | 
| 14 | 18 |         <![CDATA[ | 
| 15 |  | -<em>SELF</em>::foo(); | 
|  | 19 | +class Bar { | 
|  | 20 | +    public function baz() { | 
|  | 21 | +        <em>SELF</em>::foo(); | 
|  | 22 | +    } | 
|  | 23 | +} | 
| 16 | 24 |         ]]> | 
| 17 | 25 |         </code> | 
| 18 | 26 |     </code_comparison> | 
|  | 27 | +    <standard> | 
|  | 28 | +    <![CDATA[ | 
|  | 29 | +    There must be no spaces before or after the double colon operator. | 
|  | 30 | +    ]]> | 
|  | 31 | +    </standard> | 
| 19 | 32 |     <code_comparison> | 
| 20 |  | -        <code title="Valid: Correct spacing used."> | 
|  | 33 | +        <code title="Valid: No spaces around the double colon operator."> | 
| 21 | 34 |         <![CDATA[ | 
| 22 |  | -self<em></em>::<em></em>foo(); | 
|  | 35 | +class Bar { | 
|  | 36 | +    public function baz() { | 
|  | 37 | +        self<em></em>::<em></em>foo(); | 
|  | 38 | +    } | 
|  | 39 | +} | 
| 23 | 40 |         ]]> | 
| 24 | 41 |         </code> | 
| 25 |  | -        <code title="Invalid: Incorrect spacing used."> | 
|  | 42 | +        <code title="Invalid: Spaces around double colon operator."> | 
| 26 | 43 |         <![CDATA[ | 
| 27 |  | -self<em> </em>::<em> </em>foo(); | 
|  | 44 | +class Bar { | 
|  | 45 | +    public function baz() { | 
|  | 46 | +        self<em> </em>::<em> </em>foo(); | 
|  | 47 | +    } | 
|  | 48 | +} | 
| 28 | 49 |         ]]> | 
| 29 | 50 |         </code> | 
| 30 | 51 |     </code_comparison> | 
|  | 52 | +    <standard> | 
|  | 53 | +    <![CDATA[ | 
|  | 54 | +    The self keyword must be used instead of the current class name. | 
|  | 55 | +    ]]> | 
|  | 56 | +    </standard> | 
| 31 | 57 |     <code_comparison> | 
| 32 | 58 |         <code title="Valid: Self used as reference."> | 
| 33 | 59 |         <![CDATA[ | 
| 34 |  | -class Foo | 
| 35 |  | -{ | 
| 36 |  | -    public static function bar() | 
| 37 |  | -    { | 
| 38 |  | -    } | 
|  | 60 | +class Foo { | 
|  | 61 | +    public function bar() {} | 
| 39 | 62 | 
 | 
| 40 |  | -    public static function baz() | 
| 41 |  | -    { | 
|  | 63 | +    public function baz() { | 
| 42 | 64 |         <em>self</em>::bar(); | 
| 43 | 65 |     } | 
| 44 | 66 | } | 
| 45 | 67 |         ]]> | 
| 46 | 68 |         </code> | 
| 47 | 69 |         <code title="Invalid: Local class name used as reference."> | 
| 48 | 70 |         <![CDATA[ | 
| 49 |  | -class <em>Foo</em> | 
| 50 |  | -{ | 
| 51 |  | -    public static function bar() | 
| 52 |  | -    { | 
| 53 |  | -    } | 
|  | 71 | +class <em>Foo</em> { | 
|  | 72 | +    public function bar() {} | 
| 54 | 73 | 
 | 
| 55 |  | -    public static function baz() | 
| 56 |  | -    { | 
|  | 74 | +    public function baz() { | 
| 57 | 75 |         <em>Foo</em>::bar(); | 
| 58 | 76 |     } | 
| 59 | 77 | } | 
|  | 
0 commit comments