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

Breadcrumb

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

function AbstractScopeSniff::__construct

Constructs a new AbstractScopeTest.

Parameters

array $scopeTokens The type of scope the test wishes to listen to.:

array $tokens The tokens that the test wishes to listen to: within the scope.

boolean $listenOutside If true this test will also alert the: extending class when a token is found outside the scope, by calling the processTokenOutsideScope method.

Throws

\PHP_CodeSniffer\Exceptions\RuntimeException If the specified tokens arrays are empty or invalid.

23 calls to AbstractScopeSniff::__construct()
AbstractVariableSniff::__construct in vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractVariableSniff.php
Constructs an AbstractVariableTest.
AbstractVariableSniff::__construct in vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractVariableSniff.php
Constructs an AbstractVariableTest.
CamelCapsFunctionNameSniff::__construct in vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php
Constructs a Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff.
CamelCapsFunctionNameSniff::__construct in vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php
Constructs a Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff.
ConstructorNameSniff::__construct in vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php
Constructs the test with the tokens it wishes to listen for.

... See full list

11 methods override AbstractScopeSniff::__construct()
AbstractVariableSniff::__construct in vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractVariableSniff.php
Constructs an AbstractVariableTest.
CamelCapsFunctionNameSniff::__construct in vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php
Constructs a Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff.
ConstructorNameSniff::__construct in vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php
Constructs the test with the tokens it wishes to listen for.
IncludeSystemSniff::__construct in vendor/squizlabs/php_codesniffer/src/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php
Constructs an AbstractScopeSniff.
MethodDeclarationSniff::__construct in vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php
Constructs a Squiz_Sniffs_Scope_MethodScopeSniff.

... See full list

File

vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractScopeSniff.php, line 71

Class

AbstractScopeSniff

Namespace

PHP_CodeSniffer\Sniffs

Code

public function __construct(array $scopeTokens, array $tokens, $listenOutside = false) {
    if (empty($scopeTokens) === true) {
        $error = 'The scope tokens list cannot be empty';
        throw new RuntimeException($error);
    }
    if (empty($tokens) === true) {
        $error = 'The tokens list cannot be empty';
        throw new RuntimeException($error);
    }
    $invalidScopeTokens = array_intersect($scopeTokens, $tokens);
    if (empty($invalidScopeTokens) === false) {
        $invalid = implode(', ', $invalidScopeTokens);
        $error = "Scope tokens [{$invalid}] can't be in the tokens array";
        throw new RuntimeException($error);
    }
    $this->listenOutside = $listenOutside;
    $this->scopeTokens = array_flip($scopeTokens);
    $this->tokens = $tokens;
}

API Navigation

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