public function handleToken(TokenInterface $token = null)
    {
        $token = $token ?: $this->getToken();
        $className = get_class($token);
        $tokenHandlers = $this->getOption('token_handlers');

        if (!isset($tokenHandlers[$className])) {
            $this->throwException(
                "Unexpected token `$className`, no token handler registered",
                0,
                $token
            );
        }

        $handler = $tokenHandlers[$className];
        $handler = $handler instanceof TokenHandlerInterface
            ? $handler
            : $this->getNamedHandler($handler);

        $handler->handleToken($token, $this);

        return $this;
    }
public function handleToken(TokenInterface $token = null)
    {
        $token = $token ?: $this->getToken();
        $className = get_class($token);
        $tokenHandlers = $this->getOption('token_handlers');

        if (!isset($tokenHandlers[$className])) {
            $this->throwException(
                "Unexpected token `$className`, no token handler registered",
                0,
                $token
            );
        }

        $handler = $tokenHandlers[$className];
        $handler = $handler instanceof TokenHandlerInterface
            ? $handler
            : $this->getNamedHandler($handler);

        $handler->handleToken($token, $this);

        return $this;
    }
public function handleToken ( TokenInterface $ token = null ) { $ token = $ token ? : $ this -> getToken ( ) ; $ className = get_class ( $ token ) ; $ tokenHandlers = $ this -> getOption ( 'token_handlers' ) ; if ( ! isset ( $ tokenHandlers [ $ className ] ) ) { $ this -> throwException ( "Unexpected token `$className`, no token handler registered" , 0 , $ token ) ; } $ handler = $ tokenHandlers [ $ className ] ; $ handler = $ handler instanceof TokenHandlerInterface ? $ handler : $ this -> getNamedHandler ( $ handler ) ; $ handler -> handleToken ( $ token , $ this ) ; return $ this ; }
Handles any kind of token returned by the lexer.

The token handler is translated according to the `token_handlers` option

If no token is passed, it will take the current token
in the lexer's token generator

@param TokenInterface $token a token or the current lexer's generator token

@throws ParserException when no token handler has been found

@return $this
Handles any kind of token returned by the lexer .