PluginProbe
System Dashboard / 2.8.3
System Dashboard v2.8.3
trunk 1.0.0 1.1.0 1.1.1 1.2.0 1.3.0 1.3.1 1.3.2 1.4.0 1.5.1 1.5.2 1.6.0 1.7.1 1.7.2 1.8.0 1.9.0 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.1 All 62 releases
system-dashboard / vendor / phpdocumentor / reflection / src / phpDocumentor / Reflection / Lexer.php

Lexer.php in System Dashboard 2.8.3, at vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Lexer.php

75 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * phpDocumentor
4 *
5 * PHP Version 5.3
6 *
7 * @author Mike van Riel <mike.vanriel@naenius.com>
8 * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
9 * @license http://www.opensource.org/licenses/mit-license.php MIT
10 * @link http://phpdoc.org
11 */
12
13 namespace phpDocumentor\Reflection;
14
15 use PhpParser\Lexer as BaseLexer;
16 use PhpParser\Parser;
17
18 /**
19 * Custom lexer for phpDocumentor.
20 *
21 * phpDocumentor has a custom Lexer for PHP-Parser because it needs
22 * unmodified value for Scalar variables instead of an interpreted version.
23 *
24 * If the interpreted version was to be used then the XML interpretation would
25 * fail because of special characters.
26 *
27 * @author Mike van Riel <mike.vanriel@naenius.com>
28 * @license http://www.opensource.org/licenses/mit-license.php MIT
29 * @link http://phpdoc.org
30 */
31 class Lexer extends BaseLexer
32 {
33 /**
34 * Retrieves the next token and determines the associated attributes and
35 * returns the token id.
36 *
37 * @param string $value
38 * @param string[] $startAttributes
39 * @param string[] $endAttributes
40 *
41 * @return int
42 */
43 public function getNextToken(
44 &$value = null,
45 &$startAttributes = null,
46 &$endAttributes = null
47 ) {
48 $tokenId = parent::getNextToken($value, $startAttributes, $endAttributes);
49
50 if ($this->isTokenScalar($tokenId)) {
51 // store original value because the value itself will be interpreted
52 // by PHP_Parser and we want the unformatted value
53 $endAttributes['originalValue'] = $value;
54 }
55
56 return $tokenId;
57 }
58
59 /**
60 * Returns whether the given token id is a scalar that will be interpreted
61 * by PHP-Parser.
62 *
63 * @param int $tokenId The id to check, must match a \PhpParser_Parser::T_*
64 * constant.
65 *
66 * @return bool
67 */
68 protected function isTokenScalar($tokenId)
69 {
70 return $tokenId == Parser::T_CONSTANT_ENCAPSED_STRING
71 || $tokenId == Parser::T_LNUMBER
72 || $tokenId == Parser::T_DNUMBER;
73 }
74 }
75