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

Breadcrumb

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

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

ParserAbstract

Namespace

PhpParser

Code

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

API Navigation

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