Skip to content

Commit 14cb258

Browse files
rajyanondrejmirtes
authored andcommitted
add regression for d5284ce
1 parent 297c1ee commit 14cb258

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,9 @@ public function testBug3171(): void
362362
$this->analyse([__DIR__ . '/data/bug-3171.php'], []);
363363
}
364364

365+
public function testBug4747(): void
366+
{
367+
$this->analyse([__DIR__ . '/data/bug-4747.php'], []);
368+
}
369+
365370
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug4747;
4+
5+
/**
6+
* @param array{a_1: array{int, string}, a_2: array{int, string}, hi: int} $r
7+
* @return string
8+
*/
9+
function x(array $r, string $d) : string
10+
{
11+
assert($d === '1' || $d === '2');
12+
13+
return $r['a_' . $d][1];
14+
}

0 commit comments

Comments
 (0)