CombineIfRector

Merges nested if statements

 class SomeClass
 {
     public function run()
     {
-        if ($cond1) {
-            if ($cond2) {
-                return 'foo';
-            }
+        if ($cond1 && $cond2) {
+            return 'foo';
         }
     }
 }

Configure your rector.php:

<?php

use Rector\CodeQuality\Rector\If_\CombineIfRector;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withRules([
        CombineIfRector::class,
    ]);
SETS:  Code Quality