From 204d09b271408241fd88e8f83539b4d8c21e66e2 Mon Sep 17 00:00:00 2001 From: orklah Date: Tue, 25 Jan 2022 21:39:53 +0100 Subject: [PATCH] fix error with 0 being considered positive --- src/Psalm/Internal/Type/TypeCombiner.php | 2 +- tests/IntRangeTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Type/TypeCombiner.php b/src/Psalm/Internal/Type/TypeCombiner.php index f18591f4201..1b202d836fa 100644 --- a/src/Psalm/Internal/Type/TypeCombiner.php +++ b/src/Psalm/Internal/Type/TypeCombiner.php @@ -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(); } } diff --git a/tests/IntRangeTest.php b/tests/IntRangeTest.php index eaba7f7fd36..9cb2e8fa263 100644 --- a/tests/IntRangeTest.php +++ b/tests/IntRangeTest.php @@ -704,6 +704,18 @@ function doAnalysis(): void '$_arr===' => 'non-empty-array, int<0, max>>', ], ], + 'noErrorPushingBigShapeIntoConstant' => [ + 'code' => ' [ + ], + ], ]; }