mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix generic destruction in assertion (#5888)
This commit is contained in:
parent
a4871c1ef8
commit
3ad3375777
@ -135,7 +135,7 @@ class AndAnalyzer
|
||||
$changed_var_ids,
|
||||
$left_referenced_var_ids,
|
||||
$statements_analyzer,
|
||||
[],
|
||||
$statements_analyzer->getTemplateTypeMap() ?: [],
|
||||
$context->inside_loop,
|
||||
new CodeLocation($statements_analyzer->getSource(), $stmt->left),
|
||||
$context->inside_negation
|
||||
|
@ -2626,6 +2626,46 @@ class ConditionalTest extends \Psalm\Tests\TestCase
|
||||
isValid($val) ? $takesValid($val) : $takesInvalid($val);
|
||||
}'
|
||||
],
|
||||
'reconcileMoreThanOneGenericObject' => [
|
||||
'<?php
|
||||
|
||||
final class Invalid {}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
final class Valid {}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @param Invalid|Valid<T> $val
|
||||
* @psalm-assert-if-true Valid<T> $val
|
||||
*/
|
||||
function isValid($val): bool
|
||||
{
|
||||
return $val instanceof Valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param Valid<T>|Invalid $val1
|
||||
* @param Valid<T>|Invalid $val2
|
||||
* @param Valid<T>|Invalid $val3
|
||||
*/
|
||||
function inGenericContext($val1, $val2, $val3): void
|
||||
{
|
||||
$takesValid =
|
||||
/** @param Valid<T> $_valid */
|
||||
function ($_valid): void {};
|
||||
|
||||
if (isValid($val1) && isValid($val2) && isValid($val3)) {
|
||||
$takesValid($val1);
|
||||
$takesValid($val2);
|
||||
$takesValid($val3);
|
||||
}
|
||||
}'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user