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 @@ -279,4 +279,34 @@ protected function testOptionalKeysInUnion(array $row): void
279
279
}
280
280
}
281
281
282
+ /**
283
+ * @param array{string}|array{0: mixed, 1?: string|null} $row
284
+ */
285
+ protected function testOptionalKeysInTaggedUnion (array $ row ): void
286
+ {
287
+ if (count ($ row ) === 0 ) {
288
+ assertType ('*NEVER* ' , $ row );
289
+ } else {
290
+ assertType ('array{0: mixed, 1?: string|null} ' , $ row );
291
+ }
292
+
293
+ if (count ($ row ) === 1 ) {
294
+ assertType ('array{mixed} ' , $ row );
295
+ } else {
296
+ assertType ('array{0: mixed, 1?: string|null} ' , $ row );
297
+ }
298
+
299
+ if (count ($ row ) === 2 ) {
300
+ assertType ('array{mixed, string|null} ' , $ row );
301
+ } else {
302
+ assertType ('array{0: mixed, 1?: string|null} ' , $ row );
303
+ }
304
+
305
+ if (count ($ row ) === 3 ) {
306
+ assertType ('*NEVER* ' , $ row );
307
+ } else {
308
+ assertType ('array{0: mixed, 1?: string|null} ' , $ row );
309
+ }
310
+ }
311
+
282
312
}
You can’t perform that action at this time.
0 commit comments