Skip to content

Commit

Permalink
PropertyTypeHintSniff: Fixed false positive
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Feb 1, 2020
1 parent 16f856e commit c8f2e2b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,16 @@ private function checkTypeHint(
continue;
}

$isTraversable = TypeHintHelper::isTraversableType(TypeHintHelper::getFullyQualifiedTypeHint($phpcsFile, $propertyPointer, $typeHint), $this->getTraversableTypeHints());

if (!$isTraversable && count($traversableTypeHints) > 0) {
return;
}

if (
!$innerTypeNode instanceof ArrayTypeNode
&& !$innerTypeNode instanceof ArrayShapeNode
&& TypeHintHelper::isTraversableType(TypeHintHelper::getFullyQualifiedTypeHint($phpcsFile, $propertyPointer, $typeHint), $this->getTraversableTypeHints())
&& $isTraversable
) {
$traversableTypeHints[] = $typeHint;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,9 @@ class Whatever
/** @var mixed[]|array|Traversable */
public $moreTraverasableTypes;

/**
* @var mixed[]|array|SomethingThatLooksAsArray
*/
public $moreDifferentTypes;

}

0 comments on commit c8f2e2b

Please sign in to comment.