@@ -151,15 +151,7 @@ public function fromMethodReflection(\ReflectionMethod $from): Method
151151 $ method ->setVariadic ($ from ->isVariadic ());
152152 $ method ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
153153 $ method ->setAttributes (self ::getAttributes ($ from ));
154- if ($ from ->getReturnType () instanceof \ReflectionNamedType) {
155- $ method ->setReturnType ($ from ->getReturnType ()->getName ());
156- $ method ->setReturnNullable ($ from ->getReturnType ()->allowsNull ());
157- } elseif (
158- $ from ->getReturnType () instanceof \ReflectionUnionType
159- || $ from ->getReturnType () instanceof \ReflectionIntersectionType
160- ) {
161- $ method ->setReturnType ((string ) $ from ->getReturnType ());
162- }
154+ $ method ->setReturnType ((string ) $ from ->getReturnType ());
163155
164156 return $ method ;
165157 }
@@ -176,15 +168,7 @@ public function fromFunctionReflection(\ReflectionFunction $from, bool $withBody
176168 }
177169
178170 $ function ->setAttributes (self ::getAttributes ($ from ));
179- if ($ from ->getReturnType () instanceof \ReflectionNamedType) {
180- $ function ->setReturnType ($ from ->getReturnType ()->getName ());
181- $ function ->setReturnNullable ($ from ->getReturnType ()->allowsNull ());
182- } elseif (
183- $ from ->getReturnType () instanceof \ReflectionUnionType
184- || $ from ->getReturnType () instanceof \ReflectionIntersectionType
185- ) {
186- $ function ->setReturnType ((string ) $ from ->getReturnType ());
187- }
171+ $ function ->setReturnType ((string ) $ from ->getReturnType ());
188172
189173 if ($ withBody ) {
190174 if ($ from ->isClosure ()) {
@@ -213,15 +197,7 @@ public function fromParameterReflection(\ReflectionParameter $from): Parameter
213197 ? new PromotedParameter ($ from ->name )
214198 : new Parameter ($ from ->name );
215199 $ param ->setReference ($ from ->isPassedByReference ());
216- if ($ from ->getType () instanceof \ReflectionNamedType) {
217- $ param ->setType ($ from ->getType ()->getName ());
218- $ param ->setNullable ($ from ->getType ()->allowsNull ());
219- } elseif (
220- $ from ->getType () instanceof \ReflectionUnionType
221- || $ from ->getType () instanceof \ReflectionIntersectionType
222- ) {
223- $ param ->setType ((string ) $ from ->getType ());
224- }
200+ $ param ->setType ((string ) $ from ->getType ());
225201
226202 if ($ from ->isDefaultValueAvailable ()) {
227203 if ($ from ->isDefaultValueConstant ()) {
@@ -274,15 +250,7 @@ public function fromPropertyReflection(\ReflectionProperty $from): Property
274250 $ prop ->setValue ($ defaults [$ prop ->getName ()] ?? null );
275251 $ prop ->setStatic ($ from ->isStatic ());
276252 $ prop ->setVisibility ($ this ->getVisibility ($ from ));
277- if ($ from ->getType () instanceof \ReflectionNamedType) {
278- $ prop ->setType ($ from ->getType ()->getName ());
279- $ prop ->setNullable ($ from ->getType ()->allowsNull ());
280- } elseif (
281- $ from ->getType () instanceof \ReflectionUnionType
282- || $ from ->getType () instanceof \ReflectionIntersectionType
283- ) {
284- $ prop ->setType ((string ) $ from ->getType ());
285- }
253+ $ prop ->setType ((string ) $ from ->getType ());
286254
287255 $ prop ->setInitialized ($ from ->hasType () && array_key_exists ($ prop ->getName (), $ defaults ));
288256 $ prop ->setReadOnly (PHP_VERSION_ID >= 80100 ? $ from ->isReadOnly () : false );
0 commit comments