Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PhpDocNode.php

class PhpDocNode

Hierarchy

  • class \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode implements \PHPStan\PhpDocParser\Ast\Node uses \PHPStan\PhpDocParser\Ast\NodeAttributes

Expanded class hierarchy of PhpDocNode

3 files declare their use of PhpDocNode
AnnotationHelper.php in vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationHelper.php
ParsedDocComment.php in vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/ParsedDocComment.php
Printer.php in vendor/phpstan/phpdoc-parser/src/Printer/Printer.php

File

vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocNode.php, line 12

Namespace

PHPStan\PhpDocParser\Ast\PhpDoc
View source
class PhpDocNode implements Node {
    use NodeAttributes;
    
    /** @var PhpDocChildNode[] */
    public $children;
    
    /**
     * @param PhpDocChildNode[] $children
     */
    public function __construct(array $children) {
        $this->children = $children;
    }
    
    /**
     * @return PhpDocTagNode[]
     */
    public function getTags() : array {
        return array_filter($this->children, static function (PhpDocChildNode $child) : bool {
            return $child instanceof PhpDocTagNode;
        });
    }
    
    /**
     * @return PhpDocTagNode[]
     */
    public function getTagsByName(string $tagName) : array {
        return array_filter($this->getTags(), static function (PhpDocTagNode $tag) use ($tagName) : bool {
            return $tag->name === $tagName;
        });
    }
    
