File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
tests/PHPStan/Rules/Arrays Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -1270,6 +1270,13 @@ public function testBug13773(): void
12701270 ]);
12711271 }
12721272
1273+ public function testBug8985 (): void
1274+ {
1275+ $ this ->reportPossiblyNonexistentConstantArrayOffset = true ;
1276+
1277+ $ this ->analyse ([__DIR__ . '/data/bug-8985.php ' ], []);
1278+ }
1279+
12731280 public function testBug14308 (): void
12741281 {
12751282 $ this ->reportPossiblyNonexistentConstantArrayOffset = true ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Bug8985 ;
6+
7+ class Entity
8+ {
9+ public function __construct (private string $ value )
10+ {
11+ }
12+
13+ public function getValue (): string
14+ {
15+ return $ this ->value ;
16+ }
17+ }
18+
19+ class Repository
20+ {
21+ /** @return array<int, Entity> */
22+ public function getAll (): array
23+ {
24+ return [new Entity ('test ' )];
25+ }
26+ }
27+
28+ assert ((new Repository ())->getAll () === []);
29+
30+ $ all = (new Repository ())->getAll ();
31+ $ value = $ all [0 ]->getValue ();
You can’t perform that action at this time.
0 commit comments