Simplify handleHaltCompiler() implementation

Nowadays we're already tracking the filePos, no need to
recompute it.
This commit is contained in:
Nikita Popov 2015-06-20 12:04:40 +02:00
parent bb2c5303ae
commit 179d32cfaf

View File

@ -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