diff --git a/src/Psalm/Internal/Type/AssertionReconciler.php b/src/Psalm/Internal/Type/AssertionReconciler.php index 39daf035d..9412ca7b6 100644 --- a/src/Psalm/Internal/Type/AssertionReconciler.php +++ b/src/Psalm/Internal/Type/AssertionReconciler.php @@ -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( diff --git a/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php b/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php index 867c51387..1474c1188 100644 --- a/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php @@ -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 ); diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index e66fe3f3a..ea53d00bf 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -1406,6 +1406,22 @@ class FunctionCallTest extends TestCase [], '8.0' ], + 'getTypeDoubleThenInt' => [ + '