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

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

DerivedClassScanner.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 10.03 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-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\Exception;
013   
014  class DerivedClassScanner extends ClassScanner
015  {
016      /**
017       * @var DirectoryScanner
018       */
019      protected $directoryScanner = null;
020   
021      /**
022       * @var ClassScanner
023       */
024      protected $classScanner = null;
025   
026      /**
027       * @var array
028       */
029      protected $parentClassScanners = array();
030   
031      /**
032       * @var array
033       */
034      protected $interfaceClassScanners = array();
035   
036      /**
037       * @param ClassScanner $classScanner
038       * @param DirectoryScanner $directoryScanner
039       */
040      public function __construct(ClassScanner $classScanner, DirectoryScanner $directoryScanner)
041      {
042          $this->classScanner     = $classScanner;
043          $this->directoryScanner = $directoryScanner;
044   
045          $currentScannerClass = $classScanner;
046   
047          while ($currentScannerClass && $currentScannerClass->hasParentClass()) {
048              $currentParentClassName = $currentScannerClass->getParentClass();
049              if ($directoryScanner->hasClass($currentParentClassName)) {
050                  $currentParentClass                                 = $directoryScanner->getClass($currentParentClassName);
051                  $this->parentClassScanners[$currentParentClassName] = $currentParentClass;
052                  $currentScannerClass                                = $currentParentClass;
053              } else {
054                  $currentScannerClass = false;
055              }
056          }
057   
058          foreach ($interfaces = $this->classScanner->getInterfaces() as $iName) {
059              if ($directoryScanner->hasClass($iName)) {
060                  $this->interfaceClassScanners[$iName] = $directoryScanner->getClass($iName);
061              }
062          }
063      }
064   
065      /**
066       * @return null|string
067       */
068      public function getName()
069      {
070          return $this->classScanner->getName();
071      }
072   
073      /**
074       * @return null|string
075       */
076      public function getShortName()
077      {
078          return $this->classScanner->getShortName();
079      }
080   
081      /**
082       * @return bool
083       */
084      public function isInstantiable()
085      {
086          return $this->classScanner->isInstantiable();
087      }
088   
089      /**
090       * @return bool
091       */
092      public function isFinal()
093      {
094          return $this->classScanner->isFinal();
095      }
096   
097      /**
098       * @return bool
099       */
100      public function isAbstract()
101      {
102          return $this->classScanner->isAbstract();
103      }
104   
105      /**
106       * @return bool
107       */
108      public function isInterface()
109      {
110          return $this->classScanner->isInterface();
111      }
112   
113      /**
114       * @return array
115       */
116      public function getParentClasses()
117      {
118          return array_keys($this->parentClassScanners);
119      }
120   
121      /**
122       * @return bool
123       */
124      public function hasParentClass()
125      {
126          return ($this->classScanner->getParentClass() !== null);
127      }
128   
129      /**
130       * @return null|string
131       */
132      public function getParentClass()
133      {
134          return $this->classScanner->getParentClass();
135      }
136   
137      /**
138       * @param  bool $returnClassScanners
139       * @return array
140       */
141      public function getInterfaces($returnClassScanners = false)
142      {
143          if ($returnClassScanners) {
144              return $this->interfaceClassScanners;
145          }
146   
147          $interfaces = $this->classScanner->getInterfaces();
148          foreach ($this->parentClassScanners as $pClassScanner) {
149              $interfaces = array_merge($interfaces, $pClassScanner->getInterfaces());
150          }
151   
152          return $interfaces;
153      }
154   
155      /**
156       * Return a list of constant names
157       *
158       * @return array
159       */
160      public function getConstantNames()
161      {
162          $constants = $this->classScanner->getConstantNames();
163          foreach ($this->parentClassScanners as $pClassScanner) {
164              $constants = array_merge($constants, $pClassScanner->getConstantNames());
165          }
166   
167          return $constants;
168      }
169   
170      /**
171       * Return a list of constants
172       *
173       * @param  bool $namesOnly Set false to return instances of ConstantScanner
174       * @return array|ConstantScanner[]
175       */
176      public function getConstants($namesOnly = true)
177      {
178          if (true === $namesOnly) {
179              trigger_error('Use method getConstantNames() instead', E_USER_DEPRECATED);
180              return $this->getConstantNames();
181          }
182   
183          $constants = $this->classScanner->getConstants();
184          foreach ($this->parentClassScanners as $pClassScanner) {
185              $constants = array_merge($constants, $pClassScanner->getConstants($namesOnly));
186          }
187   
188          return $constants;
189      }
190   
191      /**
192       * Return a single constant by given name or index of info
193       *
194       * @param  string|int $constantNameOrInfoIndex
195       * @throws Exception\InvalidArgumentException
196       * @return bool|ConstantScanner
197       */
198      public function getConstant($constantNameOrInfoIndex)
199      {
200          if ($this->classScanner->hasConstant($constantNameOrInfoIndex)) {
201              return $this->classScanner->getConstant($constantNameOrInfoIndex);
202          }
203   
204          foreach ($this->parentClassScanners as $pClassScanner) {
205              if ($pClassScanner->hasConstant($constantNameOrInfoIndex)) {
206                  return $pClassScanner->getConstant($constantNameOrInfoIndex);
207              }
208          }
209   
210          throw new Exception\InvalidArgumentException(sprintf(
211              'Constant %s not found in %s',
212              $constantNameOrInfoIndex,
213              $this->classScanner->getName()
214          ));
215      }
216   
217      /**
218       * Verify if class or parent class has constant
219       *
220       * @param  string $name
221       * @return bool
222       */
223      public function hasConstant($name)
224      {
225          if ($this->classScanner->hasConstant($name)) {
226              return true;
227          }
228          foreach ($this->parentClassScanners as $pClassScanner) {
229              if ($pClassScanner->hasConstant($name)) {
230                  return true;
231              }
232          }
233   
234          return false;
235      }
236   
237      /**
238       * Return a list of property names
239       *
240       * @return array
241       */
242      public function getPropertyNames()
243      {
244          $properties = $this->classScanner->getPropertyNames();
245          foreach ($this->parentClassScanners as $pClassScanner) {
246              $properties = array_merge($properties, $pClassScanner->getPropertyNames());
247          }
248   
249          return $properties;
250      }
251   
252      /**
253       * @param  bool $returnScannerProperty
254       * @return array
255       */
256      public function getProperties($returnScannerProperty = false)
257      {
258          $properties = $this->classScanner->getProperties($returnScannerProperty);
259          foreach ($this->parentClassScanners as $pClassScanner) {
260              $properties = array_merge($properties, $pClassScanner->getProperties($returnScannerProperty));
261          }
262   
263          return $properties;
264      }
265   
266      /**
267       * Return a single property by given name or index of info
268       *
269       * @param  string|int $propertyNameOrInfoIndex
270       * @throws Exception\InvalidArgumentException
271       * @return bool|PropertyScanner
272       */
273      public function getProperty($propertyNameOrInfoIndex)
274      {
275          if ($this->classScanner->hasProperty($propertyNameOrInfoIndex)) {
276              return $this->classScanner->getProperty($propertyNameOrInfoIndex);
277          }
278   
279          foreach ($this->parentClassScanners as $pClassScanner) {
280              if ($pClassScanner->hasProperty($propertyNameOrInfoIndex)) {
281                  return $pClassScanner->getProperty($propertyNameOrInfoIndex);
282              }
283          }
284   
285          throw new Exception\InvalidArgumentException(sprintf(
286              'Property %s not found in %s',
287              $propertyNameOrInfoIndex,
288              $this->classScanner->getName()
289          ));
290      }
291   
292      /**
293       * Verify if class or parent class has property
294       *
295       * @param  string $name
296       * @return bool
297       */
298      public function hasProperty($name)
299      {
300          if ($this->classScanner->hasProperty($name)) {
301              return true;
302          }
303          foreach ($this->parentClassScanners as $pClassScanner) {
304              if ($pClassScanner->hasProperty($name)) {
305                  return true;
306              }
307          }
308   
309          return false;
310      }
311   
312      /**
313       * @return array
314       */
315      public function getMethodNames()
316      {
317          $methods = $this->classScanner->getMethodNames();
318          foreach ($this->parentClassScanners as $pClassScanner) {
319              $methods = array_merge($methods, $pClassScanner->getMethodNames());
320          }
321   
322          return $methods;
323      }
324   
325      /**
326       * @return MethodScanner[]
327       */
328      public function getMethods()
329      {
330          $methods = $this->classScanner->getMethods();
331          foreach ($this->parentClassScanners as $pClassScanner) {
332              $methods = array_merge($methods, $pClassScanner->getMethods());
333          }
334   
335          return $methods;
336      }
337   
338      /**
339       * @param  int|string $methodNameOrInfoIndex
340       * @return MethodScanner
341       * @throws Exception\InvalidArgumentException
342       */
343      public function getMethod($methodNameOrInfoIndex)
344      {
345          if ($this->classScanner->hasMethod($methodNameOrInfoIndex)) {
346              return $this->classScanner->getMethod($methodNameOrInfoIndex);
347          }
348   
349          foreach ($this->parentClassScanners as $pClassScanner) {
350              if ($pClassScanner->hasMethod($methodNameOrInfoIndex)) {
351                  return $pClassScanner->getMethod($methodNameOrInfoIndex);
352              }
353          }
354   
355          throw new Exception\InvalidArgumentException(sprintf(
356              'Method %s not found in %s',
357              $methodNameOrInfoIndex,
358              $this->classScanner->getName()
359          ));
360      }
361   
362      /**
363       * Verify if class or parent class has method by given name
364       *
365       * @param  string $name
366       * @return bool
367       */
368      public function hasMethod($name)
369      {
370          if ($this->classScanner->hasMethod($name)) {
371              return true;
372          }
373          foreach ($this->parentClassScanners as $pClassScanner) {
374              if ($pClassScanner->hasMethod($name)) {
375                  return true;
376              }
377          }
378   
379          return false;
380      }
381  }
382