PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

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

Open jrfnl opened this issue 8 months ago • 0 comments

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.

jrfnl avatar Apr 20 '25 01:04 jrfnl