Skip to content

Commit

Permalink
Fix #5406 - track more changes to assertion type
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Mar 16, 2021
1 parent 2777b62 commit 9d979e3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Psalm/Internal/Type/AssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,8 @@ private static function filterTypeWithAnother(

$has_param_match = true;

$new_param_id = $new_param->getId();

$new_param = self::filterTypeWithAnother(
$codebase,
$existing_param,
Expand All @@ -768,7 +770,7 @@ private static function filterTypeWithAnother(
$existing_type->bustCache();

if ($has_param_match
&& $existing_type_part->type_params[$i]->getId() !== $new_param->getId()
&& $existing_type_part->type_params[$i]->getId() !== $new_param_id
) {
/** @psalm-suppress PropertyTypeCoercion */
$existing_type_part->type_params[$i] = $new_param;
Expand Down
22 changes: 22 additions & 0 deletions tests/AssertAnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,28 @@ function takesParam(Param $p) : void {
}
}',
],
'assertTemplatedIterable' => [
'<?php
class Foo{}
/**
* @param array<Foo> $foos
* @return array<Foo>
*/
function foo(array $foos) : array {
allIsInstanceOf($foos, Foo::class);
return $foos;
}
/**
* @template ExpectedType of object
*
* @param mixed $value
* @param class-string<ExpectedType> $class
* @psalm-assert iterable<ExpectedType> $value
*/
function allIsInstanceOf($value, $class): void {}'
],
];
}

Expand Down

0 comments on commit 9d979e3

Please sign in to comment.