Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Code / Scanner / PropertyScanner.php
blob0ba37f6f3310b44a6ddb393a2b2e4db34da418e9
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Code\Scanner;
12 use Zend\Code\Annotation;
13 use Zend\Code\Exception;
14 use Zend\Code\NameInformation;
16 class PropertyScanner implements ScannerInterface
18 /**
19 * @var bool
21 protected $isScanned = false;
23 /**
24 * @var array
26 protected $tokens;
28 /**
29 * @var NameInformation
31 protected $nameInformation;
33 /**
34 * @var string
36 protected $class;
38 /**
39 * @var ClassScanner
41 protected $scannerClass;
43 /**
44 * @var int
46 protected $lineStart;
48 /**
49 * @var bool
51 protected $isProtected = false;
53 /**
54 * @var bool
56 protected $isPublic = true;
58 /**
59 * @var bool
61 protected $isPrivate = false;
63 /**
64 * @var bool
66 protected $isStatic = false;
68 /**
69 * @var string
71 protected $docComment;
73 /**
74 * @var string
76 protected $name;
78 /**
79 * @var string
81 protected $value;
83 /**
84 * Constructor
86 * @param array $propertyTokens
87 * @param NameInformation $nameInformation
89 public function __construct(array $propertyTokens, NameInformation $nameInformation = null)
91 $this->tokens = $propertyTokens;
92 $this->nameInformation = $nameInformation;
95 /**
96 * @param string $class
98 public function setClass($class)
100 $this->class = $class;
104 * @param ClassScanner $scannerClass
106 public function setScannerClass(ClassScanner $scannerClass)
108 $this->scannerClass = $scannerClass;
112 * @return ClassScanner
114 public function getClassScanner()
116 return $this->scannerClass;
120 * @return string
122 public function getName()
124 $this->scan();
125 return $this->name;
129 * @return bool
131 public function isPublic()
133 $this->scan();
134 return $this->isPublic;
138 * @return bool
140 public function isPrivate()
142 $this->scan();
143 return $this->isPrivate;
147 * @return bool
149 public function isProtected()
151 $this->scan();
152 return $this->isProtected;
156 * @return bool
158 public function isStatic()
160 $this->scan();
161 return $this->isStatic;
165 * @return string
167 public function getValue()
169 $this->scan();
170 return $this->value;
174 * @return string
176 public function getDocComment()
178 $this->scan();
179 return $this->docComment;
183 * @param Annotation\AnnotationManager $annotationManager
184 * @return AnnotationScanner
186 public function getAnnotations(Annotation\AnnotationManager $annotationManager)
188 if (($docComment = $this->getDocComment()) == '') {
189 return false;
192 return new AnnotationScanner($annotationManager, $docComment, $this->nameInformation);
196 * @return string
198 public function __toString()
200 $this->scan();
201 return var_export($this, true);
205 * Scan tokens
207 * @throws \Zend\Code\Exception\RuntimeException
209 protected function scan()
211 if ($this->isScanned) {
212 return;
215 if (!$this->tokens) {
216 throw new Exception\RuntimeException('No tokens were provided');
220 * Variables & Setup
222 $tokens = &$this->tokens;
224 reset($tokens);
226 SCANNER_TOP:
228 $token = current($tokens);
230 if (!is_string($token)) {
231 list($tokenType, $tokenContent, $tokenLine) = $token;
233 switch ($tokenType) {
234 case T_DOC_COMMENT:
235 if ($this->docComment === null && $this->name === null) {
236 $this->docComment = $tokenContent;
238 goto SCANNER_CONTINUE;
240 case T_VARIABLE:
241 $this->name = ltrim($tokenContent, '$');
242 goto SCANNER_CONTINUE;
244 case T_PUBLIC:
245 // use defaults
246 goto SCANNER_CONTINUE;
248 case T_PROTECTED:
249 $this->isProtected = true;
250 $this->isPublic = false;
251 goto SCANNER_CONTINUE;
253 case T_PRIVATE:
254 $this->isPrivate = true;
255 $this->isPublic = false;
256 goto SCANNER_CONTINUE;
258 case T_STATIC:
259 $this->isStatic = true;
260 goto SCANNER_CONTINUE;
262 default:
263 if ($this->name !== null && trim($tokenContent) !== '') {
264 $this->value .= (is_string($token)) ? $token : $tokenContent;
265 if (substr($this->value, 0, 1) === '"' || substr($this->value, 0, 1) === "'") {
266 $this->value = substr($this->value, 1, -1); // Remove quotes
269 goto SCANNER_CONTINUE;
273 SCANNER_CONTINUE:
275 if (next($this->tokens) === false) {
276 goto SCANNER_END;
278 goto SCANNER_TOP;
280 SCANNER_END:
282 $this->isScanned = true;