Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

ParameterScanner.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 6.58 KiB


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