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

Breadcrumb

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

class UseItem

Hierarchy

  • class \PhpParser\NodeAbstract implements \PhpParser\Node, \PhpParser\JsonSerializable
    • class \PhpParser\Node\UseItem extends \PhpParser\NodeAbstract

Expanded class hierarchy of UseItem

4 files declare their use of UseItem
GroupUse.php in vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php
NodeDumper.php in vendor/nikic/php-parser/lib/PhpParser/NodeDumper.php
ParserAbstract.php in vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php
Use_.php in vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php
1 string reference to 'UseItem'
UseItem::getType in vendor/nikic/php-parser/lib/PhpParser/Node/UseItem.php
Gets the type of the node.

File

vendor/nikic/php-parser/lib/PhpParser/Node/UseItem.php, line 9

Namespace

PhpParser\Node
View source
class UseItem extends NodeAbstract {
    
    /**
     * @var Use_::TYPE_* One of the Stmt\Use_::TYPE_* constants. Will only differ from TYPE_UNKNOWN for mixed group uses
     */
    public int $type;
    
    /** @var Node\Name Namespace, class, function or constant to alias */
    public Name $name;
    
    /** @var Identifier|null Alias */
    public ?Identifier $alias;
    
    /**
     * Constructs an alias (use) item node.
     *
     * @param Node\Name $name Namespace/Class to alias
     * @param null|string|Identifier $alias Alias
     * @param Use_::TYPE_* $type Type of the use element (for mixed group use only)
     * @param array<string, mixed> $attributes Additional attributes
     */
    public function __construct(Node\Name $name, $alias = null, int $type = Use_::TYPE_UNKNOWN, array $attributes = []) {
        $this->attributes = $attributes;
        $this->type = $type;
        $this->name = $name;
        $this->alias = \is_string($alias) ? new Identifier($alias) : $alias;
    }
    public function getSubNodeNames() : array {
        return [
            'type',
            'name',
            'alias',
        ];
    }
    
    /**
     * Get alias. If not explicitly given this is the last component of the used name.
     */
    public function getAlias() : Identifier {
        if (null !== $this->alias) {
            return $this->alias;
        }
        return new Identifier($this->name
            ->getLast());
    }
    public function getType() : string {
        return 'UseItem';
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
NodeAbstract::$attributes protected property @var array&lt;string, mixed&gt; Attributes
NodeAbstract::getAttribute public function Returns the value of an attribute. Overrides Node::getAttribute
NodeAbstract::getAttributes public function Returns all the attributes of this node. Overrides Node::getAttributes
NodeAbstract::getComments public function Gets all comments directly preceding this node. Overrides Node::getComments
NodeAbstract::getDocComment public function Gets the doc comment of the node. Overrides Node::getDocComment
NodeAbstract::getEndFilePos public function Gets the file offset of the last character that is part of this node. Overrides Node::getEndFilePos
NodeAbstract::getEndLine public function Gets the line the node ended in. Overrides Node::getEndLine
NodeAbstract::getEndTokenPos public function Gets the token offset of the last token that is part of this node. Overrides Node::getEndTokenPos
NodeAbstract::getLine public function Gets line the node started in (alias of getStartLine). Overrides Node::getLine
NodeAbstract::getStartFilePos public function Gets the file offset of the first character that is part of this node. Overrides Node::getStartFilePos
NodeAbstract::getStartLine public function Gets line the node started in. Overrides Node::getStartLine
NodeAbstract::getStartTokenPos public function Gets the token offset of the first token that is part of this node. Overrides Node::getStartTokenPos
NodeAbstract::hasAttribute public function Returns whether an attribute exists. Overrides Node::hasAttribute
NodeAbstract::jsonSerialize public function
NodeAbstract::setAttribute public function Sets an attribute on a node. Overrides Node::setAttribute
NodeAbstract::setAttributes public function Replaces all the attributes of this node. Overrides Node::setAttributes
NodeAbstract::setDocComment public function Sets the doc comment of the node. Overrides Node::setDocComment
UseItem::$alias public property @var Identifier|null Alias
UseItem::$name public property @var Node\Name Namespace, class, function or constant to alias
UseItem::$type public property
UseItem::getAlias public function Get alias. If not explicitly given this is the last component of the used name.
UseItem::getSubNodeNames public function Gets the names of the sub nodes. Overrides Node::getSubNodeNames
UseItem::getType public function Gets the type of the node. Overrides Node::getType
UseItem::__construct public function Constructs an alias (use) item node. Overrides NodeAbstract::__construct

API Navigation

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