File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1105,6 +1105,8 @@ private function specifyTypesForCountFuncCall(
1105
1105
if (
1106
1106
$ sizeType instanceof IntegerRangeType
1107
1107
&& $ sizeType ->getMin () !== null
1108
+ && $ sizeType ->getMin () <= ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT
1109
+ && ($ sizeType ->getMax () ?? $ sizeType ->getMin ()) - $ sizeType ->getMin () <= ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT
1108
1110
&& (
1109
1111
$ isList ->yes ()
1110
1112
|| $ isConstantArray ->yes () && $ arrayType ->getKeyType ()->isSuperTypeOf (IntegerRangeType::fromInterval (0 , $ sizeType ->getMin () - 1 ))->yes ()
Original file line number Diff line number Diff line change @@ -1542,6 +1542,12 @@ public function testBug12159(): void
1542
1542
$ this ->assertNoErrors ($ errors );
1543
1543
}
1544
1544
1545
+ public function testBug12787 (): void
1546
+ {
1547
+ $ errors = $ this ->runAnalyse (__DIR__ . '/data/bug-12787.php ' );
1548
+ $ this ->assertNoErrors ($ errors );
1549
+ }
1550
+
1545
1551
/**
1546
1552
* @param string[]|null $allAnalysedFiles
1547
1553
* @return Error[]
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types = 1 );
2
+
3
+ namespace Bug12787 ;
4
+
5
+ class HelloWorld
6
+ {
7
+ protected const MAX_COUNT = 100000000 ;
8
+
9
+ /**
10
+ * @return string[]
11
+ */
12
+ public function accumulate (): array
13
+ {
14
+ $ items = [];
15
+
16
+ do {
17
+ $ items [] = 'something ' ;
18
+ } while (count ($ items ) < self ::MAX_COUNT );
19
+
20
+ return $ items ;
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments