-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Enforce PSR-12 and organise imports on Winter CMS core files #1188
base: develop
Are you sure you want to change the base?
Conversation
This commit changes the PHP code sniffer to use PSR-12 rules, as that ruleset will pick up a lot of the code style issues being flagged in PRs recently. In order to set the baseline, all current core files have been reformatted to fit the ruleset.
- Convert all aliases to qualified class names (mainly facades) - Reorder imports alphabetically - Ensure last item in array has a trailing comma - Strip out unused imports
@bennothommo can you submit a PR to our developer guidelines docs to reflect these changes? Also, is it worth adding a Another thing to check is our stub files, I'm not sure if they've all been updated to our latest preferences for generating PHP files. |
This will allow us to use the ruleset in plugins as well
With new ruleset, it now passes
This command will allow developers to check code style against the Winter CMS code style rules in both the core and installed plugins.
parent::__construct(); | ||
|
||
// Register aliases for backwards compatibility with October | ||
$this->setAliases(['winter:phpcs']); |
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.
We have a property for that already: https://github.com/wintercms/winter/blob/develop/modules/system/console/asset/mix/MixCompile.php#L34-L39
This commit changes the PHP code sniffer to use PSR-12 rules, as that ruleset will pick up a lot of the code style issues being flagged in PRs recently.
In order to set the baseline, all current core files have been reformatted to fit the ruleset.
I have also implemented rules around imports in files - mainly, taking out the aliases and using qualified facades and class names, and stripping out unused imports. This will improve IDE support for PHP intelligence and code completion.
Arrays are also now enforced to have a trailing comma to improve diffs.
Sorry in advance for the code review... 😬
php artisan winter:phpcs
command