Find the best Rector rule to solve your problem
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);
}
}
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);
}
}
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);
}
}
Change static::class
to self::class
on final class
final class SomeClass
{
public function callOnMe()
{
- var_dump(static::class);
+ var_dump(self::class);
}
}
Replace string class names by
class AnotherClass
{
}
class SomeClass
{
public function run()
{
- return 'AnotherClass';
+ return \AnotherClass::class;
}
}
Change __CLASS__
to self::class
class SomeClass
{
public function callOnMe()
{
- var_dump(__CLASS__);
+ var_dump(self::class);
}
}