function TokenStream::haveTokenImmediatelyBefore
Check whether the position is directly preceded by a certain token type.
During this check whitespace and comments are skipped.
Parameters
int $pos Position before which the token should occur:
int|string $expectedTokenType Token to check for:
Return value
bool Whether the expected token was found
2 calls to TokenStream::haveTokenImmediatelyBefore()
- TokenStream::haveBraces in vendor/
nikic/ php-parser/ lib/ PhpParser/ Internal/ TokenStream.php - Whether the given position is immediately surrounded by braces.
- TokenStream::haveParens in vendor/
nikic/ php-parser/ lib/ PhpParser/ Internal/ TokenStream.php - Whether the given position is immediately surrounded by parenthesis.
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ Internal/ TokenStream.php, line 61
Class
- TokenStream
- Provides operations on token streams, for use by pretty printer.
Namespace
PhpParser\InternalCode
public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType) : bool {
$tokens = $this->tokens;
$pos--;
for (; $pos >= 0; $pos--) {
$token = $tokens[$pos];
if ($token->is($expectedTokenType)) {
return true;
}
if (!$token->isIgnorable()) {
break;
}
}
return false;
}