ControllerGetByTypeToConstructorInjectionRector

From $container->get(SomeType::class) in controllers to constructor injection (step 1/x)

 use Symfony\Bundle\FrameworkBundle\Controller\Controller;

 final class SomeCommand extends Controller
 {
+    public function __construct(private SomeType $someType)
+    {
+    }
+
     public function someMethod()
     {
-        $someType = $this->get(SomeType::class);
+        $someType = $this->someType;
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Symfony\DependencyInjection\Rector\Class_\ControllerGetByTypeToConstructorInjectionRector;

return RectorConfig::configure()
    ->withRules([
        ControllerGetByTypeToConstructorInjectionRector::class,
    ]);