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

Breadcrumb

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

class ArrowFunction

Hierarchy

  • class \PhpParser\NodeAbstract implements \PhpParser\Node, \PhpParser\JsonSerializable
    • class \PhpParser\Node\Expr extends \PhpParser\NodeAbstract
      • class \PhpParser\Node\Expr\ArrowFunction extends \PhpParser\Node\Expr implements \PhpParser\Node\FunctionLike

Expanded class hierarchy of ArrowFunction

File

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

Namespace

PhpParser\Node\Expr
View source
class ArrowFunction extends Expr implements FunctionLike {
    
    /** @var bool Whether the closure is static */
    public bool $static;
    
    /** @var bool Whether to return by reference */
    public bool $byRef;
    
    /** @var Node\Param[] */
    public array $params = [];
    
    /** @var null|Node\Identifier|Node\Name|Node\ComplexType */
    public ?Node $returnType;
    
    /** @var Expr Expression body */
    public Expr $expr;
    
    /** @var Node\AttributeGroup[] */
    public array $attrGroups;
    
    /**
     * @param array{
     *     expr: Expr,
     *     static?: bool,
     *     byRef?: bool,
     *     params?: Node\Param[],
     *     returnType?: null|Node\Identifier|Node\Name|Node\ComplexType,
     *     attrGroups?: Node\AttributeGroup[]
     * } $subNodes Array of the following subnodes:
     *             'expr'                  : Expression body
     *             'static'     => false   : Whether the closure is static
     *             'byRef'      => false   : Whether to return by reference
     *             'params'     => array() : Parameters
     *             'returnType' => null    : Return type
     *             'attrGroups' => array() : PHP attribute groups
     * @param array<string, mixed> $attributes Additional attributes
     */
    public function __construct(array $subNodes, array $attributes = []) {
        $this->attributes = $attributes;
        $this->static = $subNodes['static'] ?? false;
        $this->byRef = $subNodes['byRef'] ?? false;
        $this->params = $subNodes['params'] ?? [];
        $this->returnType = $subNodes['returnType'] ?? null;
        $this->expr = $subNodes['expr'];
        $this->attrGroups = $subNodes['attrGroups'] ?? [];
    }
    public function getSubNodeNames() : array {
        return [
            'attrGroups',
            'static',
            'byRef',
            'params',
            'returnType',
            'expr',
        ];
    }
    public function returnsByRef() : bool {
        return $this->byRef;
    }
    public function getParams() : array {
        return $this->params;
    }
    public function getReturnType() {
        return $this->returnType;
    }
    public function getAttrGroups() : array {
        return $this->attrGroups;
    }
    
    /**
     * @return Node\Stmt\Return_[]
     */
    public function getStmts() : array {
        return [
            new Node\Stmt\Return_($this->expr),
        ];
    }
    public function getType() : string {
        return 'Expr_ArrowFunction';
    }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title Overrides
ArrowFunction::$attrGroups public property @var Node\AttributeGroup[]
ArrowFunction::$byRef public property @var bool Whether to return by reference
ArrowFunction::$expr public property @var Expr Expression body
ArrowFunction::$params public property @var Node\Param[]
ArrowFunction::$returnType public property @var null|Node\Identifier|Node\Name|Node\ComplexType
ArrowFunction::$static public property @var bool Whether the closure is static
ArrowFunction::getAttrGroups public function Get PHP attribute groups. Overrides FunctionLike::getAttrGroups
ArrowFunction::getParams public function List of parameters Overrides FunctionLike::getParams
ArrowFunction::getReturnType public function Get the declared return type or null Overrides FunctionLike::getReturnType
ArrowFunction::getStmts public function Overrides FunctionLike::getStmts
ArrowFunction::getSubNodeNames public function Gets the names of the sub nodes. Overrides Node::getSubNodeNames
ArrowFunction::getType public function Gets the type of the node. Overrides Node::getType
ArrowFunction::returnsByRef public function Whether to return by reference Overrides FunctionLike::returnsByRef
ArrowFunction::__construct public function
Node::getAttribute public function Returns the value of an attribute. 1
Node::getAttributes public function Returns all the attributes of this node. 1
Node::getComments public function Gets all comments directly preceding this node. 1
Node::getDocComment public function Gets the doc comment of the node. 1
Node::getEndFilePos public function Gets the file offset of the last character that is part of this node. 1
Node::getEndLine public function Gets the line the node ended in. 1
Node::getEndTokenPos public function Gets the token offset of the last token that is part of this node. 1
Node::getLine Deprecated public function Gets line the node started in (alias of getStartLine). 1
Node::getStartFilePos public function Gets the file offset of the first character that is part of this node. 1
Node::getStartLine public function Gets line the node started in. 1
Node::getStartTokenPos public function Gets the token offset of the first token that is part of this node. 1
Node::hasAttribute public function Returns whether an attribute exists. 1
Node::setAttribute public function Sets an attribute on a node. 1
Node::setAttributes public function Replaces all the attributes of this node. 1
Node::setDocComment public function Sets the doc comment of the node. 1

API Navigation

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