public static function getVariables($template, array $options = array())
{
    $varnames = array();
    foreach (self::getExpressions($template, $options) as $expression) {
        if ($expression['valid']) {
            try {
                $expression = self::parseExpression($expression['expression']);
                foreach ($expression['varspecs'] as $varspec) {
                    try {
                        $varspec = self::parseVarspec($varspec);
                        $varnames[] = $varspec['varname'];
                    } catch (UriTemplateException $e) {
                        continue;
                    }
                }
            } catch (UriTemplateException $e) {
                continue;
            }
        }
    }
    return array_unique($varnames);
}