From 948ece9deae02a9f2d017ff41670362c85f69178 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 4 May 2023 14:21:04 +0300 Subject: [PATCH] Fix string negation to never --- .../Type/NegatedAssertionReconciler.php | 4 +++ tests/AssertAnnotationTest.php | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php index 5e1d994e857..3ce8aedd4fc 100644 --- a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php @@ -182,6 +182,10 @@ public static function reconcile( ) { $existing_var_type->removeType('array-key'); $existing_var_type->addType(new TString); + } elseif ($assertion_type instanceof TNonEmptyString + && $existing_var_type->hasString() + ) { + // do nothing } elseif ($assertion instanceof IsClassNotEqual) { // do nothing } elseif ($assertion_type instanceof TClassString && $assertion_type->is_loaded) { diff --git a/tests/AssertAnnotationTest.php b/tests/AssertAnnotationTest.php index eb3281bcb43..de1e2b8c6e1 100644 --- a/tests/AssertAnnotationTest.php +++ b/tests/AssertAnnotationTest.php @@ -2221,6 +2221,32 @@ function takesSomeIntFromEnum(int $foo): IntEnum 'ignored_issues' => [], 'php_version' => '8.1', ], + 'assertStringIsNonEmptyString' => [ + 'code' => '