src/php/CTXParser/Parser.php
private function read(array $types, Stack $tokens)
    {
        $token = $tokens->shift();

        if (!in_array($token->type, $types, true)) {
            $names = array();
            foreach ($types as $type) {
                $names[] = $this->tokenizer->getTokenName($type);
            }

            throw new \RuntimeException(
                "Expected one of: " . implode(', ', $names) . ", found " .
                $this->tokenizer->getTokenName($token->type) .
                ". in line {$token->line} at position {$token->position}."
            );
        }

        return $token;
    }
private function read(array $types, Stack $tokens)
    {
        $token = $tokens->shift();

        if (!in_array($token->type, $types, true)) {
            $names = array();
            foreach ($types as $type) {
                $names[] = $this->tokenizer->getTokenName($type);
            }

            throw new \RuntimeException(
                "Expected one of: " . implode(', ', $names) . ", found " .
                $this->tokenizer->getTokenName($token->type) .
                ". in line {$token->line} at position {$token->position}."
            );
        }

        return $token;
    }
private function read ( array $ types , Stack $ tokens ) { $ token = $ tokens -> shift ( ) ; if ( ! in_array ( $ token -> type , $ types , true ) ) { $ names = array ( ) ; foreach ( $ types as $ type ) { $ names [ ] = $ this -> tokenizer -> getTokenName ( $ type ) ; } throw new \ RuntimeException ( "Expected one of: " . implode ( ', ' , $ names ) . ", found " . $ this -> tokenizer -> getTokenName ( $ token -> type ) . ". in line {$token->line} at position {$token->position}." ) ; } return $ token ; }
Read expected from token array

Try to read the given token from the token array. If another token is
found, a parse error is issued. If the token is found, the token is
removed fromt he token array and returned.

@param array $types
@param Token[] $tokens
@return Token
Read expected from token array