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;
 3: 
 4: use Pharborist\Namespaces\UseDeclarationNode;
 5: 
 6: /**
 7:  * A block of statements.
 8:  */
 9: class StatementBlockNode extends ParentNode {
10:   protected function _getStatements() {
11:     $matches = [];
12:     $child = $this->head;
13:     while ($child) {
14:       if ($child instanceof StatementNode) {
15:         $matches[] = $child;
16:       }
17:       elseif ($child instanceof StatementBlockNode) {
18:         $matches = array_merge($matches, $child->_getStatements());
19:       }
20:       $child = $child->next;
21:     }
22:     return $matches;
23:   }
24: 
25:   /**
26:    * @return NodeCollection|StatementNode[]
27:    */
28:   public function getStatements() {
29:     return new NodeCollection($this->_getStatements(), FALSE);
30:   }
31: 
32:   /**
33:    * Get the use declarations of this statement block.
34:    *
35:    * @return NodeCollection|UseDeclarationNode[]
36:    *   Use declarations.
37:    */
38:   public function getUseDeclarations() {
39:     $declarations = new NodeCollection();
40:     /** @var \Pharborist\Namespaces\UseDeclarationBlockNode[] $use_blocks */
41:     $use_blocks = $this->children(Filter::isInstanceOf('\Pharborist\Namespaces\UseDeclarationBlockNode'));
42:     foreach ($use_blocks as $use_block) {
43:       foreach ($use_block->getDeclarationStatements() as $use_statement) {
44:         $declarations->add($use_statement->getDeclarations());
45:       }
46:     }
47:     return $declarations;
48:   }
49: 
50:   /**
51:    * Return mapping of class names to fully qualified names.
52:    *
53:    * @return array
54:    *   Associative array of namespace alias to fully qualified names.
55:    */
56:   public function getClassAliases() {
57:     $mappings = array();
58:     foreach ($this->getUseDeclarations() as $use_declaration) {
59:       if ($use_declaration->isClass()) {
60:         $mappings[$use_declaration->getBoundedName()] = $use_declaration->getName()->getAbsolutePath();
61:       }
62:     }
63:     return $mappings;
64:   }
65: }
66: 
Pharborist API documentation generated by ApiGen