Run Rector on your code to see what it can do for you:

 <?php
 
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 
 class ExampleController extends AbstractController
 {
-	public function example(Foo $foo): Response
-	{
-		dump($foo);
-
-		$problematic = static function() use ($foo): void {
-			dump($foo);
-		};
-
-		$problematic();
-	}
+	public function __construct(private readonly \Foo $foo)
+    {
+    }
+    public function example(): Response
+    {
+        dump($this->foo);
+        $problematic = static function (): void {
+            dump($this->foo);
+        };
+        $problematic();
+    }
 }
PHP snippet to change

Applied Rules:

Not a change you expect?

Config  rector.php
Rector version: b09565 - released at 2026-05-25 06:37