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

ConstantScanner.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 5.32 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\Annotation;
 013  use Zend\Code\Exception;
 014  use Zend\Code\NameInformation;
 015   
 016  class ConstantScanner implements ScannerInterface
 017  {
 018      /**
 019       * @var bool
 020       */
 021      protected $isScanned = false;
 022   
 023      /**
 024       * @var array
 025       */
 026      protected $tokens;
 027   
 028      /**
 029       * @var NameInformation
 030       */
 031      protected $nameInformation;
 032   
 033      /**
 034       * @var string
 035       */
 036      protected $class;
 037   
 038      /**
 039       * @var ClassScanner
 040       */
 041      protected $scannerClass;
 042   
 043      /**
 044       * @var int
 045       */
 046      protected $lineStart;
 047   
 048      /**
 049       * @var string
 050       */
 051      protected $docComment;
 052   
 053      /**
 054       * @var string
 055       */
 056      protected $name;
 057   
 058      /**
 059       * @var string
 060       */
 061      protected $value;
 062   
 063      /**
 064       * Constructor
 065       *
 066       * @param array $constantTokens
 067       * @param NameInformation $nameInformation
 068       */
 069      public function __construct(array $constantTokens, NameInformation $nameInformation = null)
 070      {
 071          $this->tokens = $constantTokens;
 072          $this->nameInformation = $nameInformation;
 073      }
 074   
 075      /**
 076       * @param string $class
 077       */
 078      public function setClass($class)
 079      {
 080          $this->class = $class;
 081      }
 082   
 083      /**
 084       * @param ClassScanner $scannerClass
 085       */
 086      public function setScannerClass(ClassScanner $scannerClass)
 087      {
 088          $this->scannerClass = $scannerClass;
 089      }
 090   
 091      /**
 092       * @return ClassScanner
 093       */
 094      public function getClassScanner()
 095      {
 096          return $this->scannerClass;
 097      }
 098   
 099      /**
 100       * @return string
 101       */
 102      public function getName()
 103      {
 104          $this->scan();
 105          return $this->name;
 106      }
 107   
 108      /**
 109       * @return string
 110       */
 111      public function getValue()
 112      {
 113          $this->scan();
 114          return $this->value;
 115      }
 116   
 117      /**
 118       * @return string
 119       */
 120      public function getDocComment()
 121      {
 122          $this->scan();
 123          return $this->docComment;
 124      }
 125   
 126      /**
 127       * @param Annotation\AnnotationManager $annotationManager
 128       * @return AnnotationScanner
 129       */
 130      public function getAnnotations(Annotation\AnnotationManager $annotationManager)
 131      {
 132          if (($docComment = $this->getDocComment()) == '') {
 133              return false;
 134          }
 135   
 136          return new AnnotationScanner($annotationManager, $docComment, $this->nameInformation);
 137      }
 138   
 139      /**
 140       * @return string
 141       */
 142      public function __toString()
 143      {
 144          $this->scan();
 145          return var_export($this, true);
 146      }
 147   
 148      /**
 149       * Scan tokens
 150       *
 151       * @throws Exception\RuntimeException
 152       */
 153      protected function scan()
 154      {
 155          if ($this->isScanned) {
 156              return;
 157          }
 158   
 159          if (!$this->tokens) {
 160              throw new Exception\RuntimeException('No tokens were provided');
 161          }
 162   
 163          /**
 164           * Variables & Setup
 165           */
 166          $tokens = &$this->tokens;
 167   
 168          reset($tokens);
 169   
 170          SCANNER_TOP:
 171   
 172          $token = current($tokens);
 173   
 174          if (!is_string($token)) {
 175              list($tokenType, $tokenContent, $tokenLine) = $token;
 176   
 177              switch ($tokenType) {
 178                  case T_DOC_COMMENT:
 179                      if ($this->docComment === null && $this->name === null) {
 180                          $this->docComment = $tokenContent;
 181                      }
 182                      goto SCANNER_CONTINUE;
 183                      // fall-through
 184   
 185                  case T_STRING:
 186                      $string = (is_string($token)) ? $token : $tokenContent;
 187   
 188                      if (null === $this->name) {
 189                          $this->name = $string;
 190                      } else {
 191                          if ('self' == strtolower($string)) {
 192                              list($tokenNextType, $tokenNextContent, $tokenNextLine) = next($tokens);
 193   
 194                              if ('::' == $tokenNextContent) {
 195                                  list($tokenNextType, $tokenNextContent, $tokenNextLine) = next($tokens);
 196   
 197                                  if ($this->getClassScanner()->getConstant($tokenNextContent)) {
 198                                      $this->value = $this->getClassScanner()->getConstant($tokenNextContent)->getValue();
 199                                  }
 200                              }
 201                          }
 202                      }
 203   
 204                      goto SCANNER_CONTINUE;
 205                      // fall-through
 206   
 207                  case T_CONSTANT_ENCAPSED_STRING:
 208                  case T_DNUMBER:
 209                  case T_LNUMBER:
 210                      $string = (is_string($token)) ? $token : $tokenContent;
 211   
 212                      if (substr($string, 0, 1) === '"' || substr($string, 0, 1) === "'") {
 213                          $this->value = substr($string, 1, -1); // Remove quotes
 214                      } else {
 215                          $this->value = $string;
 216                      }
 217                      goto SCANNER_CONTINUE;
 218                      // fall-trough
 219   
 220                  default:
 221                      goto SCANNER_CONTINUE;
 222              }
 223          }
 224   
 225          SCANNER_CONTINUE:
 226   
 227          if (next($this->tokens) === false) {
 228              goto SCANNER_END;
 229          }
 230          goto SCANNER_TOP;
 231   
 232          SCANNER_END:
 233   
 234          $this->isScanned = true;
 235      }
 236  }
 237