Skip to content

Squiz/VariableComment: make errorcode for "TagNotAllowed" warning modular#1039

Merged
jrfnl merged 2 commits into
4.xfrom
phpcs-4.0/feature/squiz-variablecomment-make-tagnotallowed-modular
Apr 29, 2025
Merged

Squiz/VariableComment: make errorcode for "TagNotAllowed" warning modular#1039
jrfnl merged 2 commits into
4.xfrom
phpcs-4.0/feature/squiz-variablecomment-make-tagnotallowed-modular

Conversation

@jrfnl

@jrfnl jrfnl commented Apr 20, 2025

Copy link
Copy Markdown
Member

Description

Squiz/VariableComment: make errorcode for "TagNotAllowed" warning modular

As things are, the VariableComment sniff only allows @see tags and @var tags in property docblocks.

This practice feels dated to me, as commonly used tags, such as @link, @deprecated etc are not allowed.

This commit replaces the generic TagNotAllowed error code in the sniff with a more modular [TagName]TagNotAllowed error code.

This allows for rulesets to selectively ignore the TagNotAllowed error code for specific tags the ruleset maintainer wants to allow for the code base under scan.

Includes tests.

CS: allow @link and @deprecated in property docblocks

... for this codebase.

Suggested changelog entry

Changed:

  • The error code Squiz.Commenting.VariableComment.TagNotAllowed has been replaced by a dynamic Squiz.Commenting.VariableComment.[TagName]TagNotAllowed error code.
    • This allows for selectively allowing specific tags by excluding the error code for that tag.
    • Example: to allow @link tags in property docblocks, exclude the Squiz.Commenting.VariableComment.LinkTagNotAllowed error code.

Related issues/external references

Loosely related to #122

jrfnl added 2 commits April 29, 2025 14:21
…ular

As things are, the `VariableComment` sniff only allows `@see` tags and `@var` tags in property docblocks.

This practice feels dated to me, as commonly used tags, such as `@link`, `@deprecated` etc are not allowed.

This commit replaces the generic `TagNotAllowed` error code in the sniff with a more modular `[TagName]TagNotAllowed` error code.

This allows for rulesets to selectively ignore the `TagNotAllowed` error code for specific tags the ruleset maintainer wants to allow for the code base under scan.

Includes tests.
@jrfnl
jrfnl force-pushed the phpcs-4.0/feature/squiz-variablecomment-make-tagnotallowed-modular branch from 870e42b to 20994a2 Compare April 29, 2025 12:21
@jrfnl

jrfnl commented Apr 29, 2025

Copy link
Copy Markdown
Member Author

Rebased without changes. Merging once the build has passed.

@jrfnl
jrfnl merged commit 570ce73 into 4.x Apr 29, 2025
@jrfnl
jrfnl deleted the phpcs-4.0/feature/squiz-variablecomment-make-tagnotallowed-modular branch April 29, 2025 12:32
rodrigoprimo added a commit to rodrigoprimo/WordPress-Coding-Standards that referenced this pull request Jul 16, 2026
….0 error codes

The `WordPress-Docs` ruleset excludes `Squiz.Commenting.VariableComment.TagNotAllowed`
to allow tags such tags in class variable docblocks, as used by the WordPress
documentation standards.

PHPCS 4.0 replaced this single generic error code with a per-tag `[TagName]TagNotAllowed`
error code (PHPCSStandards/PHP_CodeSniffer#1039), so the existing
exclusion no longer suppresses these warnings when running on PHPCS 4.x.

This commit adds exclusions for the new per-tag error codes (`SinceTagNotAllowed`,
`LinkTagNotAllowed` and `DeprecatedTagNotAllowed`), while keeping the existing
`TagNotAllowed` exclusion for compatibility with PHPCS 3.x.
rodrigoprimo added a commit to rodrigoprimo/WordPress-Coding-Standards that referenced this pull request Jul 17, 2026
….0 error codes

The `WordPress-Docs` ruleset excludes `Squiz.Commenting.VariableComment.TagNotAllowed`
to allow tags such tags in class variable docblocks, as used by the WordPress
documentation standards.

PHPCS 4.0 replaced this single generic error code with a per-tag `[TagName]TagNotAllowed`
error code (PHPCSStandards/PHP_CodeSniffer#1039), so the existing
exclusion no longer suppresses these warnings when running on PHPCS 4.x.

This commit adds exclusions for the new per-tag error codes (`SinceTagNotAllowed`,
`LinkTagNotAllowed` and `DeprecatedTagNotAllowed`), while keeping the existing
`TagNotAllowed` exclusion for compatibility with PHPCS 3.x.
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.

1 participant