Find the best Rector rule to solve your problem


GetCalledClassToSelfClassRector

Change get_called_class() to self::class on final class

 final class SomeClass
 {
    public function callOnMe()
    {
-       var_dump(get_called_class());
+       var_dump(self::class);
    }
 }
SETS:  PHP 5.5

GetCalledClassToStaticClassRector

Change get_called_class() to static::class on non-final class

 class SomeClass
 {
    public function callOnMe()
    {
-       var_dump(get_called_class());
+       var_dump(static::class);
    }
 }
SETS:  PHP 5.5

PregReplaceEModifierRector

The /e modifier is no longer supported, use preg_replace_callback instead

 class SomeClass
 {
     public function run()
     {
-        $comment = preg_replace('~\b(\w)(\w+)~e', '"$1".strtolower("$2")', $comment);
+        $comment = preg_replace_callback('~\b(\w)(\w+)~', function ($matches) {
+              return($matches[1].strtolower($matches[2]));
+        }, $comment);
     }
 }
SETS:  PHP 5.5

StaticToSelfOnFinalClassRector

Change static::class to self::class on final class

 final class SomeClass
 {
    public function callOnMe()
    {
-       var_dump(static::class);
+       var_dump(self::class);
    }
 }
SETS:  PHP 5.5

Configurable

StringClassNameToClassConstantRector

Replace string class names by ::class constant

 class AnotherClass
 {
 }

 class SomeClass
 {
     public function run()
     {
-        return 'AnotherClass';
+        return \AnotherClass::class;
     }
 }

ClassConstantToSelfClassRector

Change __CLASS__ to self::class

 class SomeClass
 {
    public function callOnMe()
    {
-       var_dump(__CLASS__);
+       var_dump(self::class);
    }
 }
SETS:  PHP 5.5