Skip to content

Commit 0636bf5

Browse files
committed
Remove goto in RedirectableUrlMatcher
1 parent 0d35f97 commit 0636bf5

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php

+17-13
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,7 @@ public function match($pathinfo)
3232
}
3333

3434
if ($this->allowSchemes) {
35-
redirect_scheme:
36-
$scheme = $this->context->getScheme();
37-
$this->context->setScheme(current($this->allowSchemes));
38-
try {
39-
$ret = parent::match($pathinfo);
40-
41-
return $this->redirect($pathinfo, $ret['_route'] ?? null, $this->context->getScheme()) + $ret;
42-
} catch (ExceptionInterface $e2) {
43-
throw $e;
44-
} finally {
45-
$this->context->setScheme($scheme);
46-
}
35+
return $this->redirectScheme($pathinfo, $e);
4736
} elseif ('/' === $pathinfo) {
4837
throw $e;
4938
} else {
@@ -54,11 +43,26 @@ public function match($pathinfo)
5443
return $this->redirect($pathinfo, $ret['_route'] ?? null) + $ret;
5544
} catch (ExceptionInterface $e2) {
5645
if ($this->allowSchemes) {
57-
goto redirect_scheme;
46+
return $this->redirectScheme($pathinfo, $e);
5847
}
5948
throw $e;
6049
}
6150
}
6251
}
6352
}
53+
54+
private function redirectScheme(string $pathinfo, ResourceNotFoundException $originalException)
55+
{
56+
$scheme = $this->context->getScheme();
57+
$this->context->setScheme(current($this->allowSchemes));
58+
try {
59+
$ret = parent::match($pathinfo);
60+
61+
return $this->redirect($pathinfo, $ret['_route'] ?? null, $this->context->getScheme()) + $ret;
62+
} catch (ExceptionInterface $e) {
63+
throw $originalException;
64+
} finally {
65+
$this->context->setScheme($scheme);
66+
}
67+
}
6468
}

0 commit comments

Comments
 (0)