From 394815cb03cb3cbe4ed592dbf13a2492e7f1e011 Mon Sep 17 00:00:00 2001 From: Guilherme Ferreira Date: Thu, 18 Aug 2022 19:40:12 +0200 Subject: [PATCH] Usage of "Constructor Promotion" for PHP >= 8.0.2 Symfony version 6.0 requires PHP 8.0.2 or higher, so I would suggest to make usage of the `Constructor Promotion` feature. --- routing.rst | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/routing.rst b/routing.rst index 2deee8bc920..b8e03422ec1 100644 --- a/routing.rst +++ b/routing.rst @@ -2193,12 +2193,8 @@ the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface` class class SomeService { - private $router; - - public function __construct(UrlGeneratorInterface $router) - { - $this->router = $router; - } + public function __construct(private UrlGeneratorInterface $router) + {} public function someMethod() { @@ -2312,13 +2308,9 @@ Now you'll get the expected results when generating URLs in your commands:: class SomeCommand extends Command { - private $router; - - public function __construct(RouterInterface $router) + public function __construct(private RouterInterface $router) { parent::__construct(); - - $this->router = $router; } protected function execute(InputInterface $input, OutputInterface $output): int