diff --git a/lib/PhpParser/Internal/TokenStream.php b/lib/PhpParser/Internal/TokenStream.php index 39308ae629..195863a7fb 100644 --- a/lib/PhpParser/Internal/TokenStream.php +++ b/lib/PhpParser/Internal/TokenStream.php @@ -64,7 +64,8 @@ public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType) : bool $tokens = $this->tokens; $pos--; for (; $pos >= 0; $pos--) { - $tokenType = $tokens[$pos][0]; + $index = is_string($expectedTokenType)?1:0; + $tokenType = $tokens[$pos][$index]; if ($tokenType === $expectedTokenType) { return true; } @@ -90,7 +91,8 @@ public function haveTokenImmediatelyAfter(int $pos, $expectedTokenType) : bool { $tokens = $this->tokens; $pos++; for (; $pos < \count($tokens); $pos++) { - $tokenType = $tokens[$pos][0]; + $index = is_string($expectedTokenType)?1:0; + $tokenType = $tokens[$pos][$index]; if ($tokenType === $expectedTokenType) { return true; }