File tree Expand file tree Collapse file tree 4 files changed +36
-29
lines changed Expand file tree Collapse file tree 4 files changed +36
-29
lines changed Original file line number Diff line number Diff line change @@ -1068,6 +1068,7 @@ private function specifyTypesForCountFuncCall(
10681068 !$ isNormalCount ->yes ()
10691069 || (!$ isConstantArray ->yes () && !$ isList ->yes ())
10701070 || !$ oneOrMore ->isSuperTypeOf ($ sizeType )->yes ()
1071+ || $ sizeType ->isSuperTypeOf ($ type ->getArraySize ())->yes ()
10711072 ) {
10721073 return null ;
10731074 }
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace CountConstArray2 ;
4+
5+ use function PHPStan \Testing \assertType ;
6+
7+ class HelloWorld
8+ {
9+ /**
10+ * @param int<1, max> $limit
11+ * @return list<\stdClass>
12+ */
13+ public function searchRecommendedMinPrices (int $ limit ): array
14+ {
15+ $ bestMinPrice = new \stdClass ();
16+ $ limit --;
17+ if ($ limit === 0 ) {
18+ return [$ bestMinPrice ];
19+ }
20+
21+ $ otherMinPrices = [new \stdClass ()];
22+ while (count ($ otherMinPrices ) < $ limit ) {
23+ $ otherMinPrice = new \stdClass ();
24+ if (rand (0 , 1 )) {
25+ $ otherMinPrice = null ;
26+ }
27+ if ($ otherMinPrice === null ) {
28+ break ;
29+ }
30+ array_unshift ($ otherMinPrices , $ otherMinPrice );
31+ }
32+ assertType ('non-empty-list<stdClass> ' , $ otherMinPrices );
33+ return [$ bestMinPrice , ...$ otherMinPrices ];
34+ }
35+ }
Original file line number Diff line number Diff line change @@ -139,11 +139,6 @@ public function testBug1216(): void
139139 ]);
140140 }
141141
142- public function testBug1311 (): void
143- {
144- $ this ->analyse ([__DIR__ . '/data/bug-1311.php ' ], []);
145- }
146-
147142 public function testTypesAssignedToPropertiesExpressionNames (): void
148143 {
149144 $ this ->analyse ([__DIR__ . '/data/properties-from-array-into-object.php ' ], [
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments