Skip to content

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Sep 21, 2025

Description

To selectively ignore /disable/enable standards, sniff categories, sniffs or error codes, the phpcs:ignore, phpcs:disable and phpcs:enable annotations take a comma-separated list of rule references and allow for an optional -- comment at the end of the annotation.

While not strictly speaking "officially supported", the comma-separated list was whitespace tolerant in PHPCS 3.x.

This was unintentionally broken in PR #123, but only for the phpcs:ignore syntax. The phpcs:disable/phpcs:enable annotations were not affected.

This commit fixes this bug and brings back whitespace tolerance in the comma-separated list of rule references for phpcs:ignore.

It also adds a set of tests for all three types of annotations to safeguard this. The addition of these tests effectively means that this whitespace tolerance is now officially supported.

Suggested changelog entry

Fixed: whitespace tolerance in phpcs:ignore comma-separated rule ref lists.

Related issues/external references

Fixes #1277

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

To selectively ignore /disable/enable standards, sniff categories, sniffs or error codes, the `phpcs:ignore`, `phpcs:disable` and `phpcs:enable` annotations take a comma-separated list of rule references and allow for an optional `-- comment` at the end of the annotation.

While not strictly speaking "officially supported", the comma-separated list was whitespace tolerant in PHPCS 3.x.

This was unintentionally broken in PR 123, but only for the `phpcs:ignore` syntax. The `phpcs:disable`/`phpcs:enable` annotations were not affected.

This commit fixes this bug and brings back whitespace tolerance in the comma-separated list of rule references for `phpcs:ignore`.

It also adds a set of tests for all three types of annotations to safeguard this.
The addition of these tests effectively means that this whitespace tolerance is now officially supported.

Fixes 1277
Copy link

@Domi04151309 Domi04151309 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected

@jrfnl
Copy link
Member Author

jrfnl commented Sep 21, 2025

@Domi04151309 Thanks for testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ignoring multiple rules using phpcs:ignore only ignores the first one since version 4.0.0
2 participants