Skip to content

Commit

Permalink
Merge pull request #9260 from weirdan/fix-crash-with-int-range-overflow
Browse files Browse the repository at this point in the history
Fixes #9114
  • Loading branch information
weirdan committed Feb 10, 2023
2 parents a4d593c + 85d4acf commit 468cc21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Psalm/Internal/Type/SimpleAssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
use function count;
use function explode;
use function get_class;
use function is_int;
use function min;
use function strlen;
use function strpos;
Expand Down Expand Up @@ -2000,7 +2001,7 @@ private static function reconcileIsGreaterThan(
$existing_var_type->addType(new TIntRange($assertion_value, $atomic_type->value));
}
}*/
} elseif ($atomic_type instanceof TInt) {
} elseif ($atomic_type instanceof TInt && is_int($assertion_value)) {
$redundant = false;
$existing_var_type->removeType($atomic_type->getKey());
$existing_var_type->addType(new TIntRange($assertion_value, null));
Expand Down
13 changes: 13 additions & 0 deletions tests/IntRangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,19 @@ function bar(int $_a, int $_b): void {}
}
',
],
'rangeOverflow' => [
'code' => '<?php
$i = (int)ceil(1);
if ($i <= 9223372036854775807) {
$z = $i;
} else {
$z = null;
}
',
'assertions' => [
'$z' => 'int<min, 9223372036854775807>|null',
],
],
];
}

Expand Down

0 comments on commit 468cc21

Please sign in to comment.