X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fnikic%2Fphp-parser%2Flib%2FPhpParser%2FLexer.php;fp=vendor%2Fnikic%2Fphp-parser%2Flib%2FPhpParser%2FLexer.php;h=75d3f35a39539699407b70e37445e0205271acc7;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=52226c7a59a566697d93edafb79eba15fe46e988;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/vendor/nikic/php-parser/lib/PhpParser/Lexer.php b/vendor/nikic/php-parser/lib/PhpParser/Lexer.php index 52226c7a5..75d3f35a3 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Lexer.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Lexer.php @@ -185,15 +185,17 @@ class Lexer return; } - // Check for unterminated comment - $lastToken = $this->tokens[count($this->tokens) - 1]; - if ($this->isUnterminatedComment($lastToken)) { - $errorHandler->handleError(new Error('Unterminated comment', [ - 'startLine' => $line - substr_count($lastToken[1], "\n"), - 'endLine' => $line, - 'startFilePos' => $filePos - \strlen($lastToken[1]), - 'endFilePos' => $filePos, - ])); + if (count($this->tokens) > 0) { + // Check for unterminated comment + $lastToken = $this->tokens[count($this->tokens) - 1]; + if ($this->isUnterminatedComment($lastToken)) { + $errorHandler->handleError(new Error('Unterminated comment', [ + 'startLine' => $line - substr_count($lastToken[1], "\n"), + 'endLine' => $line, + 'startFilePos' => $filePos - \strlen($lastToken[1]), + 'endFilePos' => $filePos, + ])); + } } } @@ -358,7 +360,7 @@ class Lexer if ('T_HASHBANG' === $name) { // HHVM uses a special token for #! hashbang lines $tokenMap[$i] = Tokens::T_INLINE_HTML; - } else if (defined($name = 'PhpParser\Parser\Tokens::' . $name)) { + } else if (defined($name = Tokens::class . '::' . $name)) { // Other tokens can be mapped directly $tokenMap[$i] = constant($name); }