Parser.php
protected function handleToken(array $token = null)
    {

        $token = $token ? $token : $this->getToken();

        //Put together the method name
        $method = 'handle'.ucfirst($token['type']);

        //If the token has no handler, we throw an error
        if (!method_exists($this, $method)) {
            $this->throwException(
                "Unexpected token `{$token['type']}` encountered, no handler $method found. ".
                "It seems you added custom tokens. Please extend the Parser and add a $method-method for that token",
                $token
            );
        } else {

            //Call the handler method and pass the token array as the first argument
            call_user_func([$this, $method], $token);
        }
    }
protected function handleToken(array $token = null)
    {

        $token = $token ? $token : $this->getToken();

        //Put together the method name
        $method = 'handle'.ucfirst($token['type']);

        //If the token has no handler, we throw an error
        if (!method_exists($this, $method)) {
            $this->throwException(
                "Unexpected token `{$token['type']}` encountered, no handler $method found. ".
                "It seems you added custom tokens. Please extend the Parser and add a $method-method for that token",
                $token
            );
        } else {

            //Call the handler method and pass the token array as the first argument
            call_user_func([$this, $method], $token);
        }
    }
protected function handleToken ( array $ token = null ) { $ token = $ token ? $ token : $ this -> getToken ( ) ; //Put together the method name $ method = 'handle' . ucfirst ( $ token [ 'type' ] ) ; //If the token has no handler, we throw an error if ( ! method_exists ( $ this , $ method ) ) { $ this -> throwException ( "Unexpected token `{$token['type']}` encountered, no handler $method found. " . "It seems you added custom tokens. Please extend the Parser and add a $method-method for that token" , $ token ) ; } else { //Call the handler method and pass the token array as the first argument call_user_func ( [ $ this , $ method ] , $ token ) ; } }
Handles any kind of token returned by the lexer dynamically.

The token-type will be translated into a method name
e.g.

newLine      => handleNewLine
attribute    => handleAttribute
tag          => handleTag

First argument of that method will always be the token array

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

@param array|null $token a token or the current lexer's generator token

@throws Exception when no token handler has been found
Handles any kind of token returned by the lexer dynamically .