src/PhpParser/Node/Manipulator/FunctionLikeManipulator.php
public function resolveStaticReturnTypeInfo(FunctionLike $functionLike): ?ReturnTypeInfo
    {
        if ($this->shouldSkip($functionLike)) {
            return null;
        }

        /** @var Return_[] $returnNodes */
        $returnNodes = $this->betterNodeFinder->findInstanceOf((array) $functionLike->stmts, Return_::class);

        $isVoid = true;

        $types = [];
        foreach ($returnNodes as $returnNode) {
            if ($returnNode->expr === null) {
                continue;
            }

            $types = array_merge($types, $this->nodeTypeResolver->resolveSingleTypeToStrings($returnNode->expr));
            $isVoid = false;
        }

        if ($isVoid) {
            return new ReturnTypeInfo(['void'], $this->typeAnalyzer);
        }

        $types = array_filter($types);

        return new ReturnTypeInfo($types, $this->typeAnalyzer);
    }
public function resolveStaticReturnTypeInfo(FunctionLike $functionLike): ?ReturnTypeInfo
    {
        if ($this->shouldSkip($functionLike)) {
            return null;
        }

        /** @var Return_[] $returnNodes */
        $returnNodes = $this->betterNodeFinder->findInstanceOf((array) $functionLike->stmts, Return_::class);

        $isVoid = true;

        $types = [];
        foreach ($returnNodes as $returnNode) {
            if ($returnNode->expr === null) {
                continue;
            }

            $types = array_merge($types, $this->nodeTypeResolver->resolveSingleTypeToStrings($returnNode->expr));
            $isVoid = false;
        }

        if ($isVoid) {
            return new ReturnTypeInfo(['void'], $this->typeAnalyzer);
        }

        $types = array_filter($types);

        return new ReturnTypeInfo($types, $this->typeAnalyzer);
    }
public function resolveStaticReturnTypeInfo ( FunctionLike $ functionLike ) : ? ReturnTypeInfo { if ( $ this -> shouldSkip ( $ functionLike ) ) { return null ; } /** @var Return_[] $returnNodes */ $ returnNodes = $ this -> betterNodeFinder -> findInstanceOf ( ( array ) $ functionLike -> stmts , Return_ :: class ) ; $ isVoid = true ; $ types = [ ] ; foreach ( $ returnNodes as $ returnNode ) { if ( $ returnNode -> expr === null ) { continue ; } $ types = array_merge ( $ types , $ this -> nodeTypeResolver -> resolveSingleTypeToStrings ( $ returnNode -> expr ) ) ; $ isVoid = false ; } if ( $ isVoid ) { return new ReturnTypeInfo ( [ 'void' ] , $ this -> typeAnalyzer ) ; } $ types = array_filter ( $ types ) ; return new ReturnTypeInfo ( $ types , $ this -> typeAnalyzer ) ; }
Based on static analysis of code, looking for return types
@param ClassMethod|Function_ $functionLike
Based on static analysis of code looking for return types