PhpParser\NodeAbstract::getDocComment PHP Method

getDocComment() public method

The doc comment has to be the last comment associated with the node.
public getDocComment ( ) : null | Comment\Doc
return null | Comment\Doc Doc comment object or null
    public function getDocComment()
    {
        $comments = $this->getAttribute('comments');
        if (!$comments) {
            return null;
        }
        $lastComment = $comments[count($comments) - 1];
        if (!$lastComment instanceof Comment\Doc) {
            return null;
        }
        return $lastComment;
    }