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

Breadcrumb

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

function TokenStream::haveTokenImmediatelyAfter

Check whether the position is directly followed by a certain token type.

During this check whitespace and comments are skipped.

Parameters

int $pos Position after which the token should occur:

int|string $expectedTokenType Token to check for:

Return value

bool Whether the expected token was found

2 calls to TokenStream::haveTokenImmediatelyAfter()
TokenStream::haveBraces in vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
Whether the given position is immediately surrounded by braces.
TokenStream::haveParens in vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php
Whether the given position is immediately surrounded by parenthesis.

File

vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php, line 86

Class

TokenStream
Provides operations on token streams, for use by pretty printer.

Namespace

PhpParser\Internal

Code

public function haveTokenImmediatelyAfter(int $pos, $expectedTokenType) : bool {
    $tokens = $this->tokens;
    $pos++;
    for ($c = \count($tokens); $pos < $c; $pos++) {
        $token = $tokens[$pos];
        if ($token->is($expectedTokenType)) {
            return true;
        }
        if (!$token->isIgnorable()) {
            break;
        }
    }
    return false;
}

API Navigation

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