Skip to content

Commit 05898b0

Browse files
staabmondrejmirtes
authored andcommitted
Added regression test
1 parent 65d5610 commit 05898b0

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,4 +926,12 @@ public function testBug3747(): void
926926
$this->analyse([__DIR__ . '/data/bug-3747.php'], []);
927927
}
928928

929+
public function testBug8372(): void
930+
{
931+
$this->checkExplicitMixed = true;
932+
$this->checkImplicitMixed = true;
933+
934+
$this->analyse([__DIR__ . '/data/bug-8372.php'], []);
935+
}
936+
929937
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Bug8372;
4+
5+
class Test
6+
{
7+
/**
8+
* @param array<mixed> $path
9+
*/
10+
function test(string $method, array $path): void
11+
{
12+
if (!key_exists($method, $path)) {
13+
return;
14+
}
15+
16+
if (!is_array($path[$method])) {
17+
return;
18+
}
19+
20+
if (!key_exists('parameters', $path[$method])) {
21+
$path[$method]['parameters'] = [];
22+
23+
$path[$method]['parameters'][] = 'foo';
24+
$path[$method]['parameters'][] = 'bar';
25+
$path[$method]['parameters'][] = 'baz';
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)