function File::getCondition
Return the position of the condition for the passed token.
Returns FALSE if the token does not have the condition.
Parameters
int $stackPtr The position of the token we are checking.:
int|string $type The type of token to search for.:
bool $first If TRUE, will return the matched condition: furthest away from the passed token. If FALSE, will return the matched condition closest to the passed token.
Return value
int|false
1 call to File::getCondition()
- File::findEndOfStatement in vendor/
squizlabs/ php_codesniffer/ src/ Files/ File.php - Returns the position of the last non-whitespace token in a statement.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Files/ File.php, line 2818
Class
Namespace
PHP_CodeSniffer\FilesCode
public function getCondition($stackPtr, $type, $first = true) {
// 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;
}
$conditions = $this->tokens[$stackPtr]['conditions'];
if ($first === false) {
$conditions = array_reverse($conditions, true);
}
foreach ($conditions as $token => $condition) {
if ($condition === $type) {
return $token;
}
}
return false;
}