diff --git a/tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php b/tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php index a481085088..81a26af1c6 100644 --- a/tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php +++ b/tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php @@ -926,4 +926,12 @@ public function testBug3747(): void $this->analyse([__DIR__ . '/data/bug-3747.php'], []); } + public function testBug8372(): void + { + $this->checkExplicitMixed = true; + $this->checkImplicitMixed = true; + + $this->analyse([__DIR__ . '/data/bug-8372.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Arrays/data/bug-8372.php b/tests/PHPStan/Rules/Arrays/data/bug-8372.php new file mode 100644 index 0000000000..78de62d3d9 --- /dev/null +++ b/tests/PHPStan/Rules/Arrays/data/bug-8372.php @@ -0,0 +1,28 @@ + $path + */ + function test(string $method, array $path): void + { + if (!key_exists($method, $path)) { + return; + } + + if (!is_array($path[$method])) { + return; + } + + if (!key_exists('parameters', $path[$method])) { + $path[$method]['parameters'] = []; + + $path[$method]['parameters'][] = 'foo'; + $path[$method]['parameters'][] = 'bar'; + $path[$method]['parameters'][] = 'baz'; + } + } +}