diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 237034fa7d..2dd649705b 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -47,7 +47,10 @@ - + + + + @@ -154,9 +157,4 @@ src/Standards/Generic/Sniffs/Commenting/TodoSniff\.php src/Standards/Generic/Tests/Commenting/TodoUnitTest\.php - - - - src/Util/Tokens\.php - diff --git a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php index 569466ba61..2227f66348 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php @@ -111,7 +111,8 @@ public function processMemberVar(File $phpcsFile, $stackPtr) } else { $error = '%s tag is not allowed in member variable comment'; $data = [$tokens[$tag]['content']]; - $phpcsFile->addWarning($error, $tag, 'TagNotAllowed', $data); + $code = ucwords(ltrim($tokens[$tag]['content'], '@')).'TagNotAllowed'; + $phpcsFile->addWarning($error, $tag, $code, $data); }//end if }//end foreach diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc index 170b84fe69..08b15e2c44 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc @@ -476,3 +476,26 @@ class PHP84FinalProperties { */ final int $hasDocblock; } + +// phpcs:disable Squiz.Commenting.VariableComment.SinceTagNotAllowed +// phpcs:disable Squiz.Commenting.VariableComment.DeprecatedTagNotAllowed +class AllowMoreForSelectivelyIgnoringDisallowedTags { + /** + * @var string + * + * @since 3.1 + * @deprecated 10.5 + */ + public string $propertyWithExtraTags; + + /** + * @var string + * + * @link https://example.org/some-link + * @api + * @param string This tag is not allowed. + */ + public $theAboveExtraTagsAreStillNotAllowed; +} + +// phpcs:enable Squiz.Commenting.VariableComment diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed index 0b3c5a4b9e..36fe4688cb 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed @@ -476,3 +476,26 @@ class PHP84FinalProperties { */ final int $hasDocblock; } + +// phpcs:disable Squiz.Commenting.VariableComment.SinceTagNotAllowed +// phpcs:disable Squiz.Commenting.VariableComment.DeprecatedTagNotAllowed +class AllowMoreForSelectivelyIgnoringDisallowedTags { + /** + * @var string + * + * @since 3.1 + * @deprecated 10.5 + */ + public string $propertyWithExtraTags; + + /** + * @var string + * + * @link https://example.org/some-link + * @api + * @param string This tag is not allowed. + */ + public $theAboveExtraTagsAreStillNotAllowed; +} + +// phpcs:enable Squiz.Commenting.VariableComment diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php index 01691216ca..bda0cda65e 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php @@ -81,7 +81,12 @@ public function getErrorList() */ public function getWarningList() { - return [93 => 1]; + return [ + 93 => 1, + 494 => 1, + 495 => 1, + 496 => 1, + ]; }//end getWarningList()