Overview

Namespaces

  • Pharborist
    • Constants
    • ControlStructures
    • Exceptions
    • Functions
    • Generators
    • Namespaces
    • Objects
    • Operators
    • Types
    • Variables

Classes

  • Pharborist\Variables\CompoundVariableNode
  • Pharborist\Variables\GlobalStatementNode
  • Pharborist\Variables\ReferenceVariableNode
  • Pharborist\Variables\StaticVariableNode
  • Pharborist\Variables\StaticVariableStatementNode
  • Pharborist\Variables\VariableNode
  • Pharborist\Variables\VariableVariableNode

Interfaces

  • Pharborist\Variables\VariableExpressionNode
  • Overview
  • Namespace
  • Class
 1: <?php
 2: namespace Pharborist\Objects;
 3: 
 4: use Pharborist\CommaListNode;
 5: use Pharborist\Functions\CallNode;
 6: use Pharborist\Namespaces\NameNode;
 7: use Pharborist\Node;
 8: use Pharborist\Token;
 9: use Pharborist\Variables\VariableExpressionNode;
10: 
11: /**
12:  * A call to a static class method, e.g. `MyClass::classMethod()`
13:  */
14: class ClassMethodCallNode extends CallNode implements VariableExpressionNode {
15:   /**
16:    * @var \Pharborist\Namespaces\NameNode|Node
17:    */
18:   protected $className;
19: 
20:   /**
21:    * @var Node
22:    */
23:   protected $methodName;
24: 
25:   /**
26:    * @return \Pharborist\Namespaces\NameNode|Node
27:    */
28:   public function getClassName() {
29:     return $this->className;
30:   }
31: 
32:   /**
33:    * @param string|Node $class_name
34:    * @return $this
35:    */
36:   public function setClassName($class_name) {
37:     if (is_string($class_name)) {
38:       $class_name = Token::identifier($class_name);
39:     }
40:     $this->className->replaceWith($class_name);
41:     $this->className = $class_name;
42:     return $this;
43:   }
44: 
45:   /**
46:    * @return Node
47:    */
48:   public function getMethodName() {
49:     return $this->methodName;
50:   }
51: 
52:   /**
53:    * @param string|Node $method_name
54:    * @return $this
55:    */
56:   public function setMethodName($method_name) {
57:     if (is_string($method_name)) {
58:       $method_name = Token::identifier($method_name);
59:     }
60:     $this->methodName->replaceWith($method_name);
61:     $this->methodName = $method_name;
62:     return $this;
63:   }
64: 
65:   /**
66:    * Creates a method call on a class with an empty argument list.
67:    *
68:    * @param Node|string $class_name
69:    *  The class node which is typically NameNode of class.
70:    * @param string $method_name
71:    *  The name of the called method.
72:    *
73:    * @return static
74:    */
75:   public static function create($class_name, $method_name) {
76:     if (is_string($class_name)) {
77:       $class_name = NameNode::create($class_name);
78:     }
79:     /** @var ClassMethodCallNode $node */
80:     $node = new static();
81:     $node->addChild($class_name, 'className');
82:     $node->addChild(Token::doubleColon());
83:     $node->addChild(Token::identifier($method_name), 'methodName');
84:     $node->addChild(Token::openParen(), 'openParen');
85:     $node->addChild(new CommaListNode(), 'arguments');
86:     $node->addChild(Token::closeParen(), 'closeParen');
87:     return $node;
88:   }
89: }
90: 
Pharborist API documentation generated by ApiGen