Skip to content

Commit f8e8d4d

Browse files
committed
TypeHintDeclarationSniff: Added missing @inheritdoc support for properties
1 parent c93f5bb commit f8e8d4d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

SlevomatCodingStandard/Sniffs/TypeHints/TypeHintDeclarationSniff.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,10 @@ private function checkPropertyTypeHint(\PHP_CodeSniffer\Files\File $phpcsFile, i
781781
return;
782782
}
783783

784+
if ($this->hasInheritdocAnnotation($phpcsFile, $propertyPointer)) {
785+
return;
786+
}
787+
784788
$varAnnotations = AnnotationHelper::getAnnotationsByName($phpcsFile, $propertyPointer, '@var');
785789
if (count($varAnnotations) === 0) {
786790
if (SuppressHelper::isSniffSuppressed($phpcsFile, $propertyPointer, $this->getSniffName(self::CODE_MISSING_PROPERTY_TYPE_HINT))) {
@@ -1049,9 +1053,9 @@ private function getUselessParameterAnnotations(\PHP_CodeSniffer\Files\File $php
10491053
return $uselessParameterNames;
10501054
}
10511055

1052-
private function hasInheritdocAnnotation(\PHP_CodeSniffer\Files\File $phpcsFile, int $functionPointer): bool
1056+
private function hasInheritdocAnnotation(\PHP_CodeSniffer\Files\File $phpcsFile, int $pointer): bool
10531057
{
1054-
$docComment = DocCommentHelper::getDocComment($phpcsFile, $functionPointer);
1058+
$docComment = DocCommentHelper::getDocComment($phpcsFile, $pointer);
10551059
if ($docComment === null) {
10561060
return false;
10571061
}

tests/Sniffs/TypeHints/data/typeHintDeclarationNoErrors.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,4 +662,9 @@ public function usefullSymfonySecurityAnnotation()
662662

663663
}
664664

665+
/**
666+
* {@inheritdoc}
667+
*/
668+
public $inheritdoc;
669+
665670
}

0 commit comments

Comments
 (0)