mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 12:24:49 +01:00
Fix #4759 – don’t generate assertion when assigning to same-named variable
This commit is contained in:
parent
fcf2bc3831
commit
9c5cc02f90
@ -1884,6 +1884,11 @@ class AssignmentAnalyzer
|
||||
$codebase
|
||||
);
|
||||
|
||||
$right_clauses = Context::filterClauses(
|
||||
$var_id,
|
||||
$right_clauses
|
||||
);
|
||||
|
||||
$assignment_clauses = \Psalm\Internal\Algebra::combineOredClauses(
|
||||
[new \Psalm\Internal\Clause([$var_id => ['falsy']], $var_object_id, $var_object_id)],
|
||||
$right_clauses,
|
||||
|
@ -1052,6 +1052,13 @@ class TypeAlgebraTest extends \Psalm\Tests\TestCase
|
||||
}
|
||||
}'
|
||||
],
|
||||
'assignSameName' => [
|
||||
'<?php
|
||||
function foo(string $value): string {
|
||||
$value = "yes" === $value;
|
||||
return !$value ? "foo" : "bar";
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user