Example #1
0
        } else {
            if (isset($this->»dynamics[$m]) && is_callable($this->»dynamics[$m])) {
                return call_user_func_array($this->»dynamics[$m], $a);
            } else {
                throw new HException('Unable to call «' . $m . '»');
            }
        }
    }
    static $SCHEME_DEFAULT_PORT;
    static $PATTERN_ABS_URI = "\n\t        ([a-zA-Z][-+.a-zA-Z\\d]*):\n\t        (?:\n\t           ((?:[-_.!~*'()a-zA-Z\\d;?:@&=+\$,]|%[a-fA-F\\d]{2})(?:[-_.!~*'()a-zA-Z\\d;/?:@&=+\$,\\[\\]]|%[a-fA-F\\d]{2})*)\n\t        |\n\t           (?:(?:\n\t             //(?:\n\t                 (?:(?:((?:[-_.!~*'()a-zA-Z\\d;:&=+\$,]|%[a-fA-F\\d]{2})*)@)?\n\t                   (?:((?:(?:(?:[a-zA-Z\\d](?:[-a-zA-Z\\d]*[a-zA-Z\\d])?)\\.)*(?:[a-zA-Z](?:[-a-zA-Z\\d]*[a-zA-Z\\d])?)\\.?|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\[(?:(?:[a-fA-F\\d]{1,4}:)*(?:[a-fA-F\\d]{1,4}|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})|(?:(?:[a-fA-F\\d]{1,4}:)*[a-fA-F\\d]{1,4})?::(?:(?:[a-fA-F\\d]{1,4}:)*(?:[a-fA-F\\d]{1,4}|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}))?)\\]))(?::(\\d*))?))?\n\t               |\n\t                 ((?:[-_.!~*'()a-zA-Z\\d\$,;:@&=+]|%[a-fA-F\\d]{2})+)\n\t               )\n\t             |\n\t             (?!//))\n\t             (/(?:[-_.!~*'()a-zA-Z\\d:@&=+\$,]|%[a-fA-F\\d]{2})*(?:;(?:[-_.!~*'()a-zA-Z\\d:@&=+\$,]|%[a-fA-F\\d]{2})*)*(?:/(?:[-_.!~*'()a-zA-Z\\d:@&=+\$,]|%[a-fA-F\\d]{2})*(?:;(?:[-_.!~*'()a-zA-Z\\d:@&=+\$,]|%[a-fA-F\\d]{2})*)*)*)?\n\t           )(?:\\?((?:[-_.!~*'()a-zA-Z\\d;/?:@&=+\$,\\[\\]]|%[a-fA-F\\d]{2})*))?\n\t        )\n\t        (?:\\#((?:[-_.!~*'()a-zA-Z\\d;/?:@&=+\$,\\[\\]]|%[a-fA-F\\d]{2})*))?\n\t      ";
    static $PATTERN_REL_URI = "\n\t        (?:\n\t          (?:\n\t            //\n\t            (?:\n\t              (?:((?:[-_.!~*'()a-zA-Z\\d;:&=+\$,]|%[a-fA-F\\d]{2})*)@)?\n\t                ((?:(?:(?:[a-zA-Z\\d](?:[-a-zA-Z\\d]*[a-zA-Z\\d])?)\\.)*(?:[a-zA-Z](?:[-a-zA-Z\\d]*[a-zA-Z\\d])?)\\.?|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\[(?:(?:[a-fA-F\\d]{1,4}:)*(?:[a-fA-F\\d]{1,4}|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})|(?:(?:[a-fA-F\\d]{1,4}:)*[a-fA-F\\d]{1,4})?::(?:(?:[a-fA-F\\d]{1,4}:)*(?:[a-fA-F\\d]{1,4}|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}))?)\\]))?(?::(\\d*))?\n\t            |\n\t              ((?:[-_.!~*'()a-zA-Z\\d\$,;:@&=+]|%[a-fA-F\\d]{2})+)\n\t            )\n\t          )\n\t        |\n\t          ((?:[-_.!~*'()a-zA-Z\\d;@&=+\$,]|%[a-fA-F\\d]{2})+)\n\t        )?\n\t        (/(?:[-_.!~*'()a-zA-Z\\d:@&=+\$,]|%[a-fA-F\\d]{2})*(?:;(?:[-_.!~*'()a-zA-Z\\d:@&=+\$,]|%[a-fA-F\\d]{2})*)*(?:/(?:[-_.!~*'()a-zA-Z\\d:@&=+\$,]|%[a-fA-F\\d]{2})*(?:;(?:[-_.!~*'()a-zA-Z\\d:@&=+\$,]|%[a-fA-F\\d]{2})*)*)*)?\n\t        (?:\\?((?:[-_.!~*'()a-zA-Z\\d;/?:@&=+\$,\\[\\]]|%[a-fA-F\\d]{2})*))?\n\t        (?:\\#((?:[-_.!~*'()a-zA-Z\\d;/?:@&=+\$,\\[\\]]|%[a-fA-F\\d]{2})*))?\n\t      ";
    static $PATTERN_REMOVE_WHITESPACE;
    static function parse($str)
    {
        $abs = new EReg("^" . sinatra_utils_URI::$PATTERN_REMOVE_WHITESPACE->replace(sinatra_utils_URI::$PATTERN_ABS_URI, "") . "\$", "");
        if ($abs->match($str)) {
            return new sinatra_utils_URI($abs, true);
        }
        $rel = new EReg("^" . sinatra_utils_URI::$PATTERN_REMOVE_WHITESPACE->replace(sinatra_utils_URI::$PATTERN_REL_URI, "") . "\$", "");
        if ($rel->match($str)) {
            return new sinatra_utils_URI($rel, false);
        }
        throw new HException("Invalid URI");
    }
    function __toString()
    {
        return $this->toString();
    }
}
sinatra_utils_URI::$SCHEME_DEFAULT_PORT = _hx_anonymous(array("http" => 80, "https" => 443, "ftp" => 21, "ssh" => 22));
sinatra_utils_URI::$PATTERN_REMOVE_WHITESPACE = new EReg("\\s*|\\n", "g");