Skip to content

Commit 394815c

Browse files
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.
1 parent 1c62383 commit 394815c

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

routing.rst

+3-11
Original file line numberDiff line numberDiff line change
@@ -2193,12 +2193,8 @@ the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface` class
21932193

21942194
class SomeService
21952195
{
2196-
private $router;
2197-
2198-
public function __construct(UrlGeneratorInterface $router)
2199-
{
2200-
$this->router = $router;
2201-
}
2196+
public function __construct(private UrlGeneratorInterface $router)
2197+
{}
22022198

22032199
public function someMethod()
22042200
{
@@ -2312,13 +2308,9 @@ Now you'll get the expected results when generating URLs in your commands::
23122308

23132309
class SomeCommand extends Command
23142310
{
2315-
private $router;
2316-
2317-
public function __construct(RouterInterface $router)
2311+
public function __construct(private RouterInterface $router)
23182312
{
23192313
parent::__construct();
2320-
2321-
$this->router = $router;
23222314
}
23232315

23242316
protected function execute(InputInterface $input, OutputInterface $output): int

0 commit comments

Comments
 (0)