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. - Run phpcs:
$ cd core $ ../vendor/bin/phpcs -p
- Fix the errors.
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 | 2710081-2.patch | 2.69 KB | alexpott |
Comments
Comment #2
alexpottComment #3
Mile23Since you're patching
core/phpcs.xml.dist
, the instructions are much simpler. Updating issue summary.The patch looks good.
phpcs only tells me one error which is out of scope here:
It would be nice if phpcs told you the sniff that triggered the error.
Anyway, RTBC.
Edit: Add
-s
to see sniffs in reports.Comment #4
alexpottCommitted 3815d7d and pushed to 8.1.x and 8.2.x. Thanks!