Skip to content

Commit

Permalink
Merge pull request #7487 from orklah/error
Browse files Browse the repository at this point in the history
fix error with 0 being considered positive
  • Loading branch information
orklah committed Jan 25, 2022
2 parents 7c8441b + 204d09b commit 1cc9d1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Type/TypeCombiner.php
Expand Up @@ -1193,7 +1193,7 @@ private static function scrapeIntProperties(

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();
}
}
Expand Down
12 changes: 12 additions & 0 deletions tests/IntRangeTest.php
Expand Up @@ -704,6 +704,18 @@ function doAnalysis(): void
'$_arr===' => 'non-empty-array<int<0, max>, int<0, max>>',
],
],
'noErrorPushingBigShapeIntoConstant' => [
'code' => '<?php
class DocComment
{
private const PSALM_ANNOTATIONS = [
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
];
}',
'assertions' => [
],
],
];
}

Expand Down

0 comments on commit 1cc9d1c

Please sign in to comment.