Test current route is matching request

{@inheritDoc}
@param HTTPRequest $request
@param array $values
@param boolean $alternative
@see \Orpheus\InputController\ControllerRoute::isMatchingRequest()
542325
public function isMatchingRequest(InputRequest $request, &$values=array(), $alternative=false) {
		// Method match && Path match (variables included)
		if( $this->method !== $request->getMethod() ) {
			return false;
		}
		$regex = $this->pathRegex;
		if( $alternative ) {
			// If last char is / or not, it will end with /? (optional /)
			$regex .= str_last($regex)==='/' ? '?' : '/?';
		}
		$matches = null;
		if( preg_match('#^'.$regex.'$#i', $request->getPath(), $matches) ) {
			unset($matches[0]);
			$values	= array_combine($this->pathVariables, $matches);
			return true;
		}
		return false;
	}
19216
public function match(RequestInterface $request)
    {
        return (
            $this->matchSchema($request->schema()) &&
            $this->matchMethods($request->method()) &&
            $this->matchHost($request->host()) &&
            $this->matchPath($request->path())
        );
    }
106877
public static function is_https(HTTPRequest $request = null)
    {
        // Check override from alternate_base_url
        if ($baseURL = self::config()->uninherited('alternate_base_url')) {
            $baseURL = Injector::inst()->convertServiceProperty($baseURL);
            $protocol = parse_url($baseURL, PHP_URL_SCHEME);
            if ($protocol) {
                return $protocol === 'https';
            }
        }

        // Check the current request
        $request = static::currentRequest($request);
        if ($request && ($scheme = $request->getScheme())) {
            return $scheme === 'https';
        }

        // Check default_base_url
        if ($baseURL = self::config()->uninherited('default_base_url')) {
            $baseURL = Injector::inst()->convertServiceProperty($baseURL);
            $protocol = parse_url($baseURL, PHP_URL_SCHEME);
            if ($protocol) {
                return $protocol === 'https';
            }
        }

        return false;
    }
165824
public function match(Request $request)
    {
        try {
            return parent::match($request);
        } catch (NotFoundHttpException $e) {
            $route = $this->findMatchingWordpressPost();

            if ( ! is_null($route)) {
                return $route->bind($request);
            }

            throw $e;
        }
    }
1236759
public function getMatchingRoute($routes, Request $request)
    {
        foreach ($routes as $matchingRoute) {
            if ($matchingRoute->matches($request)) {
                return $matchingRoute;
            }
        }

        return null;
    }
981880
public function match($path, RouteRequest $request = null)
    {
        $requestMethod = null;

        if ($request) {

            $requestMethod = self::convertRequestMethodConstant($request->getRequestMethod());

        } else if (isset($_SERVER['REQUEST_METHOD'])) {

            $requestMethod = self::convertRequestMethodConstant($_SERVER['REQUEST_METHOD']);

        }

        foreach ($this->routes as $route) {
            // If the route is using pcre pattern marching...
            if ($route[0]) {
                if (!preg_match($route[1], $path, $matches)) {
                    continue;
                }
                $route[3]['vars'] = $matches;

                // validate request method
                if (isset($route[3]['method']) && $route[3]['method'] != $requestMethod) {
                    continue;
                }
                if (isset($route[3]['domain']) && $route[3]['domain'] != $_SERVER['HTTP_HOST']) {
                    continue;
                }
                if (isset($route[3]['secure']) && $route[3]['secure'] && $_SERVER['HTTPS']) {
                    continue;
                }

                return $route;
            } else {
                // prefix match is used when expanding is not enabled.
                if ((
                        (is_int($route[2]) || $route[2] instanceof self || $route[2] instanceof \PHPSGI\App)
                        && strncmp($route[1], $path, strlen($route[1])) === 0
                    ) || $route[1] == $path) {
                    // validate request method
                    if (isset($route[3]['method']) && $route[3]['method'] != $requestMethod) {
                        continue;
                    }
                    if (isset($route[3]['domain']) && $route[3]['domain'] != $_SERVER['HTTP_HOST']) {
                        continue;
                    }
                    if (isset($route[3]['secure']) && $route[3]['secure'] && $_SERVER['HTTPS']) {
                        continue;
                    }

                    return $route;
                }
                continue;
            }
        }
    }
151406
private function requestHeadersMatchExpectation(ServerRequestInterface $httpRequest, RequestConditions $expectedRequest)
    {
        $inputSource = $this->inputSourceLocator->locate('header');
        foreach ($expectedRequest->getHeaders() as $header => $headerCondition) {
            $matcher = $this->matcherLocator->locate(
                $headerCondition->getMatcher()->asString()
            );

            $matches = $matcher->match(
                $inputSource->getValue($httpRequest, $header->asString()),
                $headerCondition->getValue()->asString()
            );
            if (!$matches) {
                return false;
            }
        }

        return true;
    }
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;
		}
	}
