From 5f4a21190f14b9dcc61fb18d671d9b7cc2208373 Mon Sep 17 00:00:00 2001 From: orklah Date: Thu, 8 Apr 2021 04:02:13 +0200 Subject: [PATCH] Numeric can be Falsy (#5598) --- src/Psalm/Type/Union.php | 1 + tests/TypeReconciliation/RedundantConditionTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/Psalm/Type/Union.php b/src/Psalm/Type/Union.php index a108e94ec..580b898fd 100644 --- a/src/Psalm/Type/Union.php +++ b/src/Psalm/Type/Union.php @@ -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; } diff --git a/tests/TypeReconciliation/RedundantConditionTest.php b/tests/TypeReconciliation/RedundantConditionTest.php index 6ee575dc9..92501bdcb 100644 --- a/tests/TypeReconciliation/RedundantConditionTest.php +++ b/tests/TypeReconciliation/RedundantConditionTest.php @@ -816,6 +816,17 @@ class RedundantConditionTest extends \Psalm\Tests\TestCase assert(is_string($value)); }' ], + 'NumericCanBeFalsy' => [ + '