GraphQL\Language\Token::getKindDescription PHP Method

getKindDescription() public static method

public static getKindDescription ( $kind ) : mixed
$kind
return mixed
    public static function getKindDescription($kind)
    {
        trigger_error('Deprecated as of 16.10.2016 ($kind itself contains description string now)', E_USER_DEPRECATED);
        $description = [];
        $description[self::SOF] = '<SOF>';
        $description[self::EOF] = '<EOF>';
        $description[self::BANG] = '!';
        $description[self::DOLLAR] = '$';
        $description[self::PAREN_L] = '(';
        $description[self::PAREN_R] = ')';
        $description[self::SPREAD] = '...';
        $description[self::COLON] = ':';
        $description[self::EQUALS] = '=';
        $description[self::AT] = '@';
        $description[self::BRACKET_L] = '[';
        $description[self::BRACKET_R] = ']';
        $description[self::BRACE_L] = '{';
        $description[self::PIPE] = '|';
        $description[self::BRACE_R] = '}';
        $description[self::NAME] = 'Name';
        $description[self::INT] = 'Int';
        $description[self::FLOAT] = 'Float';
        $description[self::STRING] = 'String';
        $description[self::COMMENT] = 'Comment';
        return $description[$kind];
    }

Usage Example

Example #1
0
 /**
  * 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.
  * @param string $kind
  * @return Token
  * @throws Exception
  */
 function expect($kind)
 {
     $token = $this->token;
     if ($token->kind === $kind) {
         $this->advance();
         return $token;
     }
     throw Exception::create($this->source, $token->start, "Expected " . Token::getKindDescription($kind) . ", found " . $token->getDescription());
 }