diff --git a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php index 42152b724..0d2ff8f01 100644 --- a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php @@ -586,6 +586,12 @@ class SimpleNegatedAssertionReconciler extends Reconciler } } + if ($existing_var_type->hasBool()) { + $existing_var_type->removeType('bool'); + + $existing_var_type->addType(new Type\Atomic\TTrue); + } + self::removeFalsyNegatedLiteralTypes( $existing_var_type, $did_remove_type diff --git a/tests/AssertAnnotationTest.php b/tests/AssertAnnotationTest.php index a5055c3ad..e35516475 100644 --- a/tests/AssertAnnotationTest.php +++ b/tests/AssertAnnotationTest.php @@ -1674,6 +1674,20 @@ class AssertAnnotationTest extends TestCase }', 'error_message' => 'InvalidDocblock', ], + 'assertNotEmptyOnBool' => [ + ' 'RedundantConditionGivenDocblockType', + ], ]; } } diff --git a/tests/TypeReconciliation/ReconcilerTest.php b/tests/TypeReconciliation/ReconcilerTest.php index 6e6fafc8d..935200d98 100644 --- a/tests/TypeReconciliation/ReconcilerTest.php +++ b/tests/TypeReconciliation/ReconcilerTest.php @@ -132,6 +132,7 @@ class ReconcilerTest extends \Psalm\Tests\TestCase 'iterableWithParamsToTraversableWithParams' => ['Traversable', '!array', 'iterable'], 'iterableAndObject' => ['Traversable', 'object', 'iterable'], 'iterableAndNotObject' => ['array', '!object', 'iterable'], + 'boolNotEmptyIsTrue' => ['true', '!empty', 'bool'], ]; }