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\Node;
 5: use Pharborist\ParentNode;
 6: use Pharborist\TokenNode;
 7: use Pharborist\Variables\VariableExpressionNode;
 8: 
 9: /**
10:  * An object property access, e.g. `$object->property`.
11:  */
12: class ObjectPropertyNode extends ParentNode implements VariableExpressionNode {
13:   /**
14:    * @var Node
15:    */
16:   protected $object;
17: 
18:   /**
19:    * @var Node
20:    */
21:   protected $property;
22: 
23:   /**
24:    * @return Node
25:    */
26:   public function getObject() {
27:     return $this->object;
28:   }
29: 
30:   /**
31:    * @return Node
32:    */
33:   public function getProperty() {
34:     return $this->property;
35:   }
36: 
37:   /**
38:    * Returns the name of the property if it's an identifier (ie. T_STRING TokenNode).
39:    *
40:    * @return string|NULL
41:    *   Name of the property or NULL if not an identifier (eg. dynamic property
42:    *   name).
43:    */
44:   public function getPropertyName() {
45:     $root_property = $this->getRootProperty();
46:     if ($root_property instanceof TokenNode && $root_property->getType() === T_STRING) {
47:       return $root_property->getText();
48:     }
49:     return NULL;
50:   }
51: 
52:   /**
53:    * Returns the root property.
54:    *
55:    * For example, given an expression like $foo->bar->baz this method will
56:    * return the identifier (T_STRING TokenNode) 'bar'.
57:    *
58:    * @return Node
59:    *   The node for the root property.
60:    */
61:   public function getRootProperty() {
62:     if ($this->object instanceof ObjectPropertyNode) {
63:       return $this->object->getRootProperty();
64:     }
65:     else {
66:       return $this->property;
67:     }
68:   }
69: }
70: 
Pharborist API documentation generated by ApiGen