Changes if || to early return
class SomeClass
{
public function canDrive(Car $newCar)
{
foreach ($cars as $car) {
- if ($car->hasWheels() || $car->hasFuel()) {
+ if ($car->hasWheels()) {
+ continue;
+ }
+ if ($car->hasFuel()) {
continue;
}
$car->setWheel($newCar->wheel);
$car->setFuel($newCar->fuel);
}
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
return RectorConfig::configure()
->withRules([
ChangeOrIfContinueToMultiContinueRector::class,
]);