diff --git a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php index 878111b32..dd593f18c 100644 --- a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php @@ -1170,6 +1170,10 @@ class SimpleNegatedAssertionReconciler extends Reconciler } elseif ($existing_var_type->from_calculation) { $non_int_types[] = new TFloat(); } + } elseif ($type instanceof TNumeric) { + $did_remove_type = true; + $non_int_types[] = new TString(); + $non_int_types[] = new TFloat(); } else { $non_int_types[] = $type; } @@ -1261,6 +1265,10 @@ class SimpleNegatedAssertionReconciler extends Reconciler if ($is_equality) { $non_float_types[] = $type; } + } elseif ($type instanceof TNumeric) { + $did_remove_type = true; + $non_float_types[] = new TString(); + $non_float_types[] = new TInt(); } else { $non_float_types[] = $type; } diff --git a/tests/TypeReconciliation/RedundantConditionTest.php b/tests/TypeReconciliation/RedundantConditionTest.php index 92501bdcb..308b06d32 100644 --- a/tests/TypeReconciliation/RedundantConditionTest.php +++ b/tests/TypeReconciliation/RedundantConditionTest.php @@ -827,6 +827,21 @@ class RedundantConditionTest extends \Psalm\Tests\TestCase return false; }' ], + 'NumericCanBeNotIntOrNotFloat' => [ + '