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