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.
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.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Sniffs/ AbstractScopeSniff.php, line 71
Class
Namespace
PHP_CodeSniffer\SniffsCode
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;
}