    /**
     * @return VarTagValueNode[]
     */
    public function getVarTagValues(string $tagName = '@var') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof VarTagValueNode;
        });
    }
    
    /**
     * @return ParamTagValueNode[]
     */
    public function getParamTagValues(string $tagName = '@param') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof ParamTagValueNode;
        });
    }
    
    /**
     * @return TypelessParamTagValueNode[]
     */
    public function getTypelessParamTagValues(string $tagName = '@param') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof TypelessParamTagValueNode;
        });
    }
    
    /**
     * @return ParamImmediatelyInvokedCallableTagValueNode[]
     */
    public function getParamImmediatelyInvokedCallableTagValues(string $tagName = '@param-immediately-invoked-callable') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof ParamImmediatelyInvokedCallableTagValueNode;
        });
    }
    
    /**
     * @return ParamLaterInvokedCallableTagValueNode[]
     */
    public function getParamLaterInvokedCallableTagValues(string $tagName = '@param-later-invoked-callable') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof ParamLaterInvokedCallableTagValueNode;
        });
    }
    
    /**
     * @return ParamClosureThisTagValueNode[]
     */
    public function getParamClosureThisTagValues(string $tagName = '@param-closure-this') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof ParamClosureThisTagValueNode;
        });
    }
    
    /**
     * @return PureUnlessCallableIsImpureTagValueNode[]
     */
    public function getPureUnlessCallableIsImpureTagValues(string $tagName = '@pure-unless-callable-is-impure') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof PureUnlessCallableIsImpureTagValueNode;
        });
    }
    
    /**
     * @return TemplateTagValueNode[]
     */
    public function getTemplateTagValues(string $tagName = '@template') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof TemplateTagValueNode;
        });
    }
    
    /**
     * @return ExtendsTagValueNode[]
     */
    public function getExtendsTagValues(string $tagName = '@extends') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof ExtendsTagValueNode;
        });
    }
    
    /**
     * @return ImplementsTagValueNode[]
     */
    public function getImplementsTagValues(string $tagName = '@implements') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof ImplementsTagValueNode;
        });
    }
    
    /**
     * @return UsesTagValueNode[]
     */
    public function getUsesTagValues(string $tagName = '@use') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof UsesTagValueNode;
        });
    }
    
    /**
     * @return ReturnTagValueNode[]
     */
    public function getReturnTagValues(string $tagName = '@return') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof ReturnTagValueNode;
        });
    }
    
    /**
     * @return ThrowsTagValueNode[]
     */
    public function getThrowsTagValues(string $tagName = '@throws') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof ThrowsTagValueNode;
        });
    }
    
    /**
     * @return MixinTagValueNode[]
     */
    public function getMixinTagValues(string $tagName = '@mixin') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof MixinTagValueNode;
        });
    }
    
    /**
     * @return RequireExtendsTagValueNode[]
     */
    public function getRequireExtendsTagValues(string $tagName = '@phpstan-require-extends') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof RequireExtendsTagValueNode;
        });
    }
    
    /**
     * @return RequireImplementsTagValueNode[]
     */
    public function getRequireImplementsTagValues(string $tagName = '@phpstan-require-implements') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof RequireImplementsTagValueNode;
        });
    }
    
    /**
     * @return DeprecatedTagValueNode[]
     */
    public function getDeprecatedTagValues() : array {
        return array_filter(array_column($this->getTagsByName('@deprecated'), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof DeprecatedTagValueNode;
        });
    }
    
    /**
     * @return PropertyTagValueNode[]
     */
    public function getPropertyTagValues(string $tagName = '@property') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof PropertyTagValueNode;
        });
    }
    
    /**
     * @return PropertyTagValueNode[]
     */
    public function getPropertyReadTagValues(string $tagName = '@property-read') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof PropertyTagValueNode;
        });
    }
    
    /**
     * @return PropertyTagValueNode[]
     */
    public function getPropertyWriteTagValues(string $tagName = '@property-write') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof PropertyTagValueNode;
        });
    }
    
    /**
     * @return MethodTagValueNode[]
     */
    public function getMethodTagValues(string $tagName = '@method') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof MethodTagValueNode;
        });
    }
    
    /**
     * @return TypeAliasTagValueNode[]
     */
    public function getTypeAliasTagValues(string $tagName = '@phpstan-type') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof TypeAliasTagValueNode;
        });
    }
    
    /**
     * @return TypeAliasImportTagValueNode[]
     */
    public function getTypeAliasImportTagValues(string $tagName = '@phpstan-import-type') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof TypeAliasImportTagValueNode;
        });
    }
    
    /**
     * @return AssertTagValueNode[]
     */
    public function getAssertTagValues(string $tagName = '@phpstan-assert') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof AssertTagValueNode;
        });
    }
    
    /**
     * @return AssertTagPropertyValueNode[]
     */
    public function getAssertPropertyTagValues(string $tagName = '@phpstan-assert') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof AssertTagPropertyValueNode;
        });
    }
    
    /**
     * @return AssertTagMethodValueNode[]
     */
    public function getAssertMethodTagValues(string $tagName = '@phpstan-assert') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof AssertTagMethodValueNode;
        });
    }
    
    /**
     * @return SelfOutTagValueNode[]
     */
    public function getSelfOutTypeTagValues(string $tagName = '@phpstan-this-out') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof SelfOutTagValueNode;
        });
    }
    
    /**
     * @return ParamOutTagValueNode[]
     */
    public function getParamOutTypeTagValues(string $tagName = '@param-out') : array {
        return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (PhpDocTagValueNode $value) : bool {
            return $value instanceof ParamOutTagValueNode;
        });
    }
    public function __toString() : string {
        $children = array_map(static function (PhpDocChildNode $child) : string {
            $s = (string) $child;
            return $s === '' ? '' : ' ' . $s;
        }, $this->children);
        return "/**\n *" . implode("\n *", $children) . "\n */";
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
NodeAttributes::$attributes private property @var array<string, mixed>
NodeAttributes::getAttribute public function *
NodeAttributes::hasAttribute public function
NodeAttributes::setAttribute public function *
PhpDocNode::$children public property @var PhpDocChildNode[]
PhpDocNode::getAssertMethodTagValues public function *
PhpDocNode::getAssertPropertyTagValues public function *
PhpDocNode::getAssertTagValues public function *
PhpDocNode::getDeprecatedTagValues public function *
PhpDocNode::getExtendsTagValues public function *
PhpDocNode::getImplementsTagValues public function *
PhpDocNode::getMethodTagValues public function *
PhpDocNode::getMixinTagValues public function *
PhpDocNode::getParamClosureThisTagValues public function *
PhpDocNode::getParamImmediatelyInvokedCallableTagValues public function *
PhpDocNode::getParamLaterInvokedCallableTagValues public function *
PhpDocNode::getParamOutTypeTagValues public function *
PhpDocNode::getParamTagValues public function *
PhpDocNode::getPropertyReadTagValues public function *
PhpDocNode::getPropertyTagValues public function *
PhpDocNode::getPropertyWriteTagValues public function *
PhpDocNode::getPureUnlessCallableIsImpureTagValues public function *
PhpDocNode::getRequireExtendsTagValues public function *
PhpDocNode::getRequireImplementsTagValues public function *
PhpDocNode::getReturnTagValues public function *
PhpDocNode::getSelfOutTypeTagValues public function *
PhpDocNode::getTags public function *
PhpDocNode::getTagsByName public function *
PhpDocNode::getTemplateTagValues public function *
PhpDocNode::getThrowsTagValues public function *
PhpDocNode::getTypeAliasImportTagValues public function *
PhpDocNode::getTypeAliasTagValues public function *
PhpDocNode::getTypelessParamTagValues public function *
PhpDocNode::getUsesTagValues public function *
PhpDocNode::getVarTagValues public function *
PhpDocNode::__construct public function *
PhpDocNode::__toString public function Overrides Node::__toString

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal