1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Fix #4306 - negating positive-numeric is useless, avoid crash

This commit is contained in:
Matt Brown 2020-10-11 23:16:43 -04:00
parent 7195275993
commit 5be7276a17
2 changed files with 10 additions and 0 deletions

View File

@ -67,6 +67,10 @@ class NegatedAssertionReconciler extends Reconciler
);
}
if ($is_equality && $assertion === 'positive-numeric') {
return $existing_var_type;
}
if (!$is_equality) {
if ($assertion === 'isset') {
if ($existing_var_type->possibly_undefined) {

View File

@ -775,6 +775,12 @@ class ValueTest extends \Psalm\Tests\TestCase
if ($foo) {}
}',
],
'allowCheckOnPositiveNumericInverse' => [
'<?php
function foo(int $a): void {
if (false === ($a > 1)){}
}'
],
];
}