mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix #7968 - combine and simplify types where necessary in ternary analysis
This commit is contained in:
parent
f960d71b7e
commit
990887148c
@ -129,7 +129,12 @@ class TernaryAnalyzer
|
|||||||
|
|
||||||
$if_clauses = Algebra::simplifyCNF($if_clauses);
|
$if_clauses = Algebra::simplifyCNF($if_clauses);
|
||||||
|
|
||||||
$ternary_context_clauses = array_merge($entry_clauses, $if_clauses);
|
$ternary_context_clauses = $entry_clauses
|
||||||
|
? Algebra::simplifyCNF(array_merge(
|
||||||
|
$entry_clauses,
|
||||||
|
$if_clauses
|
||||||
|
))
|
||||||
|
: $if_clauses;
|
||||||
|
|
||||||
if ($if_context->reconciled_expression_clauses) {
|
if ($if_context->reconciled_expression_clauses) {
|
||||||
$reconciled_expression_clauses = $if_context->reconciled_expression_clauses;
|
$reconciled_expression_clauses = $if_context->reconciled_expression_clauses;
|
||||||
|
@ -1202,6 +1202,18 @@ class TypeAlgebraTest extends TestCase
|
|||||||
if ($foo === null) {}
|
if ($foo === null) {}
|
||||||
}'
|
}'
|
||||||
],
|
],
|
||||||
|
'ternaryAssertionOnBool' => [
|
||||||
|
'code' => '<?php
|
||||||
|
function test(string|object $s, bool $b) : string {
|
||||||
|
if (!$b || is_string($s)) {
|
||||||
|
return $b ? $s : "";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}',
|
||||||
|
'assertions' => [],
|
||||||
|
'ignored_issues' => [],
|
||||||
|
'php_version' => '8.0',
|
||||||
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user