From ba7f2a5b3bfbbdb75c341a620ac7cefa34802486 Mon Sep 17 00:00:00 2001 From: orklah Date: Sun, 5 Sep 2021 00:24:06 +0200 Subject: [PATCH] allow range int to be positive --- .../ReturnTypeProvider/ArrayFillReturnTypeProvider.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php index fbd002b5b..2c07cec31 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php @@ -74,6 +74,14 @@ class ArrayFillReturnTypeProvider implements \Psalm\Plugin\EventHandler\Function return true; } + if ($arg->isSingle()) { + foreach ($arg->getRangeInts() as $range_int) { + if ($range_int->isPositive()) { + return true; + } + } + } + return $arg->isSingleIntLiteral() && $arg->getSingleIntLiteral()->value > 0; } }