-
-
Notifications
You must be signed in to change notification settings - Fork 421
[RFC] Allow to use PHP 7.4 typed class properties #478
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
Comments
FYI : symfony/symfony#32179 |
Sorry, but I don't think it's related. It concerns the MakerBundle and the ability to generate code with typed properties in it. |
I know, it's just to show all the reflection by the symfony team |
@hermann8u thanks for this proposal. I'm not answering to it yet ... but I'd like to comment that @LeJeanbono is right in the sense that the MakerBundle always does what the main Symfony repo does (same code syntax, same PHP version requirements, same best practices for generated code, etc.) |
Well, Symfony 5.0 won't use Typed Properties, as the min requirement is PHP 7.2. |
One thing is needed in MakerBundle though, given that it can be used to modify existing entities and not just create some: we need to make sure it can edit an entity which uses typed properties without failing (and without removing the existing types). Maybe that's already the case thanks to PHP-Parser, but that should be checked (and probably added to the testsuite). |
Closing as there is nothing specific to keep track of. |
Uh oh!
There was an error while loading. Please reload this page.
PHP 7.4 and Symfony 5.0 release dates are at the end of november 2019. One of the biggest improvement expected by many developers in this PHP version is the ability to type class properties. However, I heard that Symfony 5.0 will supports only PHP 7.2.
Is there any plan to generate code with typed properties?
I thought about it a little bit and I see the following options :
Read the content of the composer.json to detect which version of PHP is used.
If the version is superior to 7.4, then use by default the class properties. The main drawback is that typed properties would be imposed to users, but I guess it's fine since this bundle aims to promote good practices.
Add configuration to the bundle
I know that this bundle doesn't have configuration yet and I understand that the goal is to generate something really straight forward. That's why it's maybe not the right choice. However, this configuration could be located in the composer.json under an "extra.symfony.allow_typed_properties" key or something like that.
Ask dynamically during the execution of the command
This option has the advantage to let the user make the choice but it could be redundant.
A mix of the previous options
Check if the composer.json contains a PHP version > 7.4, then ask dynamically to the user during the execution of a type related command if he wants to use typed properties and then register in the composer.json the choice.
Do nothing / None of the above options
I don't know if such a feature is a good idea or not, but I think it's worth a discussion. I realised that it will imply a lot of work too, and it might be not worth the pain.
What do you think about it?
The text was updated successfully, but these errors were encountered: