Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ParserAbstract.php

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

ParserAbstract

Namespace

PhpParser

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal