Attempts to match the route of the current request against the specified route

@param string $expectedRoute the route to match against
@return array|null the list of matched parameters or `null` if the route didn't match
773083
private function matchRoute($expectedRoute) {
		$params = [];

		// create the regex that matches paths against the route
		$expectedRouteRegex = $this->createRouteRegex($expectedRoute, $params);

		// if the route regex matches the current request path
		if (preg_match($expectedRouteRegex, $this->route, $matches)) {
			if (count($matches) > 1) {
				// remove the first match (which is the full route match)
				array_shift($matches);

				// use the extracted parameters as the arguments' keys and the matches as the arguments' values
				return array_combine($params, $matches);
			}
			else {
				return [];
			}
		}
		// if the route regex does not match the current request path
		else {
			return null;
		}
	}
421696
public function satisfiesPath(string $expectedPath = null): bool
    {
        if (empty($expectedPath)) {
            return true;
        }

        if (preg_match('/^' . UriPath::pattern($expectedPath) . '/', $this->uri->path()) >= 1) {
            return true;
        }

        return false;
    }
816974
public static function match($actual, $expected = null)
    {
        $a = static::actual($actual);
        static::_buildDescription($a, $expected);

        return $a === $expected;
    }
435701
public function match(Request $request)
    {
        $hasWpParams = $request->path() == '/' && ($request->has('p') || $request->has('post_id'));

        if ($hasWpParams && $route = $this->findMatchingWordPressPost($request)) {
            return $route;
        }

        try {
            return parent::match($request);
        } catch (NotFoundHttpException $e) {

            if ($route = $this->findMatchingWordPressPost($request)) {
                return $route;
            }

            throw $e;
        }
    }
821990
public function match(Request $request, $pathOffset = null)
    {
        if (!method_exists($request, 'getQuery') && !method_exists($request, 'getUri')) {
            return false;
        }
        
        // determine that we have on correct route matching
        /** @var $uri \Zend\Uri\Http */
        /** @var $request \Zend\Http\PhpEnvironment\Request */
        $uri  = $request->getUri();
        $path = $uri->getPath();

        if ($pathOffset !== null) {
        	if ($pathOffset >= 0 && strlen($path) >= $pathOffset) {
        		if ($this->route !== substr($path, $pathOffset)) {
                    // we are not in admin child routes
        			return null;
        		}
        	}
        }

        # get route params
        // get request query string (?qD2D32#es...EncODed | ?module=Application&encoded=none)
        $reqUri      = $request->getRequestUri();
        if (($qstack = strpos($reqUri, '?')) === false) {
            // we dont have any parameter to match
            return false;
        }

        $queryString = substr($reqUri, $qstack+1);
        $queryString = $this->decodeQuery($queryString);

        $routeParams = array();
        parse_str($queryString, $routeParams);

        /*
         * Route default factory options 
         */
        $params = array_merge($this->defaults, array()/*$this->params*/); // we don't want options as default values
        $params = array_merge($params, $routeParams);

       	return new RouteMatch($params, strlen($this->route));
    }
1236759
public function getMatchingRoute($routes, Request $request)
    {
        foreach ($routes as $matchingRoute) {
            if ($matchingRoute->matches($request)) {
                return $matchingRoute;
            }
        }

        return null;
    }
140535
public function getMatchedRouteName()
    {
        if ($this->isFailure()) {
            return false;
        }
        if (! $this->matchedRouteName && $this->route) {
            $this->matchedRouteName = $this->route->getName();
        }

        return $this->matchedRouteName;
    }
497660
private function find(Contracts\Request $request)
    {
        $method = $request->method();
        $path   = $request->path();
        foreach ($this->routes as $route) {
            if ($route->method == $method) {
                $pattern = $this->pattern($route);
                if (preg_match($pattern, $path)) {
                    return $route;
                }
            }
        }

        return null;
    }
962880
protected function findRoute(Request $request)
    {
        if (! in_array($request->method(), array('GET', 'HEAD', 'OPTIONS'))) {
            return;
        }

        $uri = $request->path();

        foreach ($this->routes as $pattern => $callback) {
            if (preg_match('#^' .$pattern .'$#s', $uri, $matches)) {
                return array($callback, array_slice($matches, 1));
            }
        }
    }
953940
protected function getRouteMatch(RequestInterface $request) : Match
	{
		/** @var Router $router */
		$router = $this->dependencyContainer->get('fuel.application.router');
		$match = $router->translate($request->getUri()->getPath(), $request->getMethod());

		return $match;
	}
