@@ -314,30 +314,33 @@ private function getReturnType(): Type
314
314
{
315
315
if ($ this ->returnType === null ) {
316
316
$ name = strtolower ($ this ->getName ());
317
- if (
318
- $ name === '__construct '
319
- || $ name === '__destruct '
320
- || $ name === '__unset '
321
- || $ name === '__wakeup '
322
- || $ name === '__clone '
323
- ) {
324
- return $ this ->returnType = TypehintHelper::decideType (new VoidType (), $ this ->phpDocReturnType );
325
- }
326
- if ($ name === '__tostring ' ) {
327
- return $ this ->returnType = TypehintHelper::decideType (new StringType (), $ this ->phpDocReturnType );
328
- }
329
- if ($ name === '__isset ' ) {
330
- return $ this ->returnType = TypehintHelper::decideType (new BooleanType (), $ this ->phpDocReturnType );
331
- }
332
- if ($ name === '__sleep ' ) {
333
- return $ this ->returnType = TypehintHelper::decideType (new ArrayType (new IntegerType (), new StringType ()), $ this ->phpDocReturnType );
334
- }
335
- if ($ name === '__set_state ' ) {
336
- return $ this ->returnType = TypehintHelper::decideType (new ObjectWithoutClassType (), $ this ->phpDocReturnType );
317
+ $ returnType = $ this ->reflection ->getReturnType ();
318
+ if ($ returnType === null ) {
319
+ if (
320
+ $ name === '__construct '
321
+ || $ name === '__destruct '
322
+ || $ name === '__unset '
323
+ || $ name === '__wakeup '
324
+ || $ name === '__clone '
325
+ ) {
326
+ return $ this ->returnType = TypehintHelper::decideType (new VoidType (), $ this ->phpDocReturnType );
327
+ }
328
+ if ($ name === '__tostring ' ) {
329
+ return $ this ->returnType = TypehintHelper::decideType (new StringType (), $ this ->phpDocReturnType );
330
+ }
331
+ if ($ name === '__isset ' ) {
332
+ return $ this ->returnType = TypehintHelper::decideType (new BooleanType (), $ this ->phpDocReturnType );
333
+ }
334
+ if ($ name === '__sleep ' ) {
335
+ return $ this ->returnType = TypehintHelper::decideType (new ArrayType (new IntegerType (), new StringType ()), $ this ->phpDocReturnType );
336
+ }
337
+ if ($ name === '__set_state ' ) {
338
+ return $ this ->returnType = TypehintHelper::decideType (new ObjectWithoutClassType (), $ this ->phpDocReturnType );
339
+ }
337
340
}
338
341
339
342
$ this ->returnType = TypehintHelper::decideTypeFromReflection (
340
- $ this -> reflection -> getReturnType () ,
343
+ $ returnType ,
341
344
$ this ->phpDocReturnType ,
342
345
$ this ->declaringClass ->getName (),
343
346
);
0 commit comments