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

fix error with 0 being considered positive

This commit is contained in:
orklah 2022-01-25 21:39:53 +01:00
parent 7c8441baec
commit 204d09b271
2 changed files with 13 additions and 1 deletions

View File

@ -1193,7 +1193,7 @@ class TypeCombiner
if (!isset($combination->value_types['int'])) {
$combination->value_types['int'] = $all_nonnegative
? new TIntRange(1, null)
? new TIntRange(0, null) // improvement: use min and max literals to bound
: new TNonspecificLiteralInt();
}
}

View File

@ -704,6 +704,18 @@ class IntRangeTest extends TestCase
'$_arr===' => 'non-empty-array<int<0, max>, int<0, max>>',
],
],
'noErrorPushingBigShapeIntoConstant' => [
'code' => '<?php
class DocComment
{
private const PSALM_ANNOTATIONS = [
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
];
}',
'assertions' => [
],
],
];
}