ChangeNestedIfsToEarlyReturnRector

Change nested ifs to early return

 class SomeClass
 {
     public function run()
     {
-        if ($value === 5) {
-            if ($value2 === 10) {
-                return 'yes';
-            }
+        if ($value !== 5) {
+            return 'no';
+        }
+
+        if ($value2 === 10) {
+            return 'yes';
         }

         return 'no';
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector;

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