ReturnEarlyIfVariableRector

Replace if conditioned variable override with direct return

 final class SomeClass
 {
     public function run($value)
     {
         if ($value === 50) {
-            $value = 100;
+            return 100;
         }

         return $value;
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector;

return RectorConfig::configure()
    ->withRules([
        ReturnEarlyIfVariableRector::class,
    ]);
SETS:  Early return