Skip to content

Commit dcc4d9e

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

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

SlevomatCodingStandard/Sniffs/TypeHints/PropertyTypeHintSniff.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ private function checkTraversableTypeHintSpecification(
429429

430430
$typeNode = $propertyAnnotation->getType();
431431

432+
if (TypeHintHelper::isTypeDefinedInAnnotation($phpcsFile, $propertyPointer, (string) $typeNode)) {
433+
return;
434+
}
435+
432436
if (
433437
!$hasTraversableTypeHint
434438
&& !AnnotationTypeHelper::containsTraversableType($typeNode, $phpcsFile, $propertyPointer, $this->getTraversableTypeHints())

tests/Sniffs/TypeHints/data/propertyTypeHintEnabledNativeNoErrors.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,8 @@ class Aliases
194194
*/
195195
private static $withAlias3;
196196

197+
/**
198+
* @var SomeAlias3
199+
*/
200+
private array $withArrayAlias4;
197201
}

0 commit comments

Comments
 (0)