function ParserAbstract::maybeCreateZeroLengthNop
Create a zero-length nop to capture preceding comments, if any.
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ ParserAbstract.php, line 922
Class
Namespace
PhpParserCode
protected function maybeCreateZeroLengthNop(int $tokenPos) : ?Nop {
$comment = $this->getCommentBeforeToken($tokenPos);
if ($comment === null) {
return null;
}
$commentEndLine = $comment->getEndLine();
$commentEndFilePos = $comment->getEndFilePos();
$commentEndTokenPos = $comment->getEndTokenPos();
$attributes = [
'startLine' => $commentEndLine,
'endLine' => $commentEndLine,
'startFilePos' => $commentEndFilePos + 1,
'endFilePos' => $commentEndFilePos,
'startTokenPos' => $commentEndTokenPos + 1,
'endTokenPos' => $commentEndTokenPos,
];
return new Nop($attributes);
}