1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- =============================
- Rule ``self_static_accessor``
- =============================
- Inside a ``final`` class or anonymous class ``self`` should be preferred to
- ``static``.
- Examples
- --------
- Example #1
- ~~~~~~~~~~
- .. code-block:: diff
- --- Original
- +++ New
- @@ -5,7 +5,7 @@
- public function getBar()
- {
- - return static::class.static::test().static::$A;
- + return self::class.self::test().self::$A;
- }
- private static function test()
- Example #2
- ~~~~~~~~~~
- .. code-block:: diff
- --- Original
- +++ New
- @@ -3,6 +3,6 @@
- {
- public function bar()
- {
- - return new static();
- + return new self();
- }
- }
- Example #3
- ~~~~~~~~~~
- .. code-block:: diff
- --- Original
- +++ New
- @@ -3,6 +3,6 @@
- {
- public function isBar()
- {
- - return $foo instanceof static;
- + return $foo instanceof self;
- }
- }
- Example #4
- ~~~~~~~~~~
- .. code-block:: diff
- --- Original
- +++ New
- @@ -2,6 +2,6 @@
- $a = new class() {
- public function getBar()
- {
- - return static::class;
- + return self::class;
- }
- };
|