SwitchTrueToIfRector

Change switch (true) to if statements

 class SomeClass
 {
     public function run()
     {
-        switch (true) {
-            case $value === 0:
-                return 'no';
-            case $value === 1:
-                return 'yes';
-            case $value === 2:
-                return 'maybe';
-        };
+        if ($value === 0) {
+            return 'no';
+        }
+
+        if ($value === 1) {
+            return 'yes';
+        }
+
+        if ($value === 2) {
+            return 'maybe';
+        }
     }
 }

Configure your rector.php:

<?php

use Rector\CodeQuality\Rector\Switch_\SwitchTrueToIfRector;
use Rector\Config\RectorConfig;

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