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

Breadcrumb

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

class ClassMethod

Same name in this branch
  1. 11.1.x vendor/phpunit/phpunit/src/Event/Value/ClassMethod.php \PHPUnit\Event\Code\ClassMethod

Hierarchy

  • class \PhpParser\Node\Stmt\ClassMethod extends \Node\Stmt implements \PhpParser\Node\FunctionLike

Expanded class hierarchy of ClassMethod

6 files declare their use of ClassMethod
CodeUnitFindingVisitor.php in vendor/phpunit/php-code-coverage/src/StaticAnalysis/CodeUnitFindingVisitor.php
ComplexityCalculatingVisitor.php in vendor/sebastian/complexity/src/Visitor/ComplexityCalculatingVisitor.php
DataProviderHelper.php in vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/DataProviderHelper.php
IgnoredLinesFindingVisitor.php in vendor/phpunit/php-code-coverage/src/StaticAnalysis/IgnoredLinesFindingVisitor.php
ParserAbstract.php in vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php

... See full list

File

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

Namespace

PhpParser\Node\Stmt
View source
class ClassMethod extends Node\Stmt implements FunctionLike {
    
    /** @var int Flags */
    public int $flags;
    
    /** @var bool Whether to return by reference */
    public bool $byRef;
    
    /** @var Node\Identifier Name */
    public Node\Identifier $name;
    
    /** @var Node\Param[] Parameters */
    public array $params;
    
    /** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */
    public ?Node $returnType;
    
    /** @var Node\Stmt[]|null Statements */
    public ?array $stmts;
    
    /** @var Node\AttributeGroup[] PHP attribute groups */
    public array $attrGroups;
    
    /** @var array<string, bool> */
    private static array $magicNames = [
        '__construct' => true,
        '__destruct' => true,
        '__call' => true,
        '__callstatic' => true,
        '__get' => true,
        '__set' => true,
        '__isset' => true,
        '__unset' => true,
        '__sleep' => true,
        '__wakeup' => true,
        '__tostring' => true,
        '__set_state' => true,
        '__clone' => true,
        '__invoke' => true,
        '__debuginfo' => true,
        '__serialize' => true,
        '__unserialize' => true,
    ];
    
    /**
     * Constructs a class method node.
     *
     * @param string|Node\Identifier $name Name
     * @param array{
     *     flags?: int,
     *     byRef?: bool,
     *     params?: Node\Param[],
     *     returnType?: null|Node\Identifier|Node\Name|Node\ComplexType,
     *     stmts?: Node\Stmt[]|null,
     *     attrGroups?: Node\AttributeGroup[],
     * } $subNodes Array of the following optional subnodes:
     *             'flags       => 0              : Flags
     *             'byRef'      => false          : Whether to return by reference
     *             'params'     => array()        : Parameters
     *             'returnType' => null           : Return type
     *             'stmts'      => array()        : Statements
     *             'attrGroups' => array()        : PHP attribute groups
     * @param array<string, mixed> $attributes Additional attributes
     */
    public function __construct($name, array $subNodes = [], array $attributes = []) {
        $this->attributes = $attributes;
        $this->flags = $subNodes['flags'] ?? $subNodes['type'] ?? 0;
        $this->byRef = $subNodes['byRef'] ?? false;
        $this->name = \is_string($name) ? new Node\Identifier($name) : $name;
        $this->params = $subNodes['params'] ?? [];
        $this->returnType = $subNodes['returnType'] ?? null;
        $this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : [];
        $this->attrGroups = $subNodes['attrGroups'] ?? [];
    }
    public function getSubNodeNames() : array {
        return [
            'attrGroups',
            'flags',
            'byRef',
            'name',
            'params',
            'returnType',
            'stmts',
        ];
    }
    public function returnsByRef() : bool {
        return $this->byRef;
    }
    public function getParams() : array {
        return $this->params;
    }
    public function getReturnType() {
        return $this->returnType;
    }
    public function getStmts() : ?array {
        return $this->stmts;
    }
    public function getAttrGroups() : array {
        return $this->attrGroups;
    }
    
    /**
     * Whether the method is explicitly or implicitly public.
     */
    public function isPublic() : bool {
        return ($this->flags & Modifiers::PUBLIC) !== 0 || ($this->flags & Modifiers::VISIBILITY_MASK) === 0;
    }
    
    /**
     * Whether the method is protected.
     */
    public function isProtected() : bool {
        return (bool) ($this->flags & Modifiers::PROTECTED);
    }
    
    /**
     * Whether the method is private.
     */
    public function isPrivate() : bool {
        return (bool) ($this->flags & Modifiers::PRIVATE);
    }
    
    /**
     * Whether the method is abstract.
     */
    public function isAbstract() : bool {
        return (bool) ($this->flags & Modifiers::ABSTRACT);
    }
    
    /**
     * Whether the method is final.
     */
    public function isFinal() : bool {
        return (bool) ($this->flags & Modifiers::FINAL);
    }
    
    /**
     * Whether the method is static.
     */
    public function isStatic() : bool {
        return (bool) ($this->flags & Modifiers::STATIC);
    }
    
    /**
     * Whether the method is magic.
     */
    public function isMagic() : bool {
        return isset(self::$magicNames[$this->name
            ->toLowerString()]);
    }
    public function getType() : string {
        return 'Stmt_ClassMethod';
    }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title Overrides
ClassMethod::$attrGroups public property @var Node\AttributeGroup[] PHP attribute groups
ClassMethod::$byRef public property @var bool Whether to return by reference
ClassMethod::$flags public property @var int Flags
ClassMethod::$magicNames private static property @var array&lt;string, bool&gt;
ClassMethod::$name public property @var Node\Identifier Name
ClassMethod::$params public property @var Node\Param[] Parameters
ClassMethod::$returnType public property @var null|Node\Identifier|Node\Name|Node\ComplexType Return type
ClassMethod::$stmts public property @var Node\Stmt[]|null Statements
ClassMethod::getAttrGroups public function Get PHP attribute groups. Overrides FunctionLike::getAttrGroups
ClassMethod::getParams public function List of parameters Overrides FunctionLike::getParams
ClassMethod::getReturnType public function Get the declared return type or null Overrides FunctionLike::getReturnType
ClassMethod::getStmts public function The function body Overrides FunctionLike::getStmts
ClassMethod::getSubNodeNames public function Gets the names of the sub nodes. Overrides Node::getSubNodeNames
ClassMethod::getType public function Gets the type of the node. Overrides Node::getType
ClassMethod::isAbstract public function Whether the method is abstract.
ClassMethod::isFinal public function Whether the method is final.
ClassMethod::isMagic public function Whether the method is magic.
ClassMethod::isPrivate public function Whether the method is private.
ClassMethod::isProtected public function Whether the method is protected.
ClassMethod::isPublic public function Whether the method is explicitly or implicitly public.
ClassMethod::isStatic public function Whether the method is static.
ClassMethod::returnsByRef public function Whether to return by reference Overrides FunctionLike::returnsByRef
ClassMethod::__construct public function Constructs a class method node.
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