Split if statement, when if condition always break execution flow
class SomeClass
{
public function run($value)
{
if ($value) {
throw new \InvalidStateException;
- } else {
- return 10;
}
+
+ return 10;
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
return RectorConfig::configure()
->withRules([
RemoveAlwaysElseRector::class,
]);