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 |
PropertyScanner.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\Annotation;
013 use Zend\Code\Exception;
014 use Zend\Code\NameInformation;
015
016 class PropertyScanner implements ScannerInterface
017 {
018 const T_BOOLEAN = "boolean";
019 const T_INTEGER = "int";
020 const T_STRING = "string";
021 const T_ARRAY = "array";
022 const T_UNKNOWN = "unknown";
023
024 /**
025 * @var bool
026 */
027 protected $isScanned = false;
028
029 /**
030 * @var array
031 */
032 protected $tokens;
033
034 /**
035 * @var NameInformation
036 */
037 protected $nameInformation;
038
039 /**
040 * @var string
041 */
042 protected $class;
043
044 /**
045 * @var ClassScanner
046 */
047 protected $scannerClass;
048
049 /**
050 * @var int
051 */
052 protected $lineStart;
053
054 /**
055 * @var bool
056 */
057 protected $isProtected = false;
058
059 /**
060 * @var bool
061 */
062 protected $isPublic = true;
063
064 /**
065 * @var bool
066 */
067 protected $isPrivate = false;
068
069 /**
070 * @var bool
071 */
072 protected $isStatic = false;
073
074 /**
075 * @var string
076 */
077 protected $docComment;
078
079 /**
080 * @var string
081 */
082 protected $name;
083
084 /**
085 * @var string
086 */
087 protected $value;
088
089 /**
090 * @var string
091 */
092 protected $valueType;
093
094 /**
095 * Constructor
096 *
097 * @param array $propertyTokens
098 * @param NameInformation $nameInformation
099 */
100 public function __construct(array $propertyTokens, NameInformation $nameInformation = null)
101 {
102 $this->tokens = $propertyTokens;
103 $this->nameInformation = $nameInformation;
104 }
105
106 /**
107 * @param string $class
108 */
109 public function setClass($class)
110 {
111 $this->class = $class;
112 }
113
114 /**
115 * @param ClassScanner $scannerClass
116 */
117 public function setScannerClass(ClassScanner $scannerClass)
118 {
119 $this->scannerClass = $scannerClass;
120 }
121
122 /**
123 * @return ClassScanner
124 */
125 public function getClassScanner()
126 {
127 return $this->scannerClass;
128 }
129
130 /**
131 * @return string
132 */
133 public function getName()
134 {
135 $this->scan();
136 return $this->name;
137 }
138
139 /**
140 * @return string
141 */
142 public function getValueType()
143 {
144 return $this->valueType;
145 }
146
147 /**
148 * @return bool
149 */
150 public function isPublic()
151 {
152 $this->scan();
153 return $this->isPublic;
154 }
155
156 /**
157 * @return bool
158 */
159 public function isPrivate()
160 {
161 $this->scan();
162 return $this->isPrivate;
163 }
164
165 /**
166 * @return bool
167 */
168 public function isProtected()
169 {
170 $this->scan();
171 return $this->isProtected;
172 }
173
174 /**
175 * @return bool
176 */
177 public function isStatic()
178 {
179 $this->scan();
180 return $this->isStatic;
181 }
182
183 /**
184 * @return string
185 */
186 public function getValue()
187 {
188 $this->scan();
189 return $this->value;
190 }
191
192 /**
193 * @return string
194 */
195 public function getDocComment()
196 {
197 $this->scan();
198 return $this->docComment;
199 }
200
201 /**
202 * @param Annotation\AnnotationManager $annotationManager
203 * @return AnnotationScanner
204 */
205 public function getAnnotations(Annotation\AnnotationManager $annotationManager)
206 {
207 if (($docComment = $this->getDocComment()) == '') {
208 return false;
209 }
210
211 return new AnnotationScanner($annotationManager, $docComment, $this->nameInformation);
212 }
213
214 /**
215 * @return string
216 */
217 public function __toString()
218 {
219 $this->scan();
220 return var_export($this, true);
221 }
222
223 /**
224 * Scan tokens
225 *
226 * @throws \Zend\Code\Exception\RuntimeException
227 */
228 protected function scan()
229 {
230 if ($this->isScanned) {
231 return;
232 }
233
234 if (!$this->tokens) {
235 throw new Exception\RuntimeException('No tokens were provided');
236 }
237
238 /**
239 * Variables & Setup
240 */
241 $value = '';
242 $concatenateValue = false;
243
244 $tokens = &$this->tokens;
245 reset($tokens);
246
247 foreach ($tokens as $token) {
248 $tempValue = $token;
249 if (!is_string($token)) {
250 list($tokenType, $tokenContent, $tokenLine) = $token;
251
252 switch ($tokenType) {
253 case T_DOC_COMMENT:
254 if ($this->docComment === null && $this->name === null) {
255 $this->docComment = $tokenContent;
256 }
257 break;
258
259 case T_VARIABLE:
260 $this->name = ltrim($tokenContent, '$');
261 break;
262
263 case T_PUBLIC:
264 // use defaults
265 break;
266
267 case T_PROTECTED:
268 $this->isProtected = true;
269 $this->isPublic = false;
270 break;
271
272 case T_PRIVATE:
273 $this->isPrivate = true;
274 $this->isPublic = false;
275 break;
276
277 case T_STATIC:
278 $this->isStatic = true;
279 break;
280 default:
281 $tempValue = trim($tokenContent);
282 break;
283 }
284 }
285
286 //end value concatenation
287 if (!is_array($token) && trim($token) == ";") {
288 $concatenateValue = false;
289 }
290
291 if (true === $concatenateValue) {
292 $value .= $tempValue;
293 }
294
295 //start value concatenation
296 if (!is_array($token) && trim($token) == "=") {
297 $concatenateValue = true;
298 }
299 }
300
301 $this->valueType = self::T_UNKNOWN;
302 if ($value == "false" || $value == "true") {
303 $this->valueType = self::T_BOOLEAN;
304 } elseif (is_numeric($value)) {
305 $this->valueType = self::T_INTEGER;
306 } elseif (0 === strpos($value, 'array') || 0 === strpos($value, "[")) {
307 $this->valueType = self::T_ARRAY;
308 } elseif (substr($value, 0, 1) === '"' || substr($value, 0, 1) === "'") {
309 $value = substr($value, 1, -1); // Remove quotes
310 $this->valueType = self::T_STRING;
311 }
312
313 $this->value = empty($value) ? null : $value;
314 $this->isScanned = true;
315 }
316 }
317