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(); + } }
Applied Rules:
Not a change you expect?
rector.php