Skip to content

Commit 812c0d6

Browse files
committed
SlevomatCodingStandard.TypeHints.ReturnTypeHint: Type alias should not be reported as "missing traversable type hint specification"
1 parent ebc0025 commit 812c0d6

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

SlevomatCodingStandard/Sniffs/TypeHints/ReturnTypeHintSniff.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,10 @@ private function checkFunctionTraversableTypeHintSpecification(
449449

450450
$returnTypeNode = $this->getReturnTypeNode($returnAnnotation);
451451

452+
if (TypeHintHelper::isTypeDefinedInAnnotation($phpcsFile, $functionPointer, (string) $returnTypeNode)) {
453+
return;
454+
}
455+
452456
if (
453457
!$hasTraversableTypeHint
454458
&& !AnnotationTypeHelper::containsTraversableType(

tests/Sniffs/TypeHints/data/returnTypeHintNoErrors.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,4 +317,11 @@ public function withAlias3()
317317
{
318318
}
319319

320+
/**
321+
* @return SomeAlias3
322+
*/
323+
public function withArrayAlias(): array
324+
{
325+
}
326+
320327
}

0 commit comments

Comments
 (0)