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

Breadcrumb

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

function Scanner::isBefore

Checks if one of the given strings follows the current scan position

Parameters

string|array $expected String or array of strings to check:

bool $nextToken This parameter must be true if the first: parameter is an array so that it will check also next tokens

Return value

bool

File

vendor/mck89/peast/lib/Peast/Syntax/Scanner.php, line 762

Class

Scanner
Base class for scanners.

Namespace

Peast\Syntax

Code

public function isBefore($expected, $nextToken = false) {
    $token = $this->currentToken ?: $this->getToken();
    if (!$token) {
        return false;
    }
    elseif (in_array($token->value, $expected)) {
        return true;
    }
    elseif (!$nextToken) {
        return false;
    }
    if (!$this->getNextToken()) {
        return false;
    }
    foreach ($expected as $val) {
        if (!is_array($val) || $val[0] !== $token->value) {
            continue;
        }
        
        //If the second value in the array is true check that the current
        
        //token is not followed by line terminators, otherwise compare its
        
        //value to the next token
        if ($val[1] === true && $this->noLineTerminators(true) || $val[1] !== true && $val[1] === $this->nextToken->value) {
            return true;
        }
    }
    return false;
}

API Navigation

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