fix calendar css, take 2. (#213)
[openemr.git] / interface / modules / zend_modules / library / Zend / Code / Scanner / ConstantScanner.php
blobf2a81da5183a2fd8213492eed15fa8ebe14a88f7
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-2015 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 ConstantScanner 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 string
51 protected $docComment;
53 /**
54 * @var string
56 protected $name;
58 /**
59 * @var string
61 protected $value;
63 /**
64 * Constructor
66 * @param array $constantTokens
67 * @param NameInformation $nameInformation
69 public function __construct(array $constantTokens, NameInformation $nameInformation = null)
71 $this->tokens = $constantTokens;
72 $this->nameInformation = $nameInformation;
75 /**
76 * @param string $class
78 public function setClass($class)
80 $this->class = $class;
83 /**
84 * @param ClassScanner $scannerClass
86 public function setScannerClass(ClassScanner $scannerClass)
88 $this->scannerClass = $scannerClass;
91 /**
92 * @return ClassScanner
94 public function getClassScanner()
96 return $this->scannerClass;
99 /**
100 * @return string
102 public function getName()
104 $this->scan();
105 return $this->name;
109 * @return string
111 public function getValue()
113 $this->scan();
114 return $this->value;
118 * @return string
120 public function getDocComment()
122 $this->scan();
123 return $this->docComment;
127 * @param Annotation\AnnotationManager $annotationManager
128 * @return AnnotationScanner
130 public function getAnnotations(Annotation\AnnotationManager $annotationManager)
132 if (($docComment = $this->getDocComment()) == '') {
133 return false;
136 return new AnnotationScanner($annotationManager, $docComment, $this->nameInformation);
140 * @return string
142 public function __toString()
144 $this->scan();
145 return var_export($this, true);
149 * Scan tokens
151 * @throws Exception\RuntimeException
153 protected function scan()
155 if ($this->isScanned) {
156 return;
159 if (!$this->tokens) {
160 throw new Exception\RuntimeException('No tokens were provided');
164 * Variables & Setup
166 $tokens = &$this->tokens;
168 reset($tokens);
170 SCANNER_TOP:
172 $token = current($tokens);
174 if (!is_string($token)) {
175 list($tokenType, $tokenContent, $tokenLine) = $token;
177 switch ($tokenType) {
178 case T_DOC_COMMENT:
179 if ($this->docComment === null && $this->name === null) {
180 $this->docComment = $tokenContent;
182 goto SCANNER_CONTINUE;
183 // fall-through
185 case T_STRING:
186 $string = (is_string($token)) ? $token : $tokenContent;
188 if (null === $this->name) {
189 $this->name = $string;
190 } else {
191 if ('self' == strtolower($string)) {
192 list($tokenNextType, $tokenNextContent, $tokenNextLine) = next($tokens);
194 if ('::' == $tokenNextContent) {
195 list($tokenNextType, $tokenNextContent, $tokenNextLine) = next($tokens);
197 if ($this->getClassScanner()->getConstant($tokenNextContent)) {
198 $this->value = $this->getClassScanner()->getConstant($tokenNextContent)->getValue();
204 goto SCANNER_CONTINUE;
205 // fall-through
207 case T_CONSTANT_ENCAPSED_STRING:
208 case T_DNUMBER:
209 case T_LNUMBER:
210 $string = (is_string($token)) ? $token : $tokenContent;
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;
217 goto SCANNER_CONTINUE;
218 // fall-trough
220 default:
221 goto SCANNER_CONTINUE;
225 SCANNER_CONTINUE:
227 if (next($this->tokens) === false) {
228 goto SCANNER_END;
230 goto SCANNER_TOP;
232 SCANNER_END:
234 $this->isScanned = true;