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