Find the best Rector rule to solve your problem. Searching through 675 rules.
Found 10 rules:
Rename variable to match method return type
class SomeClass
{
public function run()
{
- $a = $this->getRunner();
+ $runner = $this->getRunner();
}
public function getRunner(): Runner
{
return new Runner();
}
}
Renames value variable name in foreach loop to match method type
class SomeClass
{
public function run()
{
$array = [];
- foreach ($object->getMethods() as $property) {
- $array[] = $property;
+ foreach ($object->getMethods() as $method) {
+ $array[] = $method;
}
}
}
Renames value variable name in foreach loop to match expression variable
class SomeClass
{
public function run()
{
$array = [];
- foreach ($variables as $property) {
- $array[] = $property;
+ foreach ($variables as $variable) {
+ $array[] = $variable;
}
}
}
Rename property and method param to match its type
class SomeClass
{
/**
* @var EntityManager
*/
- private $eventManager;
+ private $entityManager;
- public function __construct(EntityManager $eventManager)
+ public function __construct(EntityManager $entityManager)
{
- $this->eventManager = $eventManager;
+ $this->entityManager = $entityManager;
}
}
Rename param to match ClassType
final class SomeClass
{
- public function run(Apple $pie)
+ public function run(Apple $apple)
{
- $food = $pie;
+ $food = $apple;
}
}
Rename variable to match new ClassType
final class SomeClass
{
public function run()
{
- $search = new DreamSearch();
- $search->advance();
+ $dreamSearch = new DreamSearch();
+ $dreamSearch->advance();
}
}
Renames mktime() without arguments to time()
class SomeClass
{
public function run()
{
$time = mktime(1, 2, 3);
- $nextTime = mktime();
+ $nextTime = time();
}
}
Rename param within closures and arrow functions based on use with specified method calls
-(new SomeClass)->process(function ($param) {});
+(new SomeClass)->process(function ($parameter) {});
Turns method names to new ones.
$someObject = new SomeExampleClass;
-$someObject->oldMethod();
+$someObject->newMethod();
Turns defined function call new one.
-view("...", []);
+Laravel\Templating\render("...", []);