Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
ParameterScanner.php
001 <?php
002 /**
003 * Zend Framework (http://framework.zend.com/)
004 *
005 * @link http://github.com/zendframework/zf2 for the canonical source repository
006 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
007 * @license http://framework.zend.com/license/new-bsd New BSD License
008 */
009
010 namespace Zend\Code\Scanner;
011
012 use Zend\Code\NameInformation;
013
014 class ParameterScanner
015 {
016 /**
017 * @var bool
018 */
019 protected $isScanned = false;
020
021 /**
022 * @var null|ClassScanner
023 */
024 protected $declaringScannerClass = null;
025
026 /**
027 * @var null|string
028 */
029 protected $declaringClass = null;
030
031 /**
032 * @var null|MethodScanner
033 */
034 protected $declaringScannerFunction = null;
035
036 /**
037 * @var null|string
038 */
039 protected $declaringFunction = null;
040
041 /**
042 * @var null|string
043 */
044 protected $defaultValue = null;
045
046 /**
047 * @var null|string
048 */
049 protected $class = null;
050
051 /**
052 * @var null|string
053 */
054 protected $name = null;
055
056 /**
057 * @var null|int
058 */
059 protected $position = null;
060
061 /**
062 * @var bool
063 */
064 protected $isArray = false;
065
066 /**
067 * @var bool
068 */
069 protected $isDefaultValueAvailable = false;
070
071 /**
072 * @var bool
073 */
074 protected $isOptional = false;
075
076 /**
077 * @var bool
078 */
079 protected $isPassedByReference = false;
080
081 /**
082 * @var array|null
083 */
084 protected $tokens = null;
085
086 /**
087 * @var null|NameInformation
088 */
089 protected $nameInformation = null;
090
091 /**
092 * @param array $parameterTokens
093 * @param NameInformation $nameInformation
094 */
095 public function __construct(array $parameterTokens, NameInformation $nameInformation = null)
096 {
097 $this->tokens = $parameterTokens;
098 $this->nameInformation = $nameInformation;
099 }
100
101 /**
102 * Set declaring class
103 *
104 * @param string $class
105 * @return void
106 */
107 public function setDeclaringClass($class)
108 {
109 $this->declaringClass = (string) $class;
110 }
111
112 /**
113 * Set declaring scanner class
114 *
115 * @param ClassScanner $scannerClass
116 * @return void
117 */
118 public function setDeclaringScannerClass(ClassScanner $scannerClass)
119 {
120 $this->declaringScannerClass = $scannerClass;
121 }
122
123 /**
124 * Set declaring function
125 *
126 * @param string $function
127 * @return void
128 */
129 public function setDeclaringFunction($function)
130 {
131 $this->declaringFunction = $function;
132 }
133
134 /**
135 * Set declaring scanner function
136 *
137 * @param MethodScanner $scannerFunction
138 * @return void
139 */
140 public function setDeclaringScannerFunction(MethodScanner $scannerFunction)
141 {
142 $this->declaringScannerFunction = $scannerFunction;
143 }
144
145 /**
146 * Set position
147 *
148 * @param int $position
149 * @return void
150 */
151 public function setPosition($position)
152 {
153 $this->position = $position;
154 }
155
156 /**
157 * Scan
158 *
159 * @return void
160 */
161 protected function scan()
162 {
163 if ($this->isScanned) {
164 return;
165 }
166
167 $tokens = &$this->tokens;
168
169 reset($tokens);
170
171 SCANNER_TOP:
172
173 $token = current($tokens);
174
175 if (is_string($token)) {
176 // check pass by ref
177 if ($token === '&') {
178 $this->isPassedByReference = true;
179 goto SCANNER_CONTINUE;
180 }
181 if ($token === '=') {
182 $this->isOptional = true;
183 $this->isDefaultValueAvailable = true;
184 goto SCANNER_CONTINUE;
185 }
186 } else {
187 if ($this->name === null && ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR)) {
188 $this->class .= $token[1];
189 goto SCANNER_CONTINUE;
190 }
191 if ($token[0] === T_VARIABLE) {
192 $this->name = ltrim($token[1], '$');
193 goto SCANNER_CONTINUE;
194 }
195 }
196
197 if ($this->name !== null) {
198 $this->defaultValue .= trim((is_string($token)) ? $token : $token[1]);
199 }
200
201 SCANNER_CONTINUE:
202
203 if (next($this->tokens) === false) {
204 goto SCANNER_END;
205 }
206 goto SCANNER_TOP;
207
208 SCANNER_END:
209
210 if ($this->class && $this->nameInformation) {
211 $this->class = $this->nameInformation->resolveName($this->class);
212 }
213
214 $this->isScanned = true;
215 }
216
217 /**
218 * Get declaring scanner class
219 *
220 * @return ClassScanner
221 */
222 public function getDeclaringScannerClass()
223 {
224 return $this->declaringScannerClass;
225 }
226
227 /**
228 * Get declaring class
229 *
230 * @return string
231 */
232 public function getDeclaringClass()
233 {
234 return $this->declaringClass;
235 }
236
237 /**
238 * Get declaring scanner function
239 *
240 * @return MethodScanner
241 */
242 public function getDeclaringScannerFunction()
243 {
244 return $this->declaringScannerFunction;
245 }
246
247 /**
248 * Get declaring function
249 *
250 * @return string
251 */
252 public function getDeclaringFunction()
253 {
254 return $this->declaringFunction;
255 }
256
257 /**
258 * Get default value
259 *
260 * @return string
261 */
262 public function getDefaultValue()
263 {
264 $this->scan();
265
266 return $this->defaultValue;
267 }
268
269 /**
270 * Get class
271 *
272 * @return string
273 */
274 public function getClass()
275 {
276 $this->scan();
277
278 return $this->class;
279 }
280
281 /**
282 * Get name
283 *
284 * @return string
285 */
286 public function getName()
287 {
288 $this->scan();
289
290 return $this->name;
291 }
292
293 /**
294 * Get position
295 *
296 * @return int
297 */
298 public function getPosition()
299 {
300 $this->scan();
301
302 return $this->position;
303 }
304
305 /**
306 * Check if is array
307 *
308 * @return bool
309 */
310 public function isArray()
311 {
312 $this->scan();
313
314 return $this->isArray;
315 }
316
317 /**
318 * Check if default value is available
319 *
320 * @return bool
321 */
322 public function isDefaultValueAvailable()
323 {
324 $this->scan();
325
326 return $this->isDefaultValueAvailable;
327 }
328
329 /**
330 * Check if is optional
331 *
332 * @return bool
333 */
334 public function isOptional()
335 {
336 $this->scan();
337
338 return $this->isOptional;
339 }
340
341 /**
342 * Check if is passed by reference
343 *
344 * @return bool
345 */
346 public function isPassedByReference()
347 {
348 $this->scan();
349
350 return $this->isPassedByReference;
351 }
352 }
353