diff --git a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php index e44f7a8d510..b588c4549db 100644 --- a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php @@ -67,6 +67,10 @@ public static function reconcile( ); } + if ($is_equality && $assertion === 'positive-numeric') { + return $existing_var_type; + } + if (!$is_equality) { if ($assertion === 'isset') { if ($existing_var_type->possibly_undefined) { diff --git a/tests/TypeReconciliation/ValueTest.php b/tests/TypeReconciliation/ValueTest.php index 39e9127acaf..0af5e69e276 100644 --- a/tests/TypeReconciliation/ValueTest.php +++ b/tests/TypeReconciliation/ValueTest.php @@ -775,6 +775,12 @@ function x(?string $foo): void { if ($foo) {} }', ], + 'allowCheckOnPositiveNumericInverse' => [ + ' 1)){} + }' + ], ]; }