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

Breadcrumb

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

function File::hasCondition

Determine if the passed token has a condition of one of the passed types.

Parameters

int $stackPtr The position of the token we are checking.:

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

Return value

boolean

File

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

Class

File

Namespace

PHP_CodeSniffer\Files

Code

public function hasCondition($stackPtr, $types) {
    // Check for the existence of the token.
    if (isset($this->tokens[$stackPtr]) === false) {
        return false;
    }
    // Make sure the token has conditions.
    if (empty($this->tokens[$stackPtr]['conditions']) === true) {
        return false;
    }
    $types = (array) $types;
    $conditions = $this->tokens[$stackPtr]['conditions'];
    foreach ($types as $type) {
        if (in_array($type, $conditions, true) === true) {
            // We found a token with the required type.
            return true;
        }
    }
    return false;
}
RSS feed
Powered by Drupal