@@ -43,10 +43,7 @@ public function load(string $className, array $options = [], array $context = []
4343
4444 foreach ($ result as &$ metadata ) {
4545 $ type = $ metadata ->getType ();
46-
47- if (isset ($ variableTypes [(string ) $ type ])) {
48- $ metadata = $ metadata ->withType ($ this ->replaceVariableTypes ($ type , $ variableTypes ));
49- }
46+ $ metadata = $ metadata ->withType ($ this ->replaceVariableTypes ($ type , $ variableTypes ));
5047 }
5148
5249 return $ result ;
@@ -122,19 +119,19 @@ private function replaceVariableTypes(Type $type, array $variableTypes): Type
122119 }
123120
124121 if ($ type instanceof UnionType) {
125- return new UnionType (...array_map (fn (Type $ t ): Type => $ this ->replaceVariableTypes ($ t , $ variableTypes ), $ type ->getTypes ()));
122+ return Type:: union (...array_map (fn (Type $ t ): Type => $ this ->replaceVariableTypes ($ t , $ variableTypes ), $ type ->getTypes ()));
126123 }
127124
128125 if ($ type instanceof IntersectionType) {
129- return new IntersectionType (...array_map (fn (Type $ t ): Type => $ this ->replaceVariableTypes ($ t , $ variableTypes ), $ type ->getTypes ()));
126+ return Type:: intersection (...array_map (fn (Type $ t ): Type => $ this ->replaceVariableTypes ($ t , $ variableTypes ), $ type ->getTypes ()));
130127 }
131128
132129 if ($ type instanceof CollectionType) {
133130 return new CollectionType ($ this ->replaceVariableTypes ($ type ->getWrappedType (), $ variableTypes ), $ type ->isList ());
134131 }
135132
136133 if ($ type instanceof GenericType) {
137- return new GenericType (
134+ return Type:: generic (
138135 $ this ->replaceVariableTypes ($ type ->getWrappedType (), $ variableTypes ),
139136 ...array_map (fn (Type $ t ): Type => $ this ->replaceVariableTypes ($ t , $ variableTypes ), $ type ->getVariableTypes ()),
140137 );
0 commit comments