updated packages

This commit is contained in:
2019-05-18 09:06:43 +00:00
parent 901d16349e
commit e9487fa58a
2025 changed files with 30366 additions and 49653 deletions

View File

@@ -32,7 +32,7 @@ class PhpMatcherDumper extends MatcherDumper
/**
* @var ExpressionFunctionProviderInterface[]
*/
private $expressionLanguageProviders = array();
private $expressionLanguageProviders = [];
/**
* Dumps a set of routes to a PHP class.
@@ -46,12 +46,12 @@ class PhpMatcherDumper extends MatcherDumper
*
* @return string A PHP class representing the matcher class
*/
public function dump(array $options = array())
public function dump(array $options = [])
{
$options = array_replace(array(
$options = array_replace([
'class' => 'ProjectUrlMatcher',
'base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher',
), $options);
], $options);
// trailing slash support is only enabled if we know how to redirect the user
$interfaces = class_implements($options['base_class']);
@@ -98,7 +98,7 @@ EOF;
$host = '/'.strtr(strrev($host), '}.{', '(/)');
}
$routes->addRoute($host ?: '/(.*)', array($name, $route));
$routes->addRoute($host ?: '/(.*)', [$name, $route]);
}
if ($matchHost) {
@@ -111,7 +111,7 @@ EOF;
list($staticRoutes, $dynamicRoutes) = $this->groupStaticRoutes($routes);
$conditions = array(null);
$conditions = [null];
$code .= $this->compileStaticRoutes($staticRoutes, $conditions);
$chunkLimit = \count($dynamicRoutes);
@@ -154,11 +154,12 @@ EOF;
*/
private function groupStaticRoutes(RouteCollection $collection): array
{
$staticRoutes = $dynamicRegex = array();
$staticRoutes = $dynamicRegex = [];
$dynamicRoutes = new RouteCollection();
foreach ($collection->all() as $name => $route) {
$compiledRoute = $route->compile();
$staticPrefix = rtrim($compiledRoute->getStaticPrefix(), '/');
$hostRegex = $compiledRoute->getHostRegex();
$regex = $compiledRoute->getRegex();
if ($hasTrailingSlash = '/' !== $route->getPath()) {
@@ -173,22 +174,22 @@ EOF;
if ($hasTrailingSlash) {
$url = substr($url, 0, -1);
}
foreach ($dynamicRegex as list($hostRx, $rx)) {
if (preg_match($rx, $url) && (!$host || !$hostRx || preg_match($hostRx, $host))) {
$dynamicRegex[] = array($hostRegex, $regex);
foreach ($dynamicRegex as list($hostRx, $rx, $prefix)) {
if (('' === $prefix || 0 === strpos($url, $prefix)) && preg_match($rx, $url) && (!$host || !$hostRx || preg_match($hostRx, $host))) {
$dynamicRegex[] = [$hostRegex, $regex, $staticPrefix];
$dynamicRoutes->add($name, $route);
continue 2;
}
}
$staticRoutes[$url][$name] = array($route, $hasTrailingSlash);
$staticRoutes[$url][$name] = [$route, $hasTrailingSlash];
} else {
$dynamicRegex[] = array($hostRegex, $regex);
$dynamicRegex[] = [$hostRegex, $regex, $staticPrefix];
$dynamicRoutes->add($name, $route);
}
}
return array($staticRoutes, $dynamicRoutes);
return [$staticRoutes, $dynamicRoutes];
}
/**
@@ -207,15 +208,15 @@ EOF;
$code = '';
foreach ($staticRoutes as $url => $routes) {
$code .= self::export($url)." => array(\n";
$code .= self::export($url)." => [\n";
foreach ($routes as $name => list($route, $hasTrailingSlash)) {
$code .= $this->compileRoute($route, $name, !$route->compile()->getHostVariables() ? $route->getHost() : $route->compile()->getHostRegex() ?: null, $hasTrailingSlash, false, $conditions);
$code .= $this->compileRoute($route, $name, (!$route->compile()->getHostVariables() ? $route->getHost() : $route->compile()->getHostRegex()) ?: null, $hasTrailingSlash, false, $conditions);
}
$code .= "),\n";
$code .= "],\n";
}
if ($code) {
return "\$this->staticRoutes = array(\n{$this->indent($code, 1)});\n";
return "\$this->staticRoutes = [\n{$this->indent($code, 1)}];\n";
}
return $code;
@@ -245,14 +246,14 @@ EOF;
return '';
}
$code = '';
$state = (object) array(
$state = (object) [
'regex' => '',
'routes' => '',
'mark' => 0,
'markTail' => 0,
'hostVars' => array(),
'vars' => array(),
);
'hostVars' => [],
'vars' => [],
];
$state->getVars = static function ($m) use ($state) {
if ('_route' === $m[1]) {
return '?:';
@@ -265,13 +266,13 @@ EOF;
$chunkSize = 0;
$prev = null;
$perModifiers = array();
$perModifiers = [];
foreach ($collection->all() as $name => $route) {
preg_match('#[a-zA-Z]*$#', $route->compile()->getRegex(), $rx);
if ($chunkLimit < ++$chunkSize || $prev !== $rx[0] && $route->compile()->getPathVariables()) {
$chunkSize = 1;
$routes = new RouteCollection();
$perModifiers[] = array($rx[0], $routes);
$perModifiers[] = [$rx[0], $routes];
$prev = $rx[0];
}
$routes->add($name, $route);
@@ -279,12 +280,12 @@ EOF;
foreach ($perModifiers as list($modifiers, $routes)) {
$prev = false;
$perHost = array();
$perHost = [];
foreach ($routes->all() as $name => $route) {
$regex = $route->compile()->getHostRegex();
if ($prev !== $regex) {
$routes = new RouteCollection();
$perHost[] = array($regex, $routes);
$perHost[] = [$regex, $routes];
$prev = $regex;
}
$routes->add($name, $route);
@@ -299,12 +300,12 @@ EOF;
if ($matchHost) {
if ($hostRegex) {
preg_match('#^.\^(.*)\$.[a-zA-Z]*$#', $hostRegex, $rx);
$state->vars = array();
$state->vars = [];
$hostRegex = '(?i:'.preg_replace_callback('#\?P<([^>]++)>#', $state->getVars, $rx[1]).')\.';
$state->hostVars = $state->vars;
} else {
$hostRegex = '(?:(?:[^./]*+\.)++)';
$state->hostVars = array();
$state->hostVars = [];
}
$state->mark += \strlen($rx = ($prev ? ')' : '')."|{$hostRegex}(?");
$code .= "\n .".self::export($rx);
@@ -316,14 +317,14 @@ EOF;
foreach ($routes->all() as $name => $route) {
preg_match('#^.\^(.*)\$.[a-zA-Z]*$#', $route->compile()->getRegex(), $rx);
$state->vars = array();
$state->vars = [];
$regex = preg_replace_callback('#\?P<([^>]++)>#', $state->getVars, $rx[1]);
if ($hasTrailingSlash = '/' !== $regex && '/' === $regex[-1]) {
$regex = substr($regex, 0, -1);
}
$hasTrailingVar = (bool) preg_match('#\{\w+\}/?$#', $route->getPath());
$tree->addRoute($regex, array($name, $regex, $state->vars, $route, $hasTrailingSlash, $hasTrailingVar));
$tree->addRoute($regex, [$name, $regex, $state->vars, $route, $hasTrailingSlash, $hasTrailingVar]);
}
$code .= $this->compileStaticPrefixCollection($tree, $state, 0, $conditions);
@@ -348,8 +349,8 @@ EOF;
unset($state->getVars);
return "\$this->regexpList = array({$code}\n);\n"
."\$this->dynamicRoutes = array(\n{$this->indent($state->routes, 1)});\n";
return "\$this->regexpList = [{$code}\n];\n"
."\$this->dynamicRoutes = [\n{$this->indent($state->routes, 1)}];\n";
}
/**
@@ -394,7 +395,7 @@ EOF;
$state->regex .= $rx;
$prevRegex = $compiledRoute->getRegex();
$state->routes .= sprintf("%s => array(\n%s),\n", $state->mark, $this->compileRoute($route, $name, $vars, $hasTrailingSlash, $hasTrailingVar, $conditions));
$state->routes .= sprintf("%s => [\n%s],\n", $state->mark, $this->compileRoute($route, $name, $vars, $hasTrailingSlash, $hasTrailingVar, $conditions));
}
return $code;
@@ -413,15 +414,15 @@ EOF;
}
if ($condition = $route->getCondition()) {
$condition = $this->getExpressionLanguage()->compile($condition, array('context', 'request'));
$condition = $this->getExpressionLanguage()->compile($condition, ['context', 'request']);
$condition = $conditions[$condition] ?? $conditions[$condition] = (false !== strpos($condition, '$request') ? 1 : -1) * \count($conditions);
} else {
$condition = 'null';
}
return sprintf(
" array(%s, %s, %s, %s, %s, %s, %s),\n",
self::export(array('_route' => $name) + $defaults),
" [%s, %s, %s, %s, %s, %s, %s],\n",
self::export(['_route' => $name] + $defaults),
self::export($vars),
self::export(array_flip($route->getMethods()) ?: null),
self::export(array_flip($route->getSchemes()) ?: null),
@@ -445,7 +446,7 @@ EOF;
private function indent($code, $level = 1)
{
$code = preg_replace('/ => array\(\n (array\(.+),\n\),/', ' => array($1),', $code);
$code = preg_replace('/ => \[\n (\[.+),\n\],/', ' => [$1],', $code);
return preg_replace('/^./m', str_repeat(' ', $level).'$0', $code);
}
@@ -466,11 +467,11 @@ EOF;
return str_replace("\n", '\'."\n".\'', var_export($value, true));
}
if (!$value) {
return 'array()';
return '[]';
}
$i = 0;
$export = 'array(';
$export = '[';
foreach ($value as $k => $v) {
if ($i === $k) {
@@ -486,6 +487,6 @@ EOF;
$export .= self::export($v).', ';
}
return substr_replace($export, ')', -2);
return substr_replace($export, ']', -2);
}
}