From 7ed987a80745255962339a37d8faeca760d14bc1 Mon Sep 17 00:00:00 2001 From: Pavel Savushkin Date: Mon, 17 Jan 2022 17:31:20 +0200 Subject: [PATCH] fix: skip processing of Squiz.Commenting.FunctionComment for @inheritDoc It's supported to use {@inheritDoc}. Add support of @inheritDoc (w/o brackets). Original PR number - #3051 Closes #2770 --- .../Squiz/Sniffs/Commenting/FunctionCommentSniff.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php index ba3e1710f0..ee1c6c81e2 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php @@ -737,7 +737,7 @@ protected function checkSpacingAfterParamName(File $phpcsFile, $param, $maxVar, * in the stack passed in $tokens. * @param int $commentStart The position in the stack where the comment started. * - * @return boolean TRUE if the docblock contains only {@inheritdoc} (case-insensitive). + * @return boolean TRUE if the docblock contains {@inheritdoc} or @inheritdoc (case-insensitive). */ protected function checkInheritdoc(File $phpcsFile, $stackPtr, $commentStart) { @@ -751,12 +751,12 @@ protected function checkInheritdoc(File $phpcsFile, $stackPtr, $commentStart) for ($i = $commentStart; $i <= $tokens[$commentStart]['comment_closer']; $i++) { if (in_array($tokens[$i]['code'], $allowedTokens) === false) { $trimmedContent = strtolower(trim($tokens[$i]['content'])); + $allowedInheritDocs = [ + '{@inheritdoc}', + '@inheritdoc', + ]; - if ($trimmedContent === '{@inheritdoc}') { - return true; - } else { - return false; - } + return in_array($trimmedContent, $allowedInheritDocs); } }