File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -177,7 +177,10 @@ public function getTypeHint(bool $renderUnion = false): ?string
177177 if ($ renderUnion ) {
178178 $ typeHint = [];
179179 foreach ($ this ->getUnionTypes () as $ unionType ) {
180- $ typeHint [] = $ unionType ->getTypeHint ();
180+ $ unionTypeHint = $ unionType ->getTypeHint ();
181+ if (!in_array ($ unionTypeHint , $ typeHint )) {
182+ $ typeHint [] = $ unionTypeHint ;
183+ }
181184 }
182185 if ($ this ->isNullable () && !in_array ('mixed ' , $ typeHint )) {
183186 array_unshift ($ typeHint , 'null ' );
Original file line number Diff line number Diff line change @@ -353,4 +353,12 @@ public function testEnumStringValueNullableAndClass(): void
353353 $ this ->assertNull ($ type ->getTypeHint ());
354354 $ this ->assertNull ($ type ->getTypeHint (true ));
355355 }
356+
357+ public function testDontDoubleRenderUnionTypes (): void
358+ {
359+ $ type = Type::fromString ('array<int> ' );
360+ $ type ->addUnion ('array<string> ' );
361+
362+ $ this ->assertSame ('array ' , $ type ->getTypeHint (true ));
363+ }
356364}
You can’t perform that action at this time.
0 commit comments