mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix #4827 - don’t eradicate double after int check
This commit is contained in:
parent
4416da85e7
commit
cbf7e596f7
@ -476,7 +476,12 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
|
||||
&& UnionTypeComparator::isContainedBy(
|
||||
$codebase,
|
||||
$existing_var_type,
|
||||
$new_type
|
||||
$new_type,
|
||||
false,
|
||||
false,
|
||||
null,
|
||||
false,
|
||||
false
|
||||
)
|
||||
) {
|
||||
self::triggerIssueForImpossible(
|
||||
|
@ -27,7 +27,8 @@ class UnionTypeComparator
|
||||
bool $ignore_null = false,
|
||||
bool $ignore_false = false,
|
||||
?TypeComparisonResult $union_comparison_result = null,
|
||||
bool $allow_interface_equality = false
|
||||
bool $allow_interface_equality = false,
|
||||
bool $allow_float_int_equality = true
|
||||
) : bool {
|
||||
if ($union_comparison_result) {
|
||||
$union_comparison_result->scalar_type_match_found = true;
|
||||
@ -108,7 +109,7 @@ class UnionTypeComparator
|
||||
$input_type_part,
|
||||
$container_type_part,
|
||||
$allow_interface_equality,
|
||||
true,
|
||||
$allow_float_int_equality,
|
||||
$atomic_comparison_result
|
||||
);
|
||||
|
||||
|
@ -1406,6 +1406,22 @@ class FunctionCallTest extends TestCase
|
||||
[],
|
||||
'8.0'
|
||||
],
|
||||
'getTypeDoubleThenInt' => [
|
||||
'<?php
|
||||
function safe_float(mixed $val): bool {
|
||||
switch (gettype($val)) {
|
||||
case "double":
|
||||
case "integer":
|
||||
return true;
|
||||
// ... more cases omitted
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}',
|
||||
[],
|
||||
[],
|
||||
'8.0'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user