-
Notifications
You must be signed in to change notification settings - Fork 52
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
[3.x] Decide on coding standard for generated code #87
Comments
Great summary 👍 |
I support generating code that takes advantage of all those new language features. |
I would be cautious with introducing |
Laravel embracing new PHP features when generating code https://laravel-news.com/laravel-10-type-declarations |
I think, this can be closed. Hopefully the remaining generators will be updated soon. That's the only blocker for DCG 3.0. |
Note that DCG 3.x allows modifying generated assets through event subscribers. So modules will be able to alter the assets as needed. I played a bit with rector, php-cs-fixer and regexp. It worked well for me. |
Drupal 10 will require PHP 8.1 which means we can make use of all new PHP features available at this moment. However, Drupal coding standards weren't updated yet to reflect this change and will unlikely be updated in the foreseeable future. Furthermore, they don't cover PHP 7 features yet.
So far, all code generated by DCG follows Drupal core coding standards. Which means if something is not covered in Drupal coding standards it uses Drupal core code base as a referencing point. Nowadays, the generated code looks very outdated as most of Drupal core code is written using PHP 5 syntax only.
For custom projects it's not a problem to establish own standards for features that are missing in the Drupal coding standards.
Example: https://github.com/Chi-teck/drupal-coder-extension
However, for generated code that is going to be part of other projects it needs sort of community approval.
Here is an example of the currently generated code.
https://github.com/Chi-teck/drupal-code-generator/blob/3.0.0-alpha2/tests/functional/Generator/_controller/src/Controller/FooController.php
The following example represents proposed updates.
Here is an overview of the changes:
final
/private
/self
keywords to define non-abstract classes. #3019332@var
,@param
,@return
tags for strictly typed values. #3238192readonly
if they are not ever updated.The text was updated successfully, but these errors were encountered: