Skip to content

Commit

Permalink
Merge branch refs/heads/1.12.x into 2.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
phpstan-bot authored Oct 6, 2024
2 parents 0210d45 + e2654b7 commit 8606348
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Rules/MissingTypehintCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ public function getIterableTypesWithMissingValueTypehint(Type $type): array
if ($iterableValue instanceof MixedType && !$iterableValue->isExplicitMixed()) {
$iterablesWithMissingValueTypehint[] = $type;
}
if ($type instanceof IntersectionType && !$type->isList()->yes()) {
if ($type instanceof IntersectionType) {
if ($type->isList()->yes()) {
return $traverse($type->getIterableValueType());
}

return $type;
}
}
Expand Down
5 changes: 5 additions & 0 deletions tests/PHPStan/Rules/PhpDoc/FunctionAssertRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ public function testRule(): void
'Asserted negated type string for $i with type int does not narrow down the type.',
70,
],
[
'PHPDoc tag @phpstan-assert for $array has no value type specified in iterable type array<int, mixed>.',
88,
'See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type',
],
]);
}

Expand Down
15 changes: 15 additions & 0 deletions tests/PHPStan/Rules/PhpDoc/data/function-assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,18 @@ function negate1(int $i): void
function negate2(int $i): void
{
}

/**
* @param array<mixed> $array
* @param string $message
*
* @phpstan-impure
*
* @psalm-assert list $array
*/
function isList($array, $message = ''): void
{
if (!array_is_list($array)) {

}
}

0 comments on commit 8606348

Please sign in to comment.