@@ -14,3 +14,30 @@ function test(array $array, int $id): void {
1414 // only one element was set to 'foo', not all of them.
1515 assertType ("non-empty-array<int, array{state: string}> " , $ array );
1616}
17+
18+ /**
19+ * @param array<int, array{state?: string}> $array
20+ */
21+ function testMaybe (array $ array , int $ id ): void {
22+ $ array [$ id ]['state ' ] = 'foo ' ;
23+ // only one element was set to 'foo', not all of them.
24+ assertType ("non-empty-array<int, array{state?: string}> " , $ array );
25+ }
26+
27+ /**
28+ * @param array<int, array{state: string|bool}> $array
29+ */
30+ function testUnionValue (array $ array , int $ id ): void {
31+ $ array [$ id ]['state ' ] = 'foo ' ;
32+ // only one element was set to 'foo', not all of them.
33+ assertType ("non-empty-array<int, array{state: bool|string}> " , $ array );
34+ }
35+
36+ /**
37+ * @param array<int, array{state: string}|array{foo: int}> $array
38+ */
39+ function testUnionArray (array $ array , int $ id ): void {
40+ $ array [$ id ]['state ' ] = 'foo ' ;
41+ // only one element was set to 'foo', not all of them.
42+ assertType ("non-empty-array<int, non-empty-array{foo?: int, state?: string}> " , $ array );
43+ }
0 commit comments