Skip to content

Commit

Permalink
Fixed type vs string
Browse files Browse the repository at this point in the history
Allow both type and value to be checked
  • Loading branch information
Tommy Quissens committed Nov 8, 2020
1 parent 1d1bc8a commit 0300270
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/PhpParser/Internal/TokenStream.php
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 0300270

Please sign in to comment.