Заменяет simple выражения на именованные регулярные выражения
@used-by $this::match
@param string $route правило маршрута
@return string
353386
protected function getRegExpRoute($route)
    {
        return preg_replace_callback(
            '#(/?)\{(\S+?)(:(\S+?))?\}#',
            function (array $matches) {
                $startMod = $matches[1];
                $name = $matches[2];
                $type = isset($matches[4]) ? $matches[4] : 'string';

                $type = $this->getTypeRegexp($type);

                $regexp = $startMod . "(?P<$name>$type)";
                if (!$this->isRequiredParam($name)) {
                    $regexp = "({$regexp})?";
                }

                return $regexp;
            },
            $route
        );
    }
363536
protected function _compile_regex($route)
    {
        $pattern = '`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`';

        if ( preg_match_all($pattern, $route, $matches, PREG_SET_ORDER) ) {
            $match_types = array(
                'i'  => '[0-9]++',
                'a'  => '[0-9A-Za-z]++',
                'h'  => '[0-9A-Fa-f]++',
                '*'  => '.+?',
                ''   => '[^/]++'
            );
            foreach ( $matches as $match ) {
                list($block, $pre, $type, $param, $optional) = $match;

                if ( isset($match_types[$type]) ) {
                    $type = $match_types[$type];
                }
                if ( $param ) {
                    $param = "?<{$param}>";
                }
                if ( $optional ) {
                    $optional = '?';
                }

                $replaced = "(?:{$pre}({$param}{$type})){$optional}";
                $route = str_replace($block, $replaced, $route);
            }
        }
        if ( substr($route, strlen($route) - 1) != '/' ) {
            $route .= '/?';
        }
        return "`^{$route}$`";
    }
128603
public function getPathValidated(Route\Route $route)
    {
        $parameters = $route->getParameters();
        if (count($parameters)) {
            $arity = '[' . count($parameters) . ']';
        } else {
            $arity = '[0]';
        }
        $key = $route->withoutAttributes()->__toString();
        $pattern = null;
        if (isset($this->paths[$key . $arity])) {
            $pattern = $this->paths[$key . $arity]['pattern'];
        } elseif (isset($this->paths[$key . '[*]'])) {
            $pattern = $this->paths[$key . '[*]']['pattern'];
        }
        $path = $route->getPath($pattern);
        if (! isset($path)) {
            throw new Route\RouteException('Could not find path for: ' . $key . $arity);
        }
        return $path;
    }
709349
protected function replaceRouteParameters($route, &$parameters = [])
    {
        return \preg_replace_callback('/\{(.*?)(:.*?)?(\{[0-9,]+\})?\}/', function ($m) use (&$parameters) {
            return isset($parameters[$m[1]]) ? Arr::pull($parameters, $m[1]) : $m[0];
        }, $route);
    }
853197
private function getRouteName(Route $route)
    {
        return is_null($name = $route->getName()) ? $route->uri() : $name;
    }
1108522
protected function parseRoute($route)
    {
        $parsedRoute = parse_url($route);

        if (isset($parsedRoute['query'])) {
            parse_str($parsedRoute['query'], $parsedRoute['params']);
        } else {
            $parsedRoute['params'] = [];
        }

        $resolvedRoute = new Resolver(new \common_http_Request($route));
        $this->propagate($resolvedRoute);
        $parsedRoute['extension']         = $resolvedRoute->getExtensionId();
        $parsedRoute['controller']        = $resolvedRoute->getControllerShortName();
        $parsedRoute['controller_class']  = $resolvedRoute->getControllerClass();
        $parsedRoute['action']            = $resolvedRoute->getMethodName();

        return $parsedRoute;
    }
441815
public function resolveRoute($route)
    {
        $routes = $this->sectionRoutes();
        $sId = $this->resolveSectionId($route);

        if (!isset($routes['sections'][$sId])) {
            return '';
        }

        return $routes['sections'][$sId];
    }
