mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Int and Float can be reconciled with Numeric (#5611)
This commit is contained in:
parent
3b3065c881
commit
bb88cff28a
@ -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;
|
||||
}
|
||||
|
@ -827,6 +827,21 @@ class RedundantConditionTest extends \Psalm\Tests\TestCase
|
||||
return false;
|
||||
}'
|
||||
],
|
||||
'NumericCanBeNotIntOrNotFloat' => [
|
||||
'<?php
|
||||
/** @param mixed $a */
|
||||
function a($a): void{
|
||||
if (is_numeric($a)) {
|
||||
assert(!is_float($a));
|
||||
}
|
||||
}
|
||||
/** @param mixed $a */
|
||||
function b($a): void{
|
||||
if (is_numeric($a)) {
|
||||
assert(!is_int($a));
|
||||
}
|
||||
}'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user