@@ -165,15 +165,21 @@ private function getFieldsByAnnotations(string $annotationName, bool $injectSour
165165
166166 $ args = $ this ->mapParameters ($ refMethod , $ docBlockObj );
167167
168- $ phpdocType = $ typeResolver ->resolve ((string ) $ refMethod ->getReturnType ());
169-
170168 if ($ queryAnnotation ->getReturnType ()) {
171169 $ type = $ this ->registry ->get ($ queryAnnotation ->getReturnType ());
172170 } else {
171+ $ phpdocType = null ;
172+ $ returnType = $ refMethod ->getReturnType ();
173+ if ($ returnType !== null ) {
174+ $ phpdocType = $ typeResolver ->resolve ((string ) $ refMethod ->getReturnType ());
175+ } else {
176+ $ phpdocType = new Mixed_ ();
177+ }
178+
173179 $ docBlockReturnType = $ this ->getDocBlocReturnType ($ docBlockObj , $ refMethod );
174180
175181 try {
176- $ type = $ this ->mapType ($ phpdocType , $ docBlockReturnType , $ refMethod -> getReturnType ()-> allowsNull (), false );
182+ $ type = $ this ->mapType ($ phpdocType , $ docBlockReturnType , $ returnType ? $ returnType -> allowsNull () : true , false );
177183 } catch (TypeMappingException $ e ) {
178184 throw TypeMappingException::wrapWithReturnInfo ($ e , $ refMethod );
179185 }
@@ -417,7 +423,7 @@ private function mapType(Type $type, ?Type $docBlockType, bool $isNullable, bool
417423 }
418424 } catch (TypeMappingException | CannotMapTypeException $ e ) {
419425 // Is the type iterable? If yes, let's analyze the docblock
420- // TODO: it would be bettrr not to go through an exception for this.
426+ // TODO: it would be better not to go through an exception for this.
421427 if ($ type instanceof Object_) {
422428 $ fqcn = (string ) $ type ->getFqsen ();
423429 $ refClass = new ReflectionClass ($ fqcn );
0 commit comments