context = $context; } public function match($rawPathinfo) { $allow = $allowSchemes = array(); $pathinfo = rawurldecode($rawPathinfo); $context = $this->context; $requestMethod = $canonicalMethod = $context->getMethod(); if ('HEAD' === $requestMethod) { $canonicalMethod = 'GET'; } $matchedPathinfo = $pathinfo; $regexList = array( 0 => '{^(?' .'|/(a)(*:11)' .')$}sD', 11 => '{^(?' .'|/(.)(*:22)' .')$}sDu', 22 => '{^(?' .'|/(.)(*:33)' .')$}sD', ); foreach ($regexList as $offset => $regex) { while (preg_match($regex, $matchedPathinfo, $matches)) { switch ($m = (int) $matches['MARK']) { default: $routes = array( 11 => array(array('_route' => 'a'), array('a'), null, null), 22 => array(array('_route' => 'b'), array('a'), null, null), 33 => array(array('_route' => 'c'), array('a'), null, null), ); list($ret, $vars, $requiredMethods, $requiredSchemes) = $routes[$m]; foreach ($vars as $i => $v) { if (isset($matches[1 + $i])) { $ret[$v] = $matches[1 + $i]; } } $hasRequiredScheme = !$requiredSchemes || isset($requiredSchemes[$context->getScheme()]); if ($requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) { if ($hasRequiredScheme) { $allow += $requiredMethods; } break; } if (!$hasRequiredScheme) { $allowSchemes += $requiredSchemes; break; } return $ret; } if (33 === $m) { break; } $regex = substr_replace($regex, 'F', $m - $offset, 1 + strlen($m)); $offset += strlen($m); } } if ('/' === $pathinfo && !$allow && !$allowSchemes) { throw new Symfony\Component\Routing\Exception\NoConfigurationException(); } throw $allow ? new MethodNotAllowedException(array_keys($allow)) : new ResourceNotFoundException(); } }