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\TokenNode;
10: use Pharborist\Variables\VariableExpressionNode;
11:
12: 13: 14:
15: class ObjectMethodCallNode extends CallNode implements VariableExpressionNode {
16: 17: 18:
19: protected $object;
20:
21: 22: 23:
24: protected $operator;
25:
26: 27: 28:
29: protected $methodName;
30:
31: 32: 33:
34: public function getObject() {
35: return $this->object;
36: }
37:
38: 39: 40: 41: 42:
43: public function getOperator() {
44: return $this->operator;
45: }
46:
47: 48: 49:
50: public function getMethodName() {
51: return $this->methodName;
52: }
53:
54: 55: 56: 57:
58: public function setMethodName($method_name) {
59: if (is_string($method_name)) {
60: $method_name = Token::identifier($method_name);
61: }
62: $this->methodName->replaceWith($method_name);
63: $this->methodName = $method_name;
64: return $this;
65: }
66:
67: 68: 69: 70: 71: 72: 73: 74: 75: 76:
77: public static function create(Node $object, $method_name) {
78:
79: $node = new static();
80: $node->addChild($object, 'object');
81: $node->addChild(Token::objectOperator(), 'operator');
82: $node->addChild(Token::identifier($method_name), 'methodName');
83: $node->addChild(Token::openParen(), 'openParen');
84: $node->addChild(new CommaListNode(), 'arguments');
85: $node->addChild(Token::closeParen(), 'closeParen');
86: return $node;
87: }
88:
89: 90: 91: 92: 93: 94: 95:
96: public function getPreviousCall() {
97: if ($this->object instanceof CallNode) {
98: return $this->object;
99: }
100: else {
101: return NULL;
102: }
103: }
104: }
105: