Fork me on GitHub
a Sensio Labs Product

Kids Playground (v3.76.0) edition

Rule static_private_method

Converts private methods to static where possible.

Warning

Using this rule is risky

Risky when the method: contains dynamic generated calls to the instance, is dynamically referenced, is referenced inside a Trait the class uses.

Examples

Example #1

--- Original
+++ New
 <?php
 class Foo
 {
     public function bar()
     {
-        return $this->baz();
+        return self::baz();
     }

-    private function baz()
+    private static function baz()
     {
         return 1;
     }
 }

References

The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.