ControllerMethodInjectionToConstructorRector

Change Symfony controller method injection to direct constructor dependency, to separate params and services clearly

 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Annotation\Route;

 final class SomeController extends AbstractController
 {
+    public function __construct(
+        private readonly SomeService $someService
+    ) {
+    }
+
     #[Route('/some-path', name: 'some_name')]
     public function someAction(
-        Request $request,
-        SomeService $someService
+        Request $request
     ) {
-        $data = $someService->getData();
+        $data = $this->someService->getData();
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Symfony\CodeQuality\Rector\Class_\ControllerMethodInjectionToConstructorRector;

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