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
Namespace
PHP_CodeSniffer\FilesCode
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;
}