File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -249,4 +249,34 @@ protected function testOptionalKeys(array $row): void
249
249
}
250
250
}
251
251
252
+ /**
253
+ * @param array{mixed}|array{0: mixed, 1?: string|null} $row
254
+ */
255
+ protected function testOptionalKeysInUnion (array $ row ): void
256
+ {
257
+ if (count ($ row ) === 0 ) {
258
+ assertType ('*NEVER* ' , $ row );
259
+ } else {
260
+ assertType ('array{0: mixed, 1?: string|null} ' , $ row );
261
+ }
262
+
263
+ if (count ($ row ) === 1 ) {
264
+ assertType ('array{mixed} ' , $ row );
265
+ } else {
266
+ assertType ('array{0: mixed, 1?: string|null} ' , $ row );
267
+ }
268
+
269
+ if (count ($ row ) === 2 ) {
270
+ assertType ('array{mixed, string|null} ' , $ row );
271
+ } else {
272
+ assertType ('array{0: mixed, 1?: string|null} ' , $ row );
273
+ }
274
+
275
+ if (count ($ row ) === 3 ) {
276
+ assertType ('*NEVER* ' , $ row );
277
+ } else {
278
+ assertType ('array{0: mixed, 1?: string|null} ' , $ row );
279
+ }
280
+ }
281
+
252
282
}
You can’t perform that action at this time.
0 commit comments