function TokenIterator::hasTokenImmediatelyBefore
* Check whether the position is directly preceded by a certain token type. * * During this check TOKEN_HORIZONTAL_WS and TOKEN_PHPDOC_EOL are skipped
1 call to TokenIterator::hasTokenImmediatelyBefore()
- TokenIterator::hasParentheses in vendor/
phpstan/ phpdoc-parser/ src/ Parser/ TokenIterator.php - * Whether the given position is immediately surrounded by parenthesis.
File
-
vendor/
phpstan/ phpdoc-parser/ src/ Parser/ TokenIterator.php, line 323
Class
Namespace
PHPStan\PhpDocParser\ParserCode
public function hasTokenImmediatelyBefore(int $pos, int $expectedTokenType) : bool {
$tokens = $this->tokens;
$pos--;
for (; $pos >= 0; $pos--) {
$token = $tokens[$pos];
$type = $token[Lexer::TYPE_OFFSET];
if ($type === $expectedTokenType) {
return true;
}
if (!in_array($type, [
Lexer::TOKEN_HORIZONTAL_WS,
Lexer::TOKEN_PHPDOC_EOL,
], true)) {
break;
}
}
return false;
}