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

Breadcrumb

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

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

TokenIterator

Namespace

PHPStan\PhpDocParser\Parser

Code

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

API Navigation

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