Skip to content

Commit f550a07

Browse files
Add non regression test
1 parent 83f1509 commit f550a07

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

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

929+
public function testBug4809(): void
930+
{
931+
$this->analyse([__DIR__ . '/data/bug-4809.php'], []);
932+
}
933+
929934
public function testBug8372(): void
930935
{
931936
$this->checkExplicitMixed = true;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug4809;
4+
5+
class SomeClass
6+
{
7+
/**
8+
* @param array{
9+
* some?: string,
10+
* another?: string,
11+
* } $data
12+
* @param string $key
13+
* @return void
14+
*/
15+
public function someFunction(array $data, string $key): void
16+
{
17+
if($key !== 'some' && $key !== 'another') {
18+
return;
19+
}
20+
21+
if(!array_key_exists($key, $data)) {
22+
return;
23+
}
24+
25+
var_dump($data[$key]);
26+
}
27+
}

0 commit comments

Comments
 (0)