Skip to content

Commit 5d9d559

Browse files
committed
tests
1 parent d919fc5 commit 5d9d559

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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();

0 commit comments

Comments
 (0)