src/DefinitionResolver.php
public function getDocumentationFromNode($node)
    {
        // Any NamespaceDefinition comments likely apply to the file, not the declaration itself.
        if ($node instanceof Node\Statement\NamespaceDefinition) {
            return null;
        }

        // For properties and constants, set the node to the declaration node, rather than the individual property.
        // This is because they get defined as part of a list.
        $constOrPropertyDeclaration = ParserHelpers\tryGetPropertyDeclaration($node) ?? ParserHelpers\tryGetConstOrClassConstDeclaration($node);
        if ($constOrPropertyDeclaration !== null) {
            $node = $constOrPropertyDeclaration;
        }

        // For parameters, parse the function-like declaration to get documentation for a parameter
        if ($node instanceof Node\Parameter) {
            $variableName = $node->getName();

            $functionLikeDeclaration = ParserHelpers\getFunctionLikeDeclarationFromParameter($node);
            $docBlock = $this->getDocBlock($functionLikeDeclaration);

            $parameterDocBlockTag = $this->tryGetDocBlockTagForParameter($docBlock, $variableName);
            return $parameterDocBlockTag !== null ? $parameterDocBlockTag->getDescription()->render() : null;
        }

        // For everything else, get the doc block summary corresponding to the current node.
        $docBlock = $this->getDocBlock($node);
        if ($docBlock !== null) {
            // check whether we have a description, when true, add a new paragraph
            // with the description
            $description = $docBlock->getDescription()->render();

            if (empty($description)) {
                return $docBlock->getSummary();
            }

            return $docBlock->getSummary() . "\n\n" . $description;
        }
        return null;
    }
public function getDocumentationFromNode($node)
    {
        // Any NamespaceDefinition comments likely apply to the file, not the declaration itself.
        if ($node instanceof Node\Statement\NamespaceDefinition) {
            return null;
        }

        // For properties and constants, set the node to the declaration node, rather than the individual property.
        // This is because they get defined as part of a list.
        $constOrPropertyDeclaration = ParserHelpers\tryGetPropertyDeclaration($node) ?? ParserHelpers\tryGetConstOrClassConstDeclaration($node);
        if ($constOrPropertyDeclaration !== null) {
            $node = $constOrPropertyDeclaration;
        }

        // For parameters, parse the function-like declaration to get documentation for a parameter
        if ($node instanceof Node\Parameter) {
            $variableName = $node->getName();

            $functionLikeDeclaration = ParserHelpers\getFunctionLikeDeclarationFromParameter($node);
            $docBlock = $this->getDocBlock($functionLikeDeclaration);

            $parameterDocBlockTag = $this->tryGetDocBlockTagForParameter($docBlock, $variableName);
            return $parameterDocBlockTag !== null ? $parameterDocBlockTag->getDescription()->render() : null;
        }

        // For everything else, get the doc block summary corresponding to the current node.
        $docBlock = $this->getDocBlock($node);
        if ($docBlock !== null) {
            // check whether we have a description, when true, add a new paragraph
            // with the description
            $description = $docBlock->getDescription()->render();

            if (empty($description)) {
                return $docBlock->getSummary();
            }

            return $docBlock->getSummary() . "\n\n" . $description;
        }
        return null;
    }
public function getDocumentationFromNode ( $ node ) { // Any NamespaceDefinition comments likely apply to the file, not the declaration itself. if ( $ node instanceof Node \ Statement \ NamespaceDefinition ) { return null ; } // For properties and constants, set the node to the declaration node, rather than the individual property. // This is because they get defined as part of a list. $ constOrPropertyDeclaration = ParserHelpers \ tryGetPropertyDeclaration ( $ node ) ?? ParserHelpers \ tryGetConstOrClassConstDeclaration ( $ node ) ; if ( $ constOrPropertyDeclaration !== null ) { $ node = $ constOrPropertyDeclaration ; } // For parameters, parse the function-like declaration to get documentation for a parameter if ( $ node instanceof Node \ Parameter ) { $ variableName = $ node -> getName ( ) ; $ functionLikeDeclaration = ParserHelpers \ getFunctionLikeDeclarationFromParameter ( $ node ) ; $ docBlock = $ this -> getDocBlock ( $ functionLikeDeclaration ) ; $ parameterDocBlockTag = $ this -> tryGetDocBlockTagForParameter ( $ docBlock , $ variableName ) ; return $ parameterDocBlockTag !== null ? $ parameterDocBlockTag -> getDescription ( ) -> render ( ) : null ; } // For everything else, get the doc block summary corresponding to the current node. $ docBlock = $ this -> getDocBlock ( $ node ) ; if ( $ docBlock !== null ) { // check whether we have a description, when true, add a new paragraph // with the description $ description = $ docBlock -> getDescription ( ) -> render ( ) ; if ( empty ( $ description ) ) { return $ docBlock -> getSummary ( ) ; } return $ docBlock -> getSummary ( ) . "\n\n" . $ description ; } return null ; }
Gets the documentation string for a node, if it has one

@param Node $node
@return string|null
Gets the documentation string for a node if it has one