File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
src/TypeSystem/Type/UnionType Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,6 @@ final class UnionType implements TypeInterface
3232 private array $ members ;
3333
3434 private function __construct (TypeInterface ...$ members )
35- {
36- $ this ->members = $ members ;
37- }
38-
39- public static function of (TypeInterface ...$ members ): TypeInterface
4035 {
4136 $ uniqueMembers = [];
4237 foreach ($ members as $ member ) {
@@ -48,9 +43,15 @@ public static function of(TypeInterface ...$members): TypeInterface
4843
4944 $ uniqueMembers [] = $ member ;
5045 }
46+ $ this ->members = $ uniqueMembers ;
47+ }
48+
49+ public static function of (TypeInterface ...$ members ): TypeInterface
50+ {
51+ $ union = new self (...$ members );
5152
52- if (count ($ uniqueMembers ) === 1 ) {
53- return $ uniqueMembers [0 ];
53+ if (count ($ union -> members ) === 1 ) {
54+ return $ union -> members [0 ];
5455 }
5556
5657 return new self (...$ members );
You can’t perform that action at this time.
0 commit comments