mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Allow float to be empty (0.00)
This commit is contained in:
parent
334c463e08
commit
661087d445
@ -427,6 +427,23 @@ class Reconciler
|
||||
}
|
||||
}
|
||||
|
||||
if ($existing_var_type->hasFloat()) {
|
||||
$existing_float_types = $existing_var_type->getLiteralFloats();
|
||||
|
||||
if ($existing_float_types) {
|
||||
foreach ($existing_float_types as $key => $literal_type) {
|
||||
if ($literal_type->value) {
|
||||
$existing_var_type->removeType($key);
|
||||
$did_remove_type = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$did_remove_type = true;
|
||||
$existing_var_type->removeType('float');
|
||||
$existing_var_type->addType(new Type\Atomic\TLiteralFloat(0));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($existing_var_atomic_types['array'])
|
||||
&& $existing_var_atomic_types['array']->getId() !== 'array<empty, empty>'
|
||||
) {
|
||||
|
@ -1042,6 +1042,12 @@ class TypeReconciliationTest extends TestCase
|
||||
if (!$a || ($a instanceof B && $a->b())) {}
|
||||
}',
|
||||
],
|
||||
'reconcileFloatToEmpty' => [
|
||||
'<?php
|
||||
function bar(float $f) : void {
|
||||
if (!$f) {}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user