Skip to content

Commit 1b6789f

Browse files
committed
minor #17204 Usage of "Constructor Promotion" for PHP >= 8.0.2 (githubfromgui)
This PR was merged into the 6.0 branch. Discussion ---------- Usage of "Constructor Promotion" for PHP >= 8.0.2 Symfony version [6.0 requires PHP 8.0.2](https://symfony.com/doc/6.0/setup.html#technical-requirements) or higher, so I would suggest to make usage of the [ `Constructor Promotion`](https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion) feature. <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `6.x` for features of unreleased versions). --> Commits ------- 394815c Usage of "Constructor Promotion" for PHP >= 8.0.2
2 parents 5823947 + 394815c commit 1b6789f

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)