Skip to content

Commit 1a75558

Browse files
committed
TypeHintDeclarationSniff should ignore methods even with {@ignoredoc} format
1 parent 0f1c282 commit 1a75558

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

SlevomatCodingStandard/Sniffs/TypeHints/TypeHintDeclarationSniff.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,12 @@ private function getUselessParameterNames(\PHP_CodeSniffer\Files\File $phpcsFile
987987

988988
private function hasInheritdocAnnotation(\PHP_CodeSniffer\Files\File $phpcsFile, int $functionPointer): bool
989989
{
990-
return count(AnnotationHelper::getAnnotationsByName($phpcsFile, $functionPointer, '@inheritdoc')) !== 0;
990+
$docComment = DocCommentHelper::getDocComment($phpcsFile, $functionPointer);
991+
if ($docComment === null) {
992+
return false;
993+
}
994+
995+
return strpos($docComment, '@inheritdoc') !== false;
991996
}
992997

993998
}

tests/Sniffs/TypeHints/data/typeHintDeclarationNoErrors.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,19 @@ public function returnpartialUseWithAliasTraversable(): DoctrineCollections\Arra
616616
}
617617

618618
/**
619-
* @inheritdoc
619+
* {@inheritdoc}
620620
*/
621621
public function inheritdoc($a)
622622
{
623623
return true;
624624
}
625625

626+
/**
627+
* @inheritdoc
628+
*/
629+
public function inheritdocAnnotation($a)
630+
{
631+
return true;
632+
}
633+
626634
}

0 commit comments

Comments
 (0)