Skip to content

Commit 980a943

Browse files
committed
Update bug-13857.php
1 parent 91c7a78 commit 980a943

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/PHPStan/Analyser/nsrt/bug-13857.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,19 @@ function testUnionArrayDifferentType(array $array, int $id): void {
4949
$array[$id]['state'] = true;
5050
assertType("non-empty-array<int, array{state: string}|non-empty-array{foo?: int, state?: true}>", $array);
5151
}
52+
53+
/**
54+
* @param array<int, array{state: 'foo'}> $array
55+
*/
56+
function testConstantArray(array $array, int $id): void {
57+
$array[$id]['state'] = 'bar';
58+
assertType("non-empty-array<int, array{state: 'bar'}|array{state: 'foo'}>", $array);
59+
}
60+
61+
/**
62+
* @param array<int, array{state: 'foo'}> $array
63+
*/
64+
function testConstantArrayNonScalarAssign(array $array, int $id, bool $b): void {
65+
$array[$id]['state'] = $b;
66+
assertType("non-empty-array<int, array{state: 'foo'}|array{state: bool}>", $array);
67+
}

0 commit comments

Comments
 (0)