mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-30 04:29:15 +01:00
Simplify handleHaltCompiler() implementation
Nowadays we're already tracking the filePos, no need to recompute it.
This commit is contained in:
parent
bb2c5303ae
commit
179d32cfaf
@ -220,18 +220,8 @@ class Lexer
|
||||
* @return string Remaining text
|
||||
*/
|
||||
public function handleHaltCompiler() {
|
||||
// get the length of the text before the T_HALT_COMPILER token
|
||||
$textBefore = '';
|
||||
for ($i = 0; $i <= $this->pos; ++$i) {
|
||||
if (is_string($this->tokens[$i])) {
|
||||
$textBefore .= $this->tokens[$i];
|
||||
} else {
|
||||
$textBefore .= $this->tokens[$i][1];
|
||||
}
|
||||
}
|
||||
|
||||
// text after T_HALT_COMPILER, still including ();
|
||||
$textAfter = substr($this->code, strlen($textBefore));
|
||||
$textAfter = substr($this->code, $this->filePos);
|
||||
|
||||
// ensure that it is followed by ();
|
||||
// this simplifies the situation, by not allowing any comments
|
||||
|
Loading…
Reference in New Issue
Block a user