1233479
public function getRouteMatch()
    {
        if (null === $this->routeMatch) {
            /** @noinspection PhpUndefinedMethodInspection */
            $this->routeMatch = $this->getEvent()->getRouteMatch();
        }

        return $this->routeMatch;
    }
543277
public function checkRoute($route,$active=null,$inactive=null)
    {
        $this->setReturnValue($active,$inactive);

        if (is_array($route)) {
            $result = call_user_func_array(array($this,'routeIsDeeply'), $route);
        } else {
            $result = $this->routeIsDeeply($route);   
        }

        return $result ? $this->activeValue : $this->inActiveValue;
    }
1074805
public function matchRequest(Request $request)
    {
        $requestUrl = $request->getRouteURL();
        $requestMethod = $request->getMethod();

        if (empty($this->routes)) {
            $routeFile = basePath('app/Routes/web.php');
            if (file_exists($routeFile)) {
                /** @noinspection PhpIncludeInspection */
                require_once $routeFile;
            } else {
                throw new Exception("Route definition file $routeFile does not exist");
            }
        }

        $params = array();
        foreach ($this->routes as $handler) {
            $methods = $handler->getHttpMethod();
            $route = $handler->getRouteURI();

            $method_match = (stripos($methods, $requestMethod) !== false);

            // Method did not match, continue to next route.
            if (!$method_match) {
                continue;
            }

            if ($route === '*') {
                // * wildcard (matches all)
                $match = true;
            } elseif (isset($route[0]) && $route[0] === '@') {
                // @ regex delimiter
                $pattern = '`' . substr($route, 1) . '`u';
                $match = preg_match($pattern, $requestUrl, $params) === 1;
            } elseif (($position = strpos($route, '[')) === false) {
                // No params in url, do string comparison
                $match = strcmp($requestUrl, $route) === 0;
            } else {
                // Compare longest non-param string with url
                if (strncmp($requestUrl, $route, $position) !== 0) {
                    continue;
                }
                $regex = $this->compileRoute($route);
                $match = preg_match($regex, $requestUrl, $params) === 1;
            }

            if ($match) {
                if ($params) {
                    foreach ($params as $key => $value) {
                        if (is_numeric($key)) {
                            unset($params[$key]);
                        }
                    }
                }
                $handler->setParameters($params);
                $handler->lock();
                $request->setRoute($handler);

                return $handler;
            }
        }

        return false;
    }
902752
public function route(Request $request)
    {
        foreach ($this->routes as $route) {
            if ($route->matches($request)) {
                return $route;
            }
        }

        return null;
    }
671580
protected function matchRoutes(RequestInterface $request, int $pathOffset): ?RouteMatchInterface
    {
        $notAllowed = null;
        $routes = $this->getRoutes();
        foreach ($routes as $route) {
            try {
                $match = $route->match($request, $pathOffset);
                if ($match instanceof RouteMatchInterface) {
                    return $match;
                }
            } catch (MethodNotAllowed $exception) {
                if ($notAllowed instanceof MethodNotAllowed) {
                    $notAllowed->addAllowedMethods($exception->getAllowedMethods());
                } else {
                    $notAllowed = $exception;
                }
            }
        }

        if ($notAllowed instanceof MethodNotAllowed) {
            throw $notAllowed;
        }

        return null;
    }
185137
public function findMatchingPaths(Route $searchRoute)
    {
        if (isset($this->cachedRoutes[$searchRoute->getPath()])) {
            return $this->cachedRoutes[$searchRoute->getPath()];
        }

        /** @var Route $route */
        foreach ($this->getSortedRoutes() as $routePath => $name) {
            if (preg_match('#^' . preg_quote(rtrim($routePath, '/') . '/', '#') . '#', $searchRoute->getPath())) {
                $this->cachedRoutes[$searchRoute->getPath()] = $name;

                return $name;
            }
        }

        return null;
    }
356988
public function match($route, $method = 'GET', $options = [])
    {
        // Trim the query string off.
        $route = preg_replace('/([^?]*).*/u', '\1', $route);

        // Sanitize and explode the route.
        $route = parse_url($route, PHP_URL_PATH);

        $matched = $this->matcher
            ->setRoutes($this->routes)
            ->match($route, $method, $options);

        if ($matched === false) {
            throw new RouteNotFoundException(sprintf('Unable to handle request for route `%s`.', $route), 404);
        }

        return $matched;
    }