diff --git a/tests/PHPStan/Rules/Arrays/InvalidKeyInArrayDimFetchRuleTest.php b/tests/PHPStan/Rules/Arrays/InvalidKeyInArrayDimFetchRuleTest.php index c6e3df9768..22716afcd4 100644 --- a/tests/PHPStan/Rules/Arrays/InvalidKeyInArrayDimFetchRuleTest.php +++ b/tests/PHPStan/Rules/Arrays/InvalidKeyInArrayDimFetchRuleTest.php @@ -106,4 +106,14 @@ public function testBug13135(): void ]); } + public function testBug12273(): void + { + $this->analyse([__DIR__ . '/data/bug-12273.php'], [ + [ + 'Possibly invalid array key type mixed.', + 16, + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/Arrays/data/bug-12273.php b/tests/PHPStan/Rules/Arrays/data/bug-12273.php new file mode 100644 index 0000000000..6989899dcc --- /dev/null +++ b/tests/PHPStan/Rules/Arrays/data/bug-12273.php @@ -0,0 +1,17 @@ + \DateTime::class, + 'stdclass' => \stdClass::class, + ]; + + $settings = json_decode('{"class": "datetim"}'); + + \PHPStan\dumpType($map); + \PHPStan\dumpType($settings->class); + + new ($map[$settings->class])(); +}