Skip to content

Commit e2654b7

Browse files
committed
Fix duplicate errors in AssertRuleHelper
1 parent 0519ced commit e2654b7

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/Rules/MissingTypehintCheck.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ public function getIterableTypesWithMissingValueTypehint(Type $type): array
8585
if ($iterableValue instanceof MixedType && !$iterableValue->isExplicitMixed()) {
8686
$iterablesWithMissingValueTypehint[] = $type;
8787
}
88-
if ($type instanceof IntersectionType && !$type->isList()->yes()) {
88+
if ($type instanceof IntersectionType) {
89+
if ($type->isList()->yes()) {
90+
return $traverse($type->getIterableValueType());
91+
}
92+
8993
return $type;
9094
}
9195
}

tests/PHPStan/Rules/PhpDoc/FunctionAssertRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ public function testRule(): void
7070
'Asserted negated type string for $i with type int does not narrow down the type.',
7171
70,
7272
],
73+
[
74+
'PHPDoc tag @phpstan-assert for $array has no value type specified in iterable type array<int, mixed>.',
75+
88,
76+
'See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type',
77+
],
7378
]);
7479
}
7580

tests/PHPStan/Rules/PhpDoc/data/function-assert.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,18 @@ function negate1(int $i): void
7676
function negate2(int $i): void
7777
{
7878
}
79+
80+
/**
81+
* @param array<mixed> $array
82+
* @param string $message
83+
*
84+
* @phpstan-impure
85+
*
86+
* @psalm-assert list $array
87+
*/
88+
function isList($array, $message = ''): void
89+
{
90+
if (!array_is_list($array)) {
91+
92+
}
93+
}

0 commit comments

Comments
 (0)