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

  1. 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/
    
  2. Patch core/phpcs.xml.dist with the desired sniff.
  3. Run phpcs:
    $ cd core
    $ ../vendor/bin/phpcs -p
    
  4. 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

CommentFileSizeAuthor
#2 2714829_2.patch23.45 KBMile23
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mile23 created an issue. See original summary.

Mile23’s picture

Status: Active » Needs review
FileSize
23.45 KB

Generic.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:

- someFunction($arg1 , $arg2);
+ someFunction($arg1, $arg2);
borisson_’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Title: Fix 'Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma' coding standard » Fix 'Generic.Functions.FunctionCallArgumentSpacing' coding standard
Status: Reviewed & tested by the community » Fixed
+++ b/core/phpcs.xml.dist
@@ -41,6 +41,7 @@
+  <rule ref="Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma"/>

This 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.

  • alexpott committed 4376b33 on 8.2.x
    Issue #2714829 by Mile23: Fix 'Generic.Functions....

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.