Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Part of #2571965: [meta] Fix PHP coding standards in core.
Problem/Motivation
Let's add more coding standards to our phpcs-based quality workflow!
Proposed resolution
- Add Drupal Coder to your Drupal codebase
$ composer require drupal/coder $ ./vendor/bin/phpcs --config-set installed_paths /PATH/drupal/vendor/drupal/coder/coder_sniffer/
- Patch
core/phpcs.xml.dist
with the desired sniff. - Running phpcs will show you errors that exist.
$ cd core $ ../vendor/bin/phpcs -p -s
- Fix the errors. You should run phpcbf to auto-fix as many as possible.
$ cd core $ ../vendor/bin/phpcbf
- You should then run phpcs again to see what it left behind.
- You should also review all changes. Generate a diff and read it.
To review: Add phpcs to your codebase, apply the patch, and run phpcs. Any errors reported by phpcs mean more work is needed.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#2 | 2783395_2.patch | 32.91 KB | Mile23 |
Comments
Comment #2
Mile23Moved to 8.2.x because it's a docs-only improvement, but the patch applies to both 8.2.x and 8.3.x.
Comment #3
Mile23Comment #4
Eric_A CreditAttribution: Eric_A commentedThis not only fixes a standards violation but also brings back consistency between param and return in these classes that we lost when #2783393: Fix 'Drupal.Commenting.FunctionComment.IncorrectParamVarName' coding standard went into 8.2.x and 8.3.x.
Comment #5
alexpottCommitted and pushed 2e5e060 to 8.3.x and 53b5df5 to 8.2.x. Thanks!