@@ -151,15 +151,7 @@ public function fromMethodReflection(\ReflectionMethod $from): Method
151
151
$ method ->setVariadic ($ from ->isVariadic ());
152
152
$ method ->setComment (Helpers::unformatDocComment ((string ) $ from ->getDocComment ()));
153
153
$ 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 ());
163
155
164
156
return $ method ;
165
157
}
@@ -176,15 +168,7 @@ public function fromFunctionReflection(\ReflectionFunction $from, bool $withBody
176
168
}
177
169
178
170
$ 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 ());
188
172
189
173
if ($ withBody ) {
190
174
if ($ from ->isClosure ()) {
@@ -213,15 +197,7 @@ public function fromParameterReflection(\ReflectionParameter $from): Parameter
213
197
? new PromotedParameter ($ from ->name )
214
198
: new Parameter ($ from ->name );
215
199
$ 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 ());
225
201
226
202
if ($ from ->isDefaultValueAvailable ()) {
227
203
if ($ from ->isDefaultValueConstant ()) {
@@ -274,15 +250,7 @@ public function fromPropertyReflection(\ReflectionProperty $from): Property
274
250
$ prop ->setValue ($ defaults [$ prop ->getName ()] ?? null );
275
251
$ prop ->setStatic ($ from ->isStatic ());
276
252
$ 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 ());
286
254
287
255
$ prop ->setInitialized ($ from ->hasType () && array_key_exists ($ prop ->getName (), $ defaults ));
288
256
$ prop ->setReadOnly (PHP_VERSION_ID >= 80100 ? $ from ->isReadOnly () : false );
0 commit comments