Find the best Rector rule to solve your problem. Searching through 645 rules.

Found 10 rules:

RemoveUnusedPromotedPropertyRector

Remove unused promoted property

 class SomeClass
 {
     public function __construct(
-        private $someUnusedDependency,
         private $usedDependency
     ) {
     }

     public function getUsedDependency()
     {
         return $this->usedDependency;
     }
 }
SETS:  Dead Code

RemoveUnusedPrivatePropertyRector

Remove unused private properties

 class SomeClass
 {
-    private $property;
 }
SETS:  Dead Code

RemoveUnusedVariableAssignRector

Remove unused assigns to variables

 class SomeClass
 {
     public function run()
     {
-        $value = 5;
     }
 }
SETS:  Dead Code

RemoveNullPropertyInitializationRector

Remove initialization with null value from property declarations

 class SunshineCommand extends ParentClassWithNewConstructor
 {
-    private $myVar = null;
+    private $myVar;
 }
SETS:  Dead Code

RemoveUnusedPrivateClassConstantRector

Remove unused class constants

 class SomeClass
 {
-    private const SOME_CONST = 'dead';
-
     public function run()
     {
     }
 }
SETS:  Dead Code

RemoveUnusedNonEmptyArrayBeforeForeachRector

Remove unused if check to non-empty array before foreach of the array

 class SomeClass
 {
     public function run()
     {
         $values = [];
-        if ($values !== []) {
-            foreach ($values as $value) {
-                echo $value;
-            }
+        foreach ($values as $value) {
+            echo $value;
         }
     }
 }
SETS:  Dead Code

RemoveTypedPropertyDeadInstanceOfRector

Remove dead instanceof check on type hinted property

 final class SomeClass
 {
     private $someObject;

     public function __construct(SomeObject $someObject)
     {
         $this->someObject = $someObject;
     }

     public function run()
     {
-        if ($this->someObject instanceof SomeObject) {
-            return true;
-        }
-
-        return false;
+        return true;
     }
 }
SETS:  Dead Code

RemoveUnusedForeachKeyRector

Remove unused key in foreach

 $items = [];
-foreach ($items as $key => $value) {
+foreach ($items as $value) {
     $result = $value;
 }
SETS:  Dead Code

RemoveUselessAssignFromPropertyPromotionRector

Remove useless re-assign from property promotion

 class SomeClass
 {
     public function __construct(private \stdClass $std)
     {
-    	$this->std = $std;
     }
 }
SETS:  Dead Code

RemoveUnusedPublicMethodParameterRector

Remove unused parameter in public method on final class without extends and interface

 final class SomeClass
 {
-    public function run($a, $b)
+    public function run($a)
     {
         echo $a;
     }
 }
SETS:  Dead Code