1
0
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:
orklah 2021-04-08 04:02:13 +02:00 committed by GitHub
parent 870c433dc2
commit 5f4a21190f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;
}'
],
];
}