1262431
private function match(string $url, Route $route) : array
    {
        $regexp = $this->routeRegexp($route);

        if (preg_match_all('`^' . $regexp . '$`', $url, $matches, PREG_SET_ORDER)) {
            // remove all numeric matches
            $matches = array_diff_key($matches[0], range(0, count($matches[0])));

            // control query string
            if ($route->getUserInputs()) {
                foreach ($route->getUserInputs() as $querystring) {
                    $method = self::request()->getMethod() == 'POST' ? 'getPostOrQuery' : 'getQuery';
                    $value = self::request()->$method($querystring->getName(), $querystring->getType());

                    if (is_null($value) && $querystring->isMandatory()) {
                        return [false, null, $regexp];
                    }

                    if (!is_null($value)) {
                        $matches[$querystring->getName()] = $value;
                    }
                }
            }

            // control conditions
            if ($route->getConditions()) {
                foreach ($route->getConditions() as $condition) {
                    if (!$condition($matches)) {
                        return [false, null, $regexp];
                    }
                }
            }

            return [true, $matches, $regexp];
        }

        return [false, null, $regexp];
    }
1110610
private function applyGroupSettings(Route $route) : Route
    {
        $route->setRawPath($this->getGroupPath() . $route->getRawPath());
        $route->setRawHost($this->getGroupHost() . $route->getRawHost());

        if (!$route->usesCallable()) {
            $route->setControllerName($this->getGroupControllerNamespace() . $route->getControllerName());
        }

        $route->setSecure($this->groupIsSecure() || $route->isSecure());
        // The route's variable regexes take precedence over group regexes
        $route->setVarRegexes(array_merge($this->getVarRegexes(), $route->getVarRegexes()));
        $groupMiddleware = $this->getGroupMiddleware();

        if (count($groupMiddleware) > 0) {
            $route->addMiddleware($groupMiddleware, true);
        }

        return $route;
    }
962882
private function mapRoute2IndexKey($route)
    {
        $route = rtrim($route, "/");

        if (key_exists($route, $this->index)) {
            return $route;
        } elseif (empty($route) && key_exists("index", $this->index)) {
            return "index";
        } elseif (key_exists($route . "/index", $this->index)) {
            return "$route/index";
        }

        return false;
    }
203367
static public function getRoutePatternParts( Route $route ){
		$parts	= array();
		foreach( explode( "/", $route->getPattern() ) as $part ){
			$optional	= FALSE;
			$argument	= FALSE;
			if( preg_match( "@\(:.+\)@", $part ) ){													//  optional argument found
				$part		= substr( $part, 1, -1 );												//  cut argument key
				$optional	= TRUE;																	//  note that is optional
			}
			if( substr( $part, 0, 1 ) === ":" ){													//  argument found
				$part		= substr( $part, 1 );													//  cut argument key
				$argument	= TRUE;																	//  note that is argument
			}
			$parts[]	= (object) array(															//  prepare route pattern part object
				'key'		=> $part,
				'optional'	=> $optional,
				'argument'	=> $argument,
			);
		}
		return $parts;
	}
831675
public function getLink($route)
    {
        $token = 'token';
        $secure = true;
        return $this->url->link($route, $token . '=' . $this->session->data[$token], $secure);
    }
712107
private function routeMatch(string $routeRegex, string $route)
    {
        $matches = [];
        if (preg_match($routeRegex, $route, $matches)) {
            unset($matches[0]);

            return array_values($matches);
        }

        return false;
    }
861046
private function getMethods(Route $route)
    {
        $methods = $route->getMethods();
        sort($methods);

        return implode('|', $methods) ?: 'ANY';
    }
943022
protected function matches(Route $route, string $path): bool
	{
		if(preg_match($route->getRegex(), $path, $parameters) > 0)
		{
			$filtered = [];

			foreach($parameters as $key => $value)
			{
				if(is_string($key))
				{
					$filtered[$key] = $value;
				}
			}

			$route->setParameters($filtered);

			return true;
		}

		return false;
	}
1097716
protected function _validateRoute($route)
    {
        // Split on comma.
        $domains = explode(',', trim($route));

        foreach ($domains as $domain) {
            $domain = str_replace('@', '', trim($domain));
            if (!$this->_validateDomain($domain)) return false;
        }

        return $route;
    }
209259
public function matches(Route $route, Request $request)
	{
		if (is_null($route->getCompiled()->getHostRegex())) return true;

		return preg_match($route->getCompiled()->getHostRegex(), $request->getHost());
	}