composer update
This commit is contained in:
+13
-5
@@ -111,9 +111,10 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
|
||||
// Match all variables enclosed in "{}" and iterate over them. But we only want to match the innermost variable
|
||||
// in case of nested "{}", e.g. {foo{bar}}. This in ensured because \w does not match "{" or "}" itself.
|
||||
preg_match_all('#\{\w+\}#', $pattern, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
|
||||
preg_match_all('#\{(!)?(\w+)\}#', $pattern, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
|
||||
foreach ($matches as $match) {
|
||||
$varName = substr($match[0][0], 1, -1);
|
||||
$important = $match[1][1] >= 0;
|
||||
$varName = $match[2][0];
|
||||
// get all static text preceding the current variable
|
||||
$precedingText = substr($pattern, $pos, $match[0][1] - $pos);
|
||||
$pos = $match[0][1] + \strlen($match[0][0]);
|
||||
@@ -183,7 +184,13 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
$regexp = self::transformCapturingGroupsToNonCapturings($regexp);
|
||||
}
|
||||
|
||||
$tokens[] = ['variable', $isSeparator ? $precedingChar : '', $regexp, $varName];
|
||||
if ($important) {
|
||||
$token = ['variable', $isSeparator ? $precedingChar : '', $regexp, $varName, false, true];
|
||||
} else {
|
||||
$token = ['variable', $isSeparator ? $precedingChar : '', $regexp, $varName];
|
||||
}
|
||||
|
||||
$tokens[] = $token;
|
||||
$variables[] = $varName;
|
||||
}
|
||||
|
||||
@@ -196,7 +203,8 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
if (!$isHost) {
|
||||
for ($i = \count($tokens) - 1; $i >= 0; --$i) {
|
||||
$token = $tokens[$i];
|
||||
if ('variable' === $token[0] && $route->hasDefault($token[3])) {
|
||||
// variable is optional when it is not important and has a default value
|
||||
if ('variable' === $token[0] && !($token[5] ?? false) && $route->hasDefault($token[3])) {
|
||||
$firstOptional = $i;
|
||||
} else {
|
||||
break;
|
||||
@@ -216,7 +224,7 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
$regexp .= 'u';
|
||||
for ($i = 0, $nbToken = \count($tokens); $i < $nbToken; ++$i) {
|
||||
if ('variable' === $tokens[$i][0]) {
|
||||
$tokens[$i][] = true;
|
||||
$tokens[$i][4] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user