Laravel 5.6 updates
Travis config update Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
@@ -15,235 +15,152 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
public function match($pathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$allow = $allowSchemes = array();
|
||||
if ($ret = $this->doMatch($pathinfo, $allow, $allowSchemes)) {
|
||||
return $ret;
|
||||
}
|
||||
if ($allow) {
|
||||
throw new MethodNotAllowedException(array_keys($allow));
|
||||
}
|
||||
if (!in_array($this->context->getMethod(), array('HEAD', 'GET'), true)) {
|
||||
// no-op
|
||||
} elseif ($allowSchemes) {
|
||||
redirect_scheme:
|
||||
$scheme = $this->context->getScheme();
|
||||
$this->context->setScheme(key($allowSchemes));
|
||||
try {
|
||||
if ($ret = $this->doMatch($pathinfo)) {
|
||||
return $this->redirect($pathinfo, $ret['_route'], $this->context->getScheme()) + $ret;
|
||||
}
|
||||
} finally {
|
||||
$this->context->setScheme($scheme);
|
||||
}
|
||||
} elseif ('/' !== $pathinfo) {
|
||||
$pathinfo = '/' !== $pathinfo[-1] ? $pathinfo.'/' : substr($pathinfo, 0, -1);
|
||||
if ($ret = $this->doMatch($pathinfo, $allow, $allowSchemes)) {
|
||||
return $this->redirect($pathinfo, $ret['_route']) + $ret;
|
||||
}
|
||||
if ($allowSchemes) {
|
||||
goto redirect_scheme;
|
||||
}
|
||||
}
|
||||
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
private function doMatch(string $rawPathinfo, array &$allow = array(), array &$allowSchemes = array()): ?array
|
||||
{
|
||||
$allow = $allowSchemes = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/trailing/simple')) {
|
||||
// simple_trailing_slash_no_methods
|
||||
if ('/trailing/simple/no-methods' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'simple_trailing_slash_no_methods');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_simple_trailing_slash_no_methods;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_no_methods'));
|
||||
switch ($pathinfo) {
|
||||
default:
|
||||
$routes = array(
|
||||
'/trailing/simple/no-methods/' => array(array('_route' => 'simple_trailing_slash_no_methods'), null, null, null),
|
||||
'/trailing/simple/get-method/' => array(array('_route' => 'simple_trailing_slash_GET_method'), null, array('GET' => 0), null),
|
||||
'/trailing/simple/head-method/' => array(array('_route' => 'simple_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null),
|
||||
'/trailing/simple/post-method/' => array(array('_route' => 'simple_trailing_slash_POST_method'), null, array('POST' => 0), null),
|
||||
'/not-trailing/simple/no-methods' => array(array('_route' => 'simple_not_trailing_slash_no_methods'), null, null, null),
|
||||
'/not-trailing/simple/get-method' => array(array('_route' => 'simple_not_trailing_slash_GET_method'), null, array('GET' => 0), null),
|
||||
'/not-trailing/simple/head-method' => array(array('_route' => 'simple_not_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null),
|
||||
'/not-trailing/simple/post-method' => array(array('_route' => 'simple_not_trailing_slash_POST_method'), null, array('POST' => 0), null),
|
||||
);
|
||||
|
||||
if (!isset($routes[$pathinfo])) {
|
||||
break;
|
||||
}
|
||||
list($ret, $requiredHost, $requiredMethods, $requiredSchemes) = $routes[$pathinfo];
|
||||
|
||||
$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;
|
||||
}
|
||||
not_simple_trailing_slash_no_methods:
|
||||
|
||||
// simple_trailing_slash_GET_method
|
||||
if ('/trailing/simple/get-method' === $trimmedPathinfo) {
|
||||
$ret = array('_route' => 'simple_trailing_slash_GET_method');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_simple_trailing_slash_GET_method;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_GET_method'));
|
||||
}
|
||||
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_simple_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_GET_method:
|
||||
|
||||
// simple_trailing_slash_HEAD_method
|
||||
if ('/trailing/simple/head-method/' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_trailing_slash_HEAD_method');
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_simple_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_trailing_slash_POST_method
|
||||
if ('/trailing/simple/post-method/' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_trailing_slash_POST_method');
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_simple_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/trailing/regex')) {
|
||||
// regex_trailing_slash_no_methods
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P<param>[^/]++)/?$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ());
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_regex_trailing_slash_no_methods;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_no_methods'));
|
||||
$matchedPathinfo = $pathinfo;
|
||||
$regexList = array(
|
||||
0 => '{^(?'
|
||||
.'|/trailing/regex/(?'
|
||||
.'|no\\-methods/([^/]++)/(*:47)'
|
||||
.'|get\\-method/([^/]++)/(*:75)'
|
||||
.'|head\\-method/([^/]++)/(*:104)'
|
||||
.'|post\\-method/([^/]++)/(*:134)'
|
||||
.')'
|
||||
.'|/not\\-trailing/regex/(?'
|
||||
.'|no\\-methods/([^/]++)(*:187)'
|
||||
.'|get\\-method/([^/]++)(*:215)'
|
||||
.'|head\\-method/([^/]++)(*:244)'
|
||||
.'|post\\-method/([^/]++)(*:273)'
|
||||
.')'
|
||||
.')$}sD',
|
||||
);
|
||||
|
||||
foreach ($regexList as $offset => $regex) {
|
||||
while (preg_match($regex, $matchedPathinfo, $matches)) {
|
||||
switch ($m = (int) $matches['MARK']) {
|
||||
default:
|
||||
$routes = array(
|
||||
47 => array(array('_route' => 'regex_trailing_slash_no_methods'), array('param'), null, null),
|
||||
75 => array(array('_route' => 'regex_trailing_slash_GET_method'), array('param'), array('GET' => 0), null),
|
||||
104 => array(array('_route' => 'regex_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null),
|
||||
134 => array(array('_route' => 'regex_trailing_slash_POST_method'), array('param'), array('POST' => 0), null),
|
||||
187 => array(array('_route' => 'regex_not_trailing_slash_no_methods'), array('param'), null, null),
|
||||
215 => array(array('_route' => 'regex_not_trailing_slash_GET_method'), array('param'), array('GET' => 0), null),
|
||||
244 => array(array('_route' => 'regex_not_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null),
|
||||
273 => array(array('_route' => 'regex_not_trailing_slash_POST_method'), array('param'), array('POST' => 0), 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;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
if (273 === $m) {
|
||||
break;
|
||||
}
|
||||
$regex = substr_replace($regex, 'F', $m - $offset, 1 + strlen($m));
|
||||
$offset += strlen($m);
|
||||
}
|
||||
not_regex_trailing_slash_no_methods:
|
||||
|
||||
// regex_trailing_slash_GET_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P<param>[^/]++)/?$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ());
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_regex_trailing_slash_GET_method;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_GET_method'));
|
||||
}
|
||||
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_regex_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_GET_method:
|
||||
|
||||
// regex_trailing_slash_HEAD_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ());
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_regex_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_HEAD_method:
|
||||
|
||||
// regex_trailing_slash_POST_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_POST_method')), array ());
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_regex_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/not-trailing/simple')) {
|
||||
// simple_not_trailing_slash_no_methods
|
||||
if ('/not-trailing/simple/no-methods' === $pathinfo) {
|
||||
return array('_route' => 'simple_not_trailing_slash_no_methods');
|
||||
}
|
||||
|
||||
// simple_not_trailing_slash_GET_method
|
||||
if ('/not-trailing/simple/get-method' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_GET_method');
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_simple_not_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_GET_method:
|
||||
|
||||
// simple_not_trailing_slash_HEAD_method
|
||||
if ('/not-trailing/simple/head-method' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_HEAD_method');
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_simple_not_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_not_trailing_slash_POST_method
|
||||
if ('/not-trailing/simple/post-method' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_POST_method');
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_simple_not_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/not-trailing/regex')) {
|
||||
// regex_not_trailing_slash_no_methods
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_no_methods')), array ());
|
||||
}
|
||||
|
||||
// regex_not_trailing_slash_GET_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_GET_method')), array ());
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_regex_not_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_GET_method:
|
||||
|
||||
// regex_not_trailing_slash_HEAD_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_HEAD_method')), array ());
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_regex_not_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_HEAD_method:
|
||||
|
||||
// regex_not_trailing_slash_POST_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_POST_method')), array ());
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_regex_not_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user