Run Rector on your code to see what it can do for you:
<?php use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
final class SomeController extends AbstractController { - #[Route('/some-path/{from}/{to}', name: 'some_name')] - public function someAction( - \DateTimeImmutable $from, - \DateTimeImmutable $to, - ) { - return $this->render('template.html.twig', ['from' => $from, 'to' => $to]); + public function __construct(private readonly \DateTimeImmutable $from, private readonly \DateTimeImmutable $to) + { + } + #[Route('/some-path/{from}/{to}', name: 'some_name')] + public function someAction() + { + return $this->render('template.html.twig', ['from' => $this->from, 'to' => $this->to]); } }
Applied Rules:
Not a change you expect?
rector.php