1 | <?php |
||
17 | class LocationImpl implements Location { |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $file; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $file_content; |
||
27 | |||
28 | /** |
||
29 | * @var int[]|null |
||
30 | */ |
||
31 | protected $running_line_length = null; |
||
32 | |||
33 | /** |
||
34 | * This contains the stack of ids were currently in, i.e. the nesting of |
||
35 | * known code blocks we are in. |
||
36 | * |
||
37 | * @var array contains ($definition_type, $definition_id) tuples |
||
38 | */ |
||
39 | protected $definition_stack; |
||
40 | |||
41 | /** |
||
42 | * @var \PhpParser\Node|null |
||
43 | */ |
||
44 | protected $current_node = null; |
||
45 | |||
46 | 50 | public function __construct($file_name, $file_content) { |
|
53 | |||
54 | /** |
||
55 | * @return mixed |
||
56 | */ |
||
57 | 23 | public function file() { |
|
62 | |||
63 | /** |
||
64 | * @return string |
||
65 | */ |
||
66 | 43 | public function file_name() { |
|
69 | |||
70 | /** |
||
71 | * @return string |
||
72 | */ |
||
73 | 43 | public function file_content() { |
|
76 | |||
77 | /** |
||
78 | * @return int |
||
79 | */ |
||
80 | 25 | public function line() { |
|
84 | |||
85 | /** |
||
86 | * @return int |
||
87 | */ |
||
88 | 12 | public function column() { |
|
97 | |||
98 | /** |
||
99 | * @return array[] List of ($type, $handle) |
||
100 | */ |
||
101 | 25 | public function in_entities() { |
|
104 | |||
105 | /** |
||
106 | * @param int $pos |
||
107 | * @return array ($type, $handle) |
||
108 | */ |
||
109 | 41 | public function in_entity($pos) { |
|
115 | |||
116 | /** |
||
117 | * @return int |
||
118 | */ |
||
119 | 41 | public function count_in_entity() { |
|
122 | |||
123 | /** |
||
124 | * Push an entity on the stack. |
||
125 | * |
||
126 | * @param string $type |
||
127 | * @param mixed $handle |
||
128 | * @return null |
||
129 | */ |
||
130 | 43 | public function push_entity($type, $handle) { |
|
134 | |||
135 | /** |
||
136 | * Pop an entity from the stach |
||
137 | * |
||
138 | * @return null |
||
139 | */ |
||
140 | 41 | public function pop_entity() { |
|
143 | |||
144 | /** |
||
145 | * @param \PhpParser\Node $node |
||
146 | * @return null |
||
147 | */ |
||
148 | 45 | public function set_current_node(\PhpParser\Node $node) { |
|
152 | |||
153 | /** |
||
154 | * @return \PhpParser\Node $node |
||
155 | */ |
||
156 | 43 | public function current_node() { |
|
160 | |||
161 | /** |
||
162 | * @return null |
||
163 | */ |
||
164 | 42 | public function flush_current_node() { |
|
168 | |||
169 | 13 | protected function init_running_line_length() { |
|
182 | } |
||
183 | |||
184 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: