function ParserAbstract::getCommentBeforeToken
Get last comment before the given token position, if any
2 calls to ParserAbstract::getCommentBeforeToken()
- ParserAbstract::maybeCreateNop in vendor/
nikic/ php-parser/ lib/ PhpParser/ ParserAbstract.php - ParserAbstract::maybeCreateZeroLengthNop in vendor/
nikic/ php-parser/ lib/ PhpParser/ ParserAbstract.php - Create a zero-length nop to capture preceding comments, if any.
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ ParserAbstract.php, line 905
Class
Namespace
PhpParserCode
protected function getCommentBeforeToken(int $tokenPos) : ?Comment {
while (--$tokenPos >= 0) {
$token = $this->tokens[$tokenPos];
if (!isset($this->dropTokens[$token->id])) {
break;
}
if ($token->id === \T_COMMENT || $token->id === \T_DOC_COMMENT) {
return $this->createCommentFromToken($token, $tokenPos);
}
}
return null;
}