Mercurial > hg > isophonics-drupal-site
comparison vendor/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children |
comparison
equal
deleted
inserted
replaced
11:bfffd8d7479a | 12:7a779792577d |
---|---|
135 $contents = $matches[0]; | 135 $contents = $matches[0]; |
136 } | 136 } |
137 } | 137 } |
138 $tokenParser = new TokenParser($contents); | 138 $tokenParser = new TokenParser($contents); |
139 $docComment = ''; | 139 $docComment = ''; |
140 $last_token = false; | |
141 | |
140 while ($token = $tokenParser->next(false)) { | 142 while ($token = $tokenParser->next(false)) { |
141 if (is_array($token)) { | 143 if (is_array($token)) {switch ($token[0]) { |
142 switch ($token[0]) { | 144 case T_USE: |
143 case T_USE: | 145 $this->useStatements = array_merge($this->useStatements, $tokenParser->parseUseStatement()); |
144 $this->useStatements = array_merge($this->useStatements, $tokenParser->parseUseStatement()); | 146 break; |
145 break; | 147 case T_DOC_COMMENT: |
146 case T_DOC_COMMENT: | 148 $docComment = $token[1]; |
147 $docComment = $token[1]; | 149 break; |
148 break; | 150 case T_CLASS: |
149 case T_CLASS: | 151 if ($last_token !== T_PAAMAYIM_NEKUDOTAYIM) {$this->docComment['class'] = $docComment; |
150 $this->docComment['class'] = $docComment; | 152 $docComment = '';} |
151 $docComment = ''; | 153 break; |
152 break; | 154 case T_VAR: |
153 case T_VAR: | 155 case T_PRIVATE: |
154 case T_PRIVATE: | 156 case T_PROTECTED: |
155 case T_PROTECTED: | 157 case T_PUBLIC: |
156 case T_PUBLIC: | 158 $token = $tokenParser->next(); |
157 $token = $tokenParser->next(); | 159 if ($token[0] === T_VARIABLE) { |
158 if ($token[0] === T_VARIABLE) { | 160 $propertyName = substr($token[1], 1); |
159 $propertyName = substr($token[1], 1); | 161 $this->docComment['property'][$propertyName] = $docComment; |
160 $this->docComment['property'][$propertyName] = $docComment; | 162 continue 2; |
161 continue 2; | 163 } |
164 if ($token[0] !== T_FUNCTION) { | |
165 // For example, it can be T_FINAL. | |
166 continue 2; | |
167 } | |
168 // No break. | |
169 case T_FUNCTION: | |
170 // The next string after function is the name, but | |
171 // there can be & before the function name so find the | |
172 // string. | |
173 while (($token = $tokenParser->next()) && $token[0] !== T_STRING); | |
174 $methodName = $token[1]; | |
175 $this->docComment['method'][$methodName] = $docComment; | |
176 $docComment = ''; | |
177 break; | |
178 case T_EXTENDS: | |
179 $this->parentClassName = $tokenParser->parseClass(); | |
180 $nsPos = strpos($this->parentClassName, '\\'); | |
181 $fullySpecified = false; | |
182 if ($nsPos === 0) { | |
183 $fullySpecified = true; | |
184 } else { | |
185 if ($nsPos) { | |
186 $prefix = strtolower(substr($this->parentClassName, 0, $nsPos)); | |
187 $postfix = substr($this->parentClassName, $nsPos); | |
188 } else { | |
189 $prefix = strtolower($this->parentClassName); | |
190 $postfix = ''; | |
162 } | 191 } |
163 if ($token[0] !== T_FUNCTION) { | 192 foreach ($this->useStatements as $alias => $use) { |
164 // For example, it can be T_FINAL. | 193 if ($alias == $prefix) { |
165 continue 2; | 194 $this->parentClassName = '\\' . $use . $postfix; |
195 $fullySpecified = true; | |
196 } | |
166 } | 197 } |
167 // No break. | 198 } |
168 case T_FUNCTION: | 199 if (!$fullySpecified) { |
169 // The next string after function is the name, but | 200 $this->parentClassName = '\\' . $this->namespace . '\\' . $this->parentClassName; |
170 // there can be & before the function name so find the | 201 } |
171 // string. | 202 break;} |
172 while (($token = $tokenParser->next()) && $token[0] !== T_STRING); | |
173 $methodName = $token[1]; | |
174 $this->docComment['method'][$methodName] = $docComment; | |
175 $docComment = ''; | |
176 break; | |
177 case T_EXTENDS: | |
178 $this->parentClassName = $tokenParser->parseClass(); | |
179 $nsPos = strpos($this->parentClassName, '\\'); | |
180 $fullySpecified = false; | |
181 if ($nsPos === 0) { | |
182 $fullySpecified = true; | |
183 } else { | |
184 if ($nsPos) { | |
185 $prefix = strtolower(substr($this->parentClassName, 0, $nsPos)); | |
186 $postfix = substr($this->parentClassName, $nsPos); | |
187 } else { | |
188 $prefix = strtolower($this->parentClassName); | |
189 $postfix = ''; | |
190 } | |
191 foreach ($this->useStatements as $alias => $use) { | |
192 if ($alias == $prefix) { | |
193 $this->parentClassName = '\\' . $use . $postfix; | |
194 $fullySpecified = true; | |
195 } | |
196 } | |
197 } | |
198 if (!$fullySpecified) { | |
199 $this->parentClassName = '\\' . $this->namespace . '\\' . $this->parentClassName; | |
200 } | |
201 break; | |
202 } | |
203 } | 203 } |
204 | |
205 $last_token = $token[0]; | |
204 } | 206 } |
205 } | 207 } |
206 | 208 |
207 /** | 209 /** |
208 * @return StaticReflectionParser | 210 * @return StaticReflectionParser |