diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php index ba3e1710f0..ae2a02146d 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) { @@ -752,11 +752,7 @@ protected function checkInheritdoc(File $phpcsFile, $stackPtr, $commentStart) if (in_array($tokens[$i]['code'], $allowedTokens) === false) { $trimmedContent = strtolower(trim($tokens[$i]['content'])); - if ($trimmedContent === '{@inheritdoc}') { - return true; - } else { - return false; - } + return $trimmedContent === '{@inheritdoc}' || $trimmedContent === '@inheritdoc'; } } diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc index 4f59f60b71..bba9323623 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc @@ -1006,6 +1006,11 @@ function foo($foo) {} */ public function foo($a, $b) {} +/** + * @inheritDoc + */ +public function foo($a, $b) {} + // phpcs:set Squiz.Commenting.FunctionComment skipIfInheritdoc true /** @@ -1013,6 +1018,11 @@ public function foo($a, $b) {} */ public function foo($a, $b) {} +/** + * @inheritDoc + */ +public function foo($a, $b) {} + /** * Foo. * @@ -1042,7 +1052,7 @@ public function ignored() { // phpcs:set Squiz.Commenting.FunctionComment specialMethods[] __construct,__destruct -/** +/** * @return void * @throws Exception If any other error occurs. */ function throwCommentOneLine() {} diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed index 21a4103eb5..f86860d619 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed @@ -1006,6 +1006,11 @@ function foo($foo) {} */ public function foo($a, $b) {} +/** + * @inheritDoc + */ +public function foo($a, $b) {} + // phpcs:set Squiz.Commenting.FunctionComment skipIfInheritdoc true /** @@ -1013,6 +1018,11 @@ public function foo($a, $b) {} */ public function foo($a, $b) {} +/** + * @inheritDoc + */ +public function foo($a, $b) {} + /** * Foo. * @@ -1042,7 +1052,7 @@ public function ignored() { // phpcs:set Squiz.Commenting.FunctionComment specialMethods[] __construct,__destruct -/** +/** * @return void * @throws Exception If any other error occurs. */ function throwCommentOneLine() {} diff --git a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php index 632b7c51b2..7c0825d6db 100644 --- a/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php @@ -115,7 +115,9 @@ public function getErrorList() 997 => 1, 1004 => 2, 1006 => 1, - 1029 => 1, + 1009 => 2, + 1011 => 1, + 1039 => 1, ]; // Scalar type hints only work from PHP 7 onwards. @@ -151,7 +153,7 @@ public function getErrorList() $errors[459] = 1; $errors[893] = 3; } else { - $errors[1023] = 1; + $errors[1033] = 1; } return $errors;