tokens = token_get_all('tokens); $key = key($this->tokens); // FIXME this workaround should be dropped while ($token && $token[0] === T_STRING && isset($this->tokens[$key + 2]) && $this->tokens[++$key] === '-' && $this->tokens[++$key][0] === T_STRING) { $token[1] .= '-' . $this->tokens[$key][1]; next($this->tokens); next($this->tokens); } } while (is_array($token) && $token[0] === T_WHITESPACE); if (is_string($token) || $token === false) { $this->token_type = $token; $this->token_value = NULL; } else { $this->token_type = $token[0]; switch ($token[0]) { case T_CONSTANT_ENCAPSED_STRING: $this->token_value = stripcslashes(substr($token[1], 1, -1)); break; case T_DNUMBER: $this->token_value = (double) $token[1]; break; case T_LNUMBER: $this->token_value = (int) $token[1]; break; default: $this->token_value = $token[1]; } } return $this->token_type; } /** * Returns the current token type. The valid token types are * those defined for token_get_all() in the PHP documentation. */ public function tokenType() { return $this->token_type; } /** * Returns the current token value if the token type supports * a value (T_STRING, T_LNUMBER etc.). Returns NULL otherwise. */ public function tokenValue() { return $this->token_value; } }