Ignore specifc sniffs when adding additional parameters to interface methods

Created on 23 June 2025, about 1 month ago

Problem/Motivation

The documentation for how to how to add additional parameters to interface methods uses 'phpcs: disable'.

The doc was initially changed in 🌱 Document how to add additional parameters to interface methods Fixed and later work in 🐛 Fix PHPStan arguments.count error Active

Steps to reproduce

Proposed resolution

Ignore only the specific sniffs needed, not all sniffs.
Change the example in 2 at Step 1: Prepare the new signature

current text

    * phpcs:disable Drupal.Commenting
    * @todo Uncomment new method parameters before drupal:11.0.0.
    * @see https://www.drupal.org/project/drupal/issues/3354672
    *
    * @param BazInterface $baz
    *   Documentation for parameter $baz.
    * phpcs:enable

proposed text

    * phpcs:ignore Drupal.Commenting.DocComment.TagGroupSpacing
    * @todo Uncomment new method parameters before drupal:11.0.0.
    * @see https://www.drupal.org/project/drupal/issues/3354672
    * phpcs:ignore Drupal.Commenting.FunctionComment.ParamNameNoMatch
    * @param BazInterface $baz
    *   Documentation for parameter $baz.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component

base system

Created by

🇳🇿New Zealand quietone

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @quietone
  • First commit to issue fork.
  • 🇮🇳India immaculatexavier

    I've updated Step 2: Prepare the new signature in the documentation as part of this change. Specifically, I replaced the broad phpcs:disable Drupal.Commenting with targeted phpcs:ignore annotations for:

    Drupal.Commenting.DocComment.TagGroupSpacing

    Drupal.Commenting.FunctionComment.ParamNameNoMatch

    This ensures that we only suppress the necessary sniffs and maintain all other coding standards. The change is in line with the recommendations discussed in #3531685 Proposed Resolution

    https://www.drupal.org/about/core/policies/core-change-policies/how-to-d...

  • 🇺🇸United States xjm

    I've actually gone further in 🐛 Fix PHPStan arguments.count error Active and proposed that we change the standard to move the @todo and @see to the correct part of the docblock. This achieves several things:

    1. It has better readability.
    2. It follows our existing documentation standards.
    3. It allows us to remove an entire phpcs:ignore from every single parameter and typehint addition of this sort.
    4. It allows for the possibility of multiple parameters being added to a method, and for listing them clearly for the developer.

    Here's an example from that issue:

      /**
       * Gets sorted plugin definitions.
       *
       * @param array[]|null $definitions
       *   (optional) The plugin definitions to sort. If omitted, all plugin
       *   definitions are used.
       * phpcs:ignore Drupal.Commenting.FunctionComment.ParamNameNoMatch
       * @param string $label_key
       *   (optional) The key to be used as a label for sorting.
       *
       * @return array[]
       *   An array of plugin definitions, sorted by category and label.
       *
       * @see https://www.drupal.org/project/drupal/issues/3354672
       *
       * @todo Uncomment the new $label_key method parameter before drupal:12.0.0.
       */
      public function getSortedDefinitions(?array $definitions = NULL /*, string $label_key = 'label' */);
  • 🇺🇸United States xjm

    The current MR appears empty, so no credit is granted for @immaculatexavier.

  • 🇺🇸United States xjm

    A sample for the documentation page might be something like:

     /**
       * Returns sample data.
       *
       * phpcs:ignore Drupal.Commenting.FunctionComment.ParamNameNoMatch
       * @param string $added_parameter
       *   The new parameter being added.
       *
       * @return array[]
       *   The sample data.
       *
       * @see https://www.drupal.org/project/drupal/issues/3354672
       *
       * @todo Uncomment the new $added_parameter method parameter before drupal:12.0.0.
       */
      public function getSampleData(/* string $added_parameter = '' */);
    
  • 🇺🇸United States xjm

    xjm changed the visibility of the branch 3531685-ignore-specifc-sniffs to hidden.

  • 🇺🇸United States xjm
Production build 0.71.5 2024