Automattic\WooCommerce\Vendor\GraphQL\Language
Parser::expect
If the next token is of the given kind, return that token after advancing the parser. Otherwise, do not change the parser state and return false.
Method of the class: Parser{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->expect( $kind ): Token;
- $kind(string) (required)
- .
Parser::expect() Parser::expect code WC 11.0.1
private function expect(string $kind): Token
{
$token = $this->lexer->token;
if ($token->kind === $kind) {
$this->lexer->advance();
return $token;
}
throw new SyntaxError($this->lexer->source, $token->start, "Expected {$kind}, found {$token->getDescription()}");
}