Skip to content

Commit 34e0a61

Browse files
staabmondrejmirtes
authored andcommitted
Added regression test
1 parent bfa860e commit 34e0a61

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

tests/PHPStan/Rules/Arrays/InvalidKeyInArrayDimFetchRuleTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,14 @@ public function testBug13135(): void
106106
]);
107107
}
108108

109+
public function testBug12273(): void
110+
{
111+
$this->analyse([__DIR__ . '/data/bug-12273.php'], [
112+
[
113+
'Possibly invalid array key type mixed.',
114+
16,
115+
],
116+
]);
117+
}
118+
109119
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Bug12273;
4+
5+
function doFoo():void {
6+
$map = [
7+
'datetime' => \DateTime::class,
8+
'stdclass' => \stdClass::class,
9+
];
10+
11+
$settings = json_decode('{"class": "datetim"}');
12+
13+
\PHPStan\dumpType($map);
14+
\PHPStan\dumpType($settings->class);
15+
16+
new ($map[$settings->class])();
17+
}

0 commit comments

Comments
 (0)