function Scanner::isBefore
Checks if one of the given strings follows the current scan position
Parameters
string|array $expected String or array of strings to check:
bool $nextToken This parameter must be true if the first: parameter is an array so that it will check also next tokens
Return value
bool
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Scanner.php, line 762
Class
- Scanner
- Base class for scanners.
Namespace
Peast\SyntaxCode
public function isBefore($expected, $nextToken = false) {
$token = $this->currentToken ?: $this->getToken();
if (!$token) {
return false;
}
elseif (in_array($token->value, $expected)) {
return true;
}
elseif (!$nextToken) {
return false;
}
if (!$this->getNextToken()) {
return false;
}
foreach ($expected as $val) {
if (!is_array($val) || $val[0] !== $token->value) {
continue;
}
//If the second value in the array is true check that the current
//token is not followed by line terminators, otherwise compare its
//value to the next token
if ($val[1] === true && $this->noLineTerminators(true) || $val[1] !== true && $val[1] === $this->nextToken->value) {
return true;
}
}
return false;
}