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

Breadcrumb

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

class MethodDefinition

A node that represents a method declaration in classes and object literals.

@author Marco Marchiò <marco.mm89@gmail.com>

Hierarchy

  • class \Peast\Syntax\Node\Node implements \Peast\Syntax\Node\JSONSerializable
    • class \Peast\Syntax\Node\MethodDefinition extends \Peast\Syntax\Node\Node

Expanded class hierarchy of MethodDefinition

3 string references to 'MethodDefinition'
ClassBody::setBody in vendor/mck89/peast/lib/Peast/Syntax/Node/ClassBody.php
Sets class methods and properties
Parser::parseMethodDefinition in vendor/mck89/peast/lib/Peast/Syntax/Parser.php
Parses a method definition
Renderer::renderNode in vendor/mck89/peast/lib/Peast/Renderer.php
Renders a node

File

vendor/mck89/peast/lib/Peast/Syntax/Node/MethodDefinition.php, line 17

Namespace

Peast\Syntax\Node
View source
class MethodDefinition extends Node {
    
    /**
     * Map of node properties
     * 
     * @var array 
     */
    protected $propertiesMap = array(
        "key" => true,
        "value" => true,
        "kind" => false,
        "computed" => false,
        "static" => false,
    );
    
    //Kind constants
    
    /**
     * Constructor method
     */
    const KIND_CONSTRUCTOR = "constructor";
    
    /**
     * Standard method
     */
    const KIND_METHOD = "method";
    
    /**
     * Getter method
     */
    const KIND_GET = "get";
    
    /**
     * Setter method
     */
    const KIND_SET = "set";
    
    /**
     * Method's key
     * 
     * @var Expression|PrivateIdentifier
     */
    protected $key;
    
    /**
     * Method's value
     * 
     * @var FunctionExpression 
     */
    protected $value;
    
    /**
     * Method's kind that is one of the kind constants
     * 
     * @var string 
     */
    protected $kind = self::KIND_METHOD;
    
    /**
     * Computed flag that is true if method's key is declared using square
     * brackets syntax
     * 
     * @var bool 
     */
    protected $computed = false;
    
    /**
     * Static flag that is true if the method is static
     * 
     * @var bool 
     */
    protected $static = false;
    
    /**
     * Returns the method's key
     * 
     * @return Expression|PrivateIdentifier
     */
    public function getKey() {
        return $this->key;
    }
    
    /**
     * Sets the method's key
     * 
     * @param Expression|PrivateIdentifier $key Method's key
     * 
     * @return $this
     */
    public function setKey($key) {
        $this->assertType($key, array(
            "Expression",
            "PrivateIdentifier",
        ));
        $this->key = $key;
        return $this;
    }
    
    /**
     * Returns the method's value
     * 
     * @return FunctionExpression
     */
    public function getValue() {
        return $this->value;
    }
    
    /**
     * Sets the method's value
     * 
     * @param FunctionExpression $value Method's value
     * 
     * @return $this
     */
    public function setValue(FunctionExpression $value) {
        $this->value = $value;
        return $this;
    }
    
    /**
     * Returns the method's kind that is one of the kind constants
     * 
     * @return string
     */
    public function getKind() {
        return $this->kind;
    }
    
    /**
     * Sets the method's kind that is one of the kind constants
     * 
     * @param string $kind Method's kind
     * 
     * @return $this
     */
    public function setKind($kind) {
        $this->kind = $kind;
        return $this;
    }
    
    /**
     * Returns the computed flag that is true if method's key is declared using
     * square brackets syntax
     * 
     * @return bool
     */
    public function getComputed() {
        return $this->computed;
    }
    
    /**
     * Sets the computed flag that is true if method's key is declared using
     * square brackets syntax
     * 
     * @param bool $computed Computed flag
     * 
     * @return $this
     */
    public function setComputed($computed) {
        $this->computed = (bool) $computed;
        return $this;
    }
    
    /**
     * Returns the static flag that is true if the method is static
     * 
     * @return bool
     */
    public function getStatic() {
        return $this->{"static"};
    }
    
    /**
     * Sets the static flag that is true if the method is static
     * 
     * @param bool $static Static flag
     * 
     * @return $this
     */
    public function setStatic($static) {
        $this->{"static"} = (bool) $static;
        return $this;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
MethodDefinition::$computed protected property Computed flag that is true if method&#039;s key is declared using square
brackets syntax
MethodDefinition::$key protected property Method&#039;s key
MethodDefinition::$kind protected property Method&#039;s kind that is one of the kind constants
MethodDefinition::$propertiesMap protected property Map of node properties Overrides Node::$propertiesMap
MethodDefinition::$static protected property Static flag that is true if the method is static
MethodDefinition::$value protected property Method&#039;s value
MethodDefinition::getComputed public function Returns the computed flag that is true if method&#039;s key is declared using
square brackets syntax
MethodDefinition::getKey public function Returns the method&#039;s key
MethodDefinition::getKind public function Returns the method&#039;s kind that is one of the kind constants
MethodDefinition::getStatic public function Returns the static flag that is true if the method is static
MethodDefinition::getValue public function Returns the method&#039;s value
MethodDefinition::KIND_CONSTRUCTOR constant Constructor method
MethodDefinition::KIND_GET constant Getter method
MethodDefinition::KIND_METHOD constant Standard method
MethodDefinition::KIND_SET constant Setter method
MethodDefinition::setComputed public function Sets the computed flag that is true if method&#039;s key is declared using
square brackets syntax
MethodDefinition::setKey public function Sets the method&#039;s key
MethodDefinition::setKind public function Sets the method&#039;s kind that is one of the kind constants
MethodDefinition::setStatic public function Sets the static flag that is true if the method is static
MethodDefinition::setValue public function Sets the method&#039;s value
Node::$leadingComments protected property Leading comments array
Node::$location public property Node location in the source code
Node::$trailingComments protected property Trailing comments array
Node::assertArrayOf protected function Asserts that the given value is an array of defined type
Node::assertType protected function Asserts that the given value respects the defined type
Node::getLeadingComments public function Returns leading comments array
Node::getLocation public function Returns node location in the source code
Node::getTrailingComments public function Returns trailing comments array
Node::getType public function Returns node type 2
Node::jsonSerialize public function Returns a serializable version of the node 2
Node::render public function Renders the current node
Node::setEndPosition public function Sets the end position of the node in the source code
Node::setLeadingComments public function Sets leading comments array 1
Node::setStartPosition public function Sets the start position of the node in the source code
Node::setTrailingComments public function Sets trailing comments array 1
Node::traverse public function Traverses the current node and all its child nodes using the given
function
Node::typeError protected function Throws an error if the defined type is not supported b
Node::__construct public function Class constructor

API Navigation

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