File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -39,15 +39,18 @@ public function __construct(
3939 private ParametersInterface $ parameters ,
4040 private string $ description = '' ,
4141 ) {
42- $ this ->type = $ this ->type ();
4342 if ($ parameters ->count () < 2 ) {
4443 throw new LogicException (
4544 (string ) message (
4645 'Must pass at least two parameters for union '
4746 )
4847 );
4948 }
50-
49+ $ types = array_map (
50+ fn (ParameterInterface $ parameter ): string => $ parameter ->type ()->typeHinting (),
51+ iterator_to_array ($ this ->parameters )
52+ );
53+ $ this ->type = new Type (TypeInterface::UNION , ...$ types );
5154 $ this ->parameters = $ parameters ;
5255 }
5356
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ public function testConstruct(): void
4545 bar: int ()
4646 );
4747 $ parameter = new UnionParameter ($ parameters );
48+ $ this ->assertSame ('string|int ' , $ parameter ->type ()->typeHinting ());
4849 $ this ->assertSame (
4950 TypeInterface::UNION ,
5051 $ parameter ->type ()->primitive ()
You can’t perform that action at this time.
0 commit comments