Skip to content

Commit 9f3a13d

Browse files
VincentLangletondrejmirtes
authored andcommitted
Add non regression test
1 parent 5732016 commit 9f3a13d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,4 +954,16 @@ public function testBug12447(): void
954954
]);
955955
}
956956

957+
public function testBug1061(): void
958+
{
959+
$this->reportPossiblyNonexistentConstantArrayOffset = true;
960+
961+
$this->analyse([__DIR__ . '/data/bug-1061.php'], [
962+
[
963+
"Offset 'one'|'two' might not exist on array{two: 1, three: 2}.",
964+
14,
965+
],
966+
]);
967+
}
968+
957969
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug1061;
4+
5+
class A {
6+
const KEYS = ["one", "two"];
7+
const ARR = [
8+
"two" => 1,
9+
"three" => 2
10+
];
11+
}
12+
13+
foreach (A::KEYS as $key) {
14+
echo A::ARR[$key];
15+
}

0 commit comments

Comments
 (0)