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: /**
 5:  * A token.
 6:  */
 7: class TokenNode extends Node {
 8:   /**
 9:    * @var int
10:    */
11:   protected $type;
12: 
13:   /**
14:    * @var string
15:    */
16:   protected $text;
17: 
18:   /**
19:    * @var SourcePosition
20:    */
21:   protected $position;
22: 
23:   /**
24:    * Construct token.
25:    * @param int $type
26:    * @param string $text
27:    * @param SourcePosition $position
28:    */
29:   public function __construct($type, $text, $position = NULL) {
30:     $this->type = $type;
31:     $this->text = $text;
32:     $this->position = $position;
33:   }
34: 
35:   /**
36:    * @return SourcePosition
37:    */
38:   public function getSourcePosition() {
39:     return $this->position;
40:   }
41: 
42:   /**
43:    * @return int
44:    */
45:   public function getType() {
46:     return $this->type;
47:   }
48: 
49:   /**
50:    * @param int $type
51:    * @return string
52:    */
53:   public static function typeName($type) {
54:     if (is_string($type)) {
55:       return $type;
56:     }
57:     else {
58:       return token_name($type);
59:     }
60:   }
61: 
62:   /**
63:    * @return string
64:    */
65:   public function getTypeName() {
66:     return self::typeName($this->type);
67:   }
68: 
69:   /**
70:    * @return string
71:    */
72:   public function getText() {
73:     return $this->text;
74:   }
75: 
76:   /**
77:    * @param string $text
78:    * @return $this
79:    */
80:   public function setText($text) {
81:     $this->text = $text;
82:     return $this;
83:   }
84: 
85:   /**
86:    * @return string
87:    */
88:   public function __toString() {
89:     return $this->text;
90:   }
91: }
92: 
Pharborist API documentation generated by ApiGen