$supportsTrailingSlash = 'GET' ===
$method &&
$this instanceof RedirectableUrlMatcherInterface;
$trimmedPathinfo =
rtrim($pathinfo, '/'
) ?: '/';
foreach ($routes as $name =>
$route) { $compiledRoute =
$route->
compile();
$staticPrefix =
rtrim($compiledRoute->
getStaticPrefix(), '/'
);
$requiredMethods =
$route->
getMethods();
// check the static prefix of the URL first. Only use the more expensive preg_match when it matches
if ('' !==
$staticPrefix && !
str_starts_with($trimmedPathinfo,
$staticPrefix)) { $this->
addTrace(sprintf('Path "%s" does not match',
$route->
getPath()), self::ROUTE_DOES_NOT_MATCH,
$name,
$route);
continue;
} $regex =
$compiledRoute->
getRegex();
$pos =
strrpos($regex, '$'
);
$hasTrailingSlash = '/' ===
$regex[$pos - 1
];
$regex =
substr_replace($regex, '/?$',
$pos -
$hasTrailingSlash, 1 +
$hasTrailingSlash);
if (!
preg_match($regex,
$pathinfo,
$matches)) { // does it match without any requirements?
$r =
new Route($route->
getPath(),
$route->
getDefaults(),
[],
$route->
getOptions());