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