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

Breadcrumb

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

function File::findNext

Returns the position of the next specified token(s).

If a value is specified, the next token of the specified type(s) containing the specified value will be returned.

Returns false if no token can be found.

Parameters

int|string|array $types The type(s) of tokens to search for.:

int $start The position to start searching from in the: token stack.

int|null $end The end position to fail if no token is found.: if not specified or null, end will default to the end of the token stack.

bool $exclude If true, find the next token that is NOT of: a type specified in $types.

string|null $value The value that the token(s) must be equal to.: If value is omitted, tokens with any value will be returned.

bool $local If true, tokens outside the current statement: will not be checked. i.e., checking will stop at the next semicolon found.

Return value

int|false

See also

findPrevious()

7 calls to File::findNext()
File::findEndOfStatement in vendor/squizlabs/php_codesniffer/src/Files/File.php
Returns the position of the last non-whitespace token in a statement.
File::findExtendedClassName in vendor/squizlabs/php_codesniffer/src/Files/File.php
Returns the name of the class that the specified class extends. (works for classes, anonymous classes and interfaces)
File::findImplementedInterfaceNames in vendor/squizlabs/php_codesniffer/src/Files/File.php
Returns the names of the interfaces that the specified class or enum implements.
File::findStartOfStatement in vendor/squizlabs/php_codesniffer/src/Files/File.php
Returns the position of the first non-whitespace token in a statement.
File::getMethodParameters in vendor/squizlabs/php_codesniffer/src/Files/File.php
Returns the method parameters for the specified function token.

... See full list

File

vendor/squizlabs/php_codesniffer/src/Files/File.php, line 2361

Class

File

Namespace

PHP_CodeSniffer\Files

Code

public function findNext($types, $start, $end = null, $exclude = false, $value = null, $local = false) {
    $types = (array) $types;
    if ($end === null || $end > $this->numTokens) {
        $end = $this->numTokens;
    }
    for ($i = $start; $i < $end; $i++) {
        $found = (bool) $exclude;
        foreach ($types as $type) {
            if ($this->tokens[$i]['code'] === $type) {
                $found = !$exclude;
                break;
            }
        }
        if ($found === true) {
            if ($value === null) {
                return $i;
            }
            else {
                if ($this->tokens[$i]['content'] === $value) {
                    return $i;
                }
            }
        }
        if ($local === true && $this->tokens[$i]['code'] === T_SEMICOLON) {
            break;
        }
    }
    
    //end for
    return false;
}
RSS feed
Powered by Drupal