Security update for Core, with self-updated composer
[yaffs-website] / vendor / nikic / php-parser / lib / PhpParser / Lexer.php
index 52226c7a59a566697d93edafb79eba15fe46e988..75d3f35a39539699407b70e37445e0205271acc7 100644 (file)
@@ -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);
                 }