Changes Single return of || to early returns
class SomeClass
{
public function accept()
{
- return $this->something() || $this->somethingElse();
+ if ($this->something()) {
+ return true;
+ }
+ return (bool) $this->somethingElse();
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
return RectorConfig::configure()
->withRules([
ReturnBinaryOrToEarlyReturnRector::class,
]);