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 | 2714829_2.patch | 23.45 KB | Mile23 |
Comments
Comment #2
Mile23Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma
demands that we never put a space before a comma when we're sending arguments to a function or method.It's so mean.
All changes are like this:
Comment #3
borisson_Comment #4
alexpottThis should just be
Generic.Functions.FunctionCallArgumentSpacing
core complies with all the other parts of this sniff according to phpcs. Other than that this looks great. Fixing on commit.