Skip to content

Commit a02c4ef

Browse files
phpstan-botstaabm
authored andcommitted
Add regression test for #14129
Closes phpstan/phpstan#14129
1 parent 289fed3 commit a02c4ef

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Bug14129;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class Foo
8+
{
9+
10+
/**
11+
* @param array{foo: int} $a
12+
*/
13+
public function doFoo(array $a): void
14+
{
15+
$k = rand(0, 1) ? 'a' : 'b';
16+
$a[$k] = 256;
17+
assertType('array{foo: int, a: 256}|array{foo: int, b: 256}', $a);
18+
}
19+
20+
/**
21+
* @param array{foo: int} $a
22+
* @param int<1,5> $intRange
23+
*/
24+
public function doBar(array $a, $intRange): void
25+
{
26+
$a[$intRange] = 256;
27+
assertType('array{foo: int, 1: 256}|array{foo: int, 2: 256}|array{foo: int, 3: 256}|array{foo: int, 4: 256}|array{foo: int, 5: 256}', $a);
28+
}
29+
30+
}

0 commit comments

Comments
 (0)