mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Numeric can be Falsy (#5598)
This commit is contained in:
parent
870c433dc2
commit
5f4a21190f
@ -814,6 +814,7 @@ class Union implements TypeNode
|
||||
return isset($this->types['int'])
|
||||
|| isset($this->types['float'])
|
||||
|| isset($this->types['numeric-string'])
|
||||
|| isset($this->types['numeric'])
|
||||
|| ($include_literal_int && $this->literal_int_types)
|
||||
|| $this->literal_float_types;
|
||||
}
|
||||
|
@ -816,6 +816,17 @@ class RedundantConditionTest extends \Psalm\Tests\TestCase
|
||||
assert(is_string($value));
|
||||
}'
|
||||
],
|
||||
'NumericCanBeFalsy' => [
|
||||
'<?php
|
||||
function test(string|int|float|bool $value): bool {
|
||||
if (is_numeric($value) || $value === true) {
|
||||
if ($value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user