diff --git a/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php b/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php index f3dc6a63c..9df93389b 100644 --- a/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php @@ -585,6 +585,11 @@ class ScalarTypeComparator return true; } + if ($input_type_part instanceof TLowercaseString + && get_class($container_type_part) === TNonEmptyString::class) { + return false; + } + if ($input_type_part->getKey() === $container_type_part->getKey()) { return true; } diff --git a/tests/Template/ConditionalReturnTypeTest.php b/tests/Template/ConditionalReturnTypeTest.php index 0cbab4dc0..211dc000e 100644 --- a/tests/Template/ConditionalReturnTypeTest.php +++ b/tests/Template/ConditionalReturnTypeTest.php @@ -841,6 +841,24 @@ class ConditionalReturnTypeTest extends TestCase } ' ], + 'strlenReturnsIntForLowercaseString' => [ + '