Find the best Rector rule to solve your problem
Turns method names to new ones.
$someObject = new SomeExampleClass;
-$someObject->oldMethod();
+$someObject->newMethod();
Replaces defined class constants in their calls.
-$value = SomeClass::OLD_CONSTANT;
-$value = SomeClass::OTHER_OLD_CONSTANT;
+$value = SomeClass::NEW_CONSTANT;
+$value = DifferentClass::NEW_CONSTANT;
Replaces defined classes by new ones.
namespace App;
-use SomeOldClass;
+use SomeNewClass;
-function someFunction(SomeOldClass $someOldClass): SomeOldClass
+function someFunction(SomeNewClass $someOldClass): SomeNewClass
{
- if ($someOldClass instanceof SomeOldClass) {
- return new SomeOldClass;
+ if ($someOldClass instanceof SomeNewClass) {
+ return new SomeNewClass;
}
}
Change Doctrine\DBAL\Connection and Doctrine\DBAL\Driver\ResultStatement ->fetchAll() to ->fetchAllAssociative() and other replacements
use Doctrine\DBAL\Connection;
class SomeClass
{
public function run(Connection $connection)
{
- return $connection->fetchAll();
+ return $connection->fetchAllAssociative();
}
}
Extract array arg on QueryBuilder select, addSelect, groupBy, addGroupBy
function query(\Doctrine\DBAL\Query\QueryBuilder $queryBuilder)
{
- $query = $queryBuilder->select(['u.id', 'p.id']);
+ $query = $queryBuilder->select('u.id', 'p.id');
}