Shortens else/if to elseif
class SomeClass
{
public function run()
{
if ($cond1) {
return $action1;
- } else {
- if ($cond2) {
- return $action2;
- }
+ } elseif ($cond2) {
+ return $action2;
}
}
}
Configure your rector.php
:
<?php
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
ShortenElseIfRector::class,
]);