Skip to content

Commit 0e706b3

Browse files
committed
Regression test
Closes phpstan/phpstan#4532
1 parent 5ca8b49 commit 0e706b3

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,4 +980,14 @@ public function testBug1061(): void
980980
]);
981981
}
982982

983+
public function testBug4532(): void
984+
{
985+
$this->analyse([__DIR__ . '/data/bug-4532.php'], [
986+
[
987+
'Offset int|null might not exist on array<int, string>.',
988+
25,
989+
],
990+
]);
991+
}
992+
983993
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Bug4532;
4+
5+
use AllowDynamicProperties;
6+
7+
/**
8+
* @property int|null $status
9+
*/
10+
#[AllowDynamicProperties]
11+
class Entity
12+
{
13+
public const STATUS_OFF = 0;
14+
public const STATUS_ON = 1;
15+
16+
/** @var array<int, string> */
17+
public static array $statuses = [
18+
self::STATUS_OFF => 'Off',
19+
self::STATUS_ON => 'On',
20+
];
21+
}
22+
23+
function (): void {
24+
$entity = new Entity;
25+
echo Entity::$statuses[$entity->status];
26+
};

0 commit comments

Comments
 (0)