-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Usage of "Constructor Promotion" for PHP >= 8.0.2 #17204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Symfony version 6.0 requires PHP 8.0.2 or higher, so I would suggest to make usage of the `Constructor Promotion` feature.
Related also to one of my PR i think docs core members should define what/how/etc can be done regarding sf6/php8 to modernize the example without having much conflict and so on It could definitely be worth it :) |
I'm failing to find my previous comments on changes like this (maybe I didn't comment it on GitHub?). I would say our current stance on using new PHP features is a very conservative in the docs. Our docs is quite "code example heavy" (i.e. we often favor documenting features in code blocks over writing long paragraphs). For this reason, code examples must be as focused on the actual feature as possible. At this moment, my opinion would be:
|
Thanks @94noni for mentioning your PR! IMO @wouterj due to the popularity of the framework, I think "modernizing" code examples using PHP new features would be a nice way of educating other developers that may not be aware of these functionalities yet. Plus, the specific case of |
My vote would be to merge this. I agree with @wouterj about "Constructor promotion" not being common, but this is less and less true as time goes. Also, any person using recent Symfony versions and reading its docs, should be using a PHP version compatible with that feature, so readers won't face technical issues. @xabbuh and @OskarStark what do you think about this? Thanks! |
My only concern would be merge conflicts when merging things up. But as we do less changes in lower branches I think we should be able to deal with them. So 👍 from me. |
👍 for me too |
public function __construct(private UrlGeneratorInterface $router) | ||
{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure which code style Symfony uses, but we should use the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Guilherme! While merging I tweaked this a bit (see 835a8e0) to follow current Symfony code syntax rules about this (see #17204 (comment)) |
Symfony version 6.0 requires PHP 8.0.2 or higher, so I would suggest to make usage of the
Constructor Promotion
feature.