From dfbc9dd177d00e74334748f539409abf85bdee11 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 24 Jul 2023 09:07:46 +0200 Subject: [PATCH] Fix combination of non-falsy-string and falsy literal --- src/Psalm/Internal/Type/TypeCombiner.php | 5 ----- tests/TypeCombinationTest.php | 7 +++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Psalm/Internal/Type/TypeCombiner.php b/src/Psalm/Internal/Type/TypeCombiner.php index d091c2399..5577a10ac 100644 --- a/src/Psalm/Internal/Type/TypeCombiner.php +++ b/src/Psalm/Internal/Type/TypeCombiner.php @@ -1038,11 +1038,6 @@ class TypeCombiner && $type->value ) { // do nothing - } elseif (isset($combination->value_types['string']) - && $combination->value_types['string'] instanceof TNonEmptyString - && $type->value !== '' - ) { - // do nothing } else { $combination->value_types['string'] = new TString(); } diff --git a/tests/TypeCombinationTest.php b/tests/TypeCombinationTest.php index 5a74bc012..c3371ef2a 100644 --- a/tests/TypeCombinationTest.php +++ b/tests/TypeCombinationTest.php @@ -860,6 +860,13 @@ class TypeCombinationTest extends TestCase 'non-empty-literal-string', ], ], + 'nonFalsyStringAndFalsyLiteral' => [ + 'string', + [ + 'non-falsy-string', + '"0"', + ], + ], ]; }