1287452
public function getMatchingRoute($request)
    {
        // Get matching route
        $this->currentRoute = $route = $this->routes->match($request);

        return $route;
    }
1328009
public function match(ServerRequestInterface $request) : RouterMatch
    {
        $path = $request->getUri()->getPath();
        $syContext = new RequestContext('/');
        $syMatcher = new UrlMatcher($this->syRouteCollection, $syContext);
        try {
            $params = $syMatcher->match($path);
        } catch (\Throwable $e) {
            throw new HttpException(404, "No route matched for path $path",
                null, $e);
        }
        
        $matchedRouteName = $params['_route'];
        unset($params['_route']);
        $route = $this->routeProvider->getRouteFromName($matchedRouteName);
        $routerMatch = new RouterMatch($route, $params);
        return $routerMatch;
    }
908289
public function find(Request $request, array $routes)
    {
        foreach ($routes as $route) {

            if(!$this->matchMethod($request, $route)){
                continue;
            }

            if(!$this->matchContentType($request, $route)){
                continue;
            }

            if(!$this->matchFilters($route)){
                continue;
            }

            $routeMatches = $this->matchPattern($request, $route);
            if ($routeMatches) {
                $route->setMatches($routeMatches);
                return $route;
            }
        }
        throw new RouteException(
            sprintf('No route found for uri "%s"', $request->getRequestUri()),
            $request,
            $routes
        );
    }
1183570
public function match(ServerRequestInterface $request, $path)
	{
	    if(isset($this->properties['method'])) {
	        if(!in_array(strtolower($request->getMethod()), $this->properties['method']))
	            return array(
	                'route' => false,
                    'parameter' => false,
                    'continue' => false
                );
        }

        if(isset($this->properties['path'])) {
            $result = $this->matchPath($path);

            if(!$result['matched'])
                return array(
                    'route' =>false,
                    'parameter' => $result['parameter'],
                    'continue' => $result['continue']
                );

            if($this->properties['validators']) {
                $flag = $this->matchValidators($request, $path, $result['parameter']);

                if($flag === false)
                    return array(
                        'route' => false,
                        'parameter' => false,
                        'continue' => false
                    );
            }

            return array(
                'route' => $this,
                'parameter' => $result['parameter'],
                'continue' => $result['continue']
            );
        }

        return array(
            'route'=>false,
            'parameter'=> array(),
            'continue'=> false
        );
	}
435925
private function matchRoutes(Request $request, Response $response)
    {
        $stack  = [];
        $path   = $request->httpRequest->getPath();
        $method = $request->httpRequest->getMethod();

        foreach ($this->routes as $route) {
            if (!$route->match($path, $method)) {
                continue;
            }

            $methodArgs = $route->getArgs($path);
            $request->setData($methodArgs);

            $route->on('error', function (...$args) {
                $this->emit('error', $args);
            });

            $stack[] = function (...$params) use ($route) {
                $route->run(...$params);
            };
        }

        if (count($stack) == 0) {
            $this->emit('NotFound', array($request, $response));
            return;
        }

        $this->runStack($stack, $request, $response);
    }
437156
public function matchRequest(ServerRequest $request)
    {
        return $this->getMatchRoute(
            $request->getMethod(),
            $this->getUrl($request)
        );
    }
35045
public static function matches($matchers, RequestInterface $request): bool
    {
        $matchers = (array) $matchers;

        foreach ($matchers as $v) {
            if ($v === true) {
                continue;
            }

            if ($v === false) {
                return false;
            }

            if (\is_string($v)) {
                $len = \strlen($v);
                if ($len > 3 &&
                    $v[0] === '<' &&
                    ($pos = \strpos($v, ':')) !== false &&
                    $v[$len - 1] === '>'
                ) {
                    $fun = \trim(\substr($v, 1, $pos));
                    $args = \array_map('\trim', \explode(',', \substr($v, $pos + 1, -1)));

                    $matcher = self::$fun(...$args);
                } else {
                    $matcher = self::path($v);
                }
            } elseif (\is_callable($v)) {
                $matcher = self::callback($v);
            } else {
                $matcher = $v;
            }

            if (!$matcher instanceof MatcherInterface) {
                throw new \RuntimeException('Invalid matcher. Must be a boolean, string, callable or a Hail\\Http\\Matcher\\MatcherInterface');
            }

            if (!$matcher->matches($request)) {
                return false;
            }
        }

        return true;
    }
1065021
protected function matchRoute(ServerRequestInterface $request): ?RouteInterface
    {
        foreach ($this->routes as $route) {
            // Matched route will return new route instance with matched parameters
            $matched = $route->match($request);

            if (!empty($matched)) {
                return $matched;
            }
        }

        if (!empty($this->default)) {
            return $this->default->match($request);
        }

        // unable to match any 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;
    }