mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-02 13:09:53 +09:00
Update composer dependencies
This commit is contained in:
42
vendor/symfony/routing/RouteCompiler.php
vendored
42
vendor/symfony/routing/RouteCompiler.php
vendored
@@ -46,10 +46,10 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
*/
|
||||
public static function compile(Route $route)
|
||||
{
|
||||
$hostVariables = array();
|
||||
$variables = array();
|
||||
$hostVariables = [];
|
||||
$variables = [];
|
||||
$hostRegex = null;
|
||||
$hostTokens = array();
|
||||
$hostTokens = [];
|
||||
|
||||
if ('' !== $host = $route->getHost()) {
|
||||
$result = self::compilePattern($route, $host, true);
|
||||
@@ -94,9 +94,9 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
|
||||
private static function compilePattern(Route $route, $pattern, $isHost)
|
||||
{
|
||||
$tokens = array();
|
||||
$variables = array();
|
||||
$matches = array();
|
||||
$tokens = [];
|
||||
$variables = [];
|
||||
$matches = [];
|
||||
$pos = 0;
|
||||
$defaultSeparator = $isHost ? '.' : '/';
|
||||
$useUtf8 = preg_match('//u', $pattern);
|
||||
@@ -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]);
|
||||
@@ -142,9 +143,9 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
}
|
||||
|
||||
if ($isSeparator && $precedingText !== $precedingChar) {
|
||||
$tokens[] = array('text', substr($precedingText, 0, -\strlen($precedingChar)));
|
||||
$tokens[] = ['text', substr($precedingText, 0, -\strlen($precedingChar))];
|
||||
} elseif (!$isSeparator && \strlen($precedingText) > 0) {
|
||||
$tokens[] = array('text', $precedingText);
|
||||
$tokens[] = ['text', $precedingText];
|
||||
}
|
||||
|
||||
$regexp = $route->getRequirement($varName);
|
||||
@@ -153,7 +154,7 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
// Find the next static character after the variable that functions as a separator. By default, this separator and '/'
|
||||
// are disallowed for the variable. This default requirement makes sure that optional variables can be matched at all
|
||||
// and that the generating-matching-combination of URLs unambiguous, i.e. the params used for generating the URL are
|
||||
// the same that will be matched. Example: new Route('/{page}.{_format}', array('_format' => 'html'))
|
||||
// the same that will be matched. Example: new Route('/{page}.{_format}', ['_format' => 'html'])
|
||||
// If {page} would also match the separating dot, {_format} would never match as {page} will eagerly consume everything.
|
||||
// Also even if {_format} was not optional the requirement prevents that {page} matches something that was originally
|
||||
// part of {_format} when generating the URL, e.g. _format = 'mobile.html'.
|
||||
@@ -183,12 +184,18 @@ class RouteCompiler implements RouteCompilerInterface
|
||||
$regexp = self::transformCapturingGroupsToNonCapturings($regexp);
|
||||
}
|
||||
|
||||
$tokens[] = array('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;
|
||||
}
|
||||
|
||||
if ($pos < \strlen($pattern)) {
|
||||
$tokens[] = array('text', substr($pattern, $pos));
|
||||
$tokens[] = ['text', substr($pattern, $pos)];
|
||||
}
|
||||
|
||||
// find the first optional token
|
||||
@@ -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,17 +224,17 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'staticPrefix' => self::determineStaticPrefix($route, $tokens),
|
||||
'regex' => $regexp,
|
||||
'tokens' => array_reverse($tokens),
|
||||
'variables' => $variables,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user