1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 12:24:49 +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 committed by Daniil Gentili
parent 4f5a3ca82b
commit 01781af718
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
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)){}
}'
],
];
}