Skip to content

Commit 8bc2600

Browse files
committed
fixed CS
1 parent 32c7238 commit 8bc2600

File tree

4 files changed

+68
-68
lines changed

4 files changed

+68
-68
lines changed

Matcher/Dumper/PhpMatcherDumper.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PhpMatcherDumper extends MatcherDumper
3232
/**
3333
* @var ExpressionFunctionProviderInterface[]
3434
*/
35-
private $expressionLanguageProviders = array();
35+
private $expressionLanguageProviders = [];
3636

3737
/**
3838
* Dumps a set of routes to a PHP class.
@@ -46,12 +46,12 @@ class PhpMatcherDumper extends MatcherDumper
4646
*
4747
* @return string A PHP class representing the matcher class
4848
*/
49-
public function dump(array $options = array())
49+
public function dump(array $options = [])
5050
{
51-
$options = array_replace(array(
51+
$options = array_replace([
5252
'class' => 'ProjectUrlMatcher',
5353
'base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher',
54-
), $options);
54+
], $options);
5555

5656
// trailing slash support is only enabled if we know how to redirect the user
5757
$interfaces = class_implements($options['base_class']);
@@ -98,7 +98,7 @@ private function generateProperties(): string
9898
$host = '/'.strtr(strrev($host), '}.{', '(/)');
9999
}
100100

101-
$routes->addRoute($host ?: '/(.*)', array($name, $route));
101+
$routes->addRoute($host ?: '/(.*)', [$name, $route]);
102102
}
103103

104104
if ($matchHost) {
@@ -111,7 +111,7 @@ private function generateProperties(): string
111111

112112
list($staticRoutes, $dynamicRoutes) = $this->groupStaticRoutes($routes);
113113

114-
$conditions = array(null);
114+
$conditions = [null];
115115
$code .= $this->compileStaticRoutes($staticRoutes, $conditions);
116116
$chunkLimit = \count($dynamicRoutes);
117117

@@ -154,7 +154,7 @@ private function generateProperties(): string
154154
*/
155155
private function groupStaticRoutes(RouteCollection $collection): array
156156
{
157-
$staticRoutes = $dynamicRegex = array();
157+
$staticRoutes = $dynamicRegex = [];
158158
$dynamicRoutes = new RouteCollection();
159159

160160
foreach ($collection->all() as $name => $route) {
@@ -175,20 +175,20 @@ private function groupStaticRoutes(RouteCollection $collection): array
175175
}
176176
foreach ($dynamicRegex as list($hostRx, $rx)) {
177177
if (preg_match($rx, $url) && (!$host || !$hostRx || preg_match($hostRx, $host))) {
178-
$dynamicRegex[] = array($hostRegex, $regex);
178+
$dynamicRegex[] = [$hostRegex, $regex];
179179
$dynamicRoutes->add($name, $route);
180180
continue 2;
181181
}
182182
}
183183

184-
$staticRoutes[$url][$name] = array($route, $hasTrailingSlash);
184+
$staticRoutes[$url][$name] = [$route, $hasTrailingSlash];
185185
} else {
186-
$dynamicRegex[] = array($hostRegex, $regex);
186+
$dynamicRegex[] = [$hostRegex, $regex];
187187
$dynamicRoutes->add($name, $route);
188188
}
189189
}
190190

191-
return array($staticRoutes, $dynamicRoutes);
191+
return [$staticRoutes, $dynamicRoutes];
192192
}
193193

194194
/**
@@ -245,14 +245,14 @@ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHo
245245
return '';
246246
}
247247
$code = '';
248-
$state = (object) array(
248+
$state = (object) [
249249
'regex' => '',
250250
'routes' => '',
251251
'mark' => 0,
252252
'markTail' => 0,
253-
'hostVars' => array(),
254-
'vars' => array(),
255-
);
253+
'hostVars' => [],
254+
'vars' => [],
255+
];
256256
$state->getVars = static function ($m) use ($state) {
257257
if ('_route' === $m[1]) {
258258
return '?:';
@@ -265,26 +265,26 @@ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHo
265265

266266
$chunkSize = 0;
267267
$prev = null;
268-
$perModifiers = array();
268+
$perModifiers = [];
269269
foreach ($collection->all() as $name => $route) {
270270
preg_match('#[a-zA-Z]*$#', $route->compile()->getRegex(), $rx);
271271
if ($chunkLimit < ++$chunkSize || $prev !== $rx[0] && $route->compile()->getPathVariables()) {
272272
$chunkSize = 1;
273273
$routes = new RouteCollection();
274-
$perModifiers[] = array($rx[0], $routes);
274+
$perModifiers[] = [$rx[0], $routes];
275275
$prev = $rx[0];
276276
}
277277
$routes->add($name, $route);
278278
}
279279

280280
foreach ($perModifiers as list($modifiers, $routes)) {
281281
$prev = false;
282-
$perHost = array();
282+
$perHost = [];
283283
foreach ($routes->all() as $name => $route) {
284284
$regex = $route->compile()->getHostRegex();
285285
if ($prev !== $regex) {
286286
$routes = new RouteCollection();
287-
$perHost[] = array($regex, $routes);
287+
$perHost[] = [$regex, $routes];
288288
$prev = $regex;
289289
}
290290
$routes->add($name, $route);
@@ -299,12 +299,12 @@ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHo
299299
if ($matchHost) {
300300
if ($hostRegex) {
301301
preg_match('#^.\^(.*)\$.[a-zA-Z]*$#', $hostRegex, $rx);
302-
$state->vars = array();
302+
$state->vars = [];
303303
$hostRegex = '(?i:'.preg_replace_callback('#\?P<([^>]++)>#', $state->getVars, $rx[1]).')\.';
304304
$state->hostVars = $state->vars;
305305
} else {
306306
$hostRegex = '(?:(?:[^./]*+\.)++)';
307-
$state->hostVars = array();
307+
$state->hostVars = [];
308308
}
309309
$state->mark += \strlen($rx = ($prev ? ')' : '')."|{$hostRegex}(?");
310310
$code .= "\n .".self::export($rx);
@@ -316,14 +316,14 @@ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHo
316316
foreach ($routes->all() as $name => $route) {
317317
preg_match('#^.\^(.*)\$.[a-zA-Z]*$#', $route->compile()->getRegex(), $rx);
318318

319-
$state->vars = array();
319+
$state->vars = [];
320320
$regex = preg_replace_callback('#\?P<([^>]++)>#', $state->getVars, $rx[1]);
321321
if ($hasTrailingSlash = '/' !== $regex && '/' === $regex[-1]) {
322322
$regex = substr($regex, 0, -1);
323323
}
324324
$hasTrailingVar = (bool) preg_match('#\{\w+\}/?$#', $route->getPath());
325325

326-
$tree->addRoute($regex, array($name, $regex, $state->vars, $route, $hasTrailingSlash, $hasTrailingVar));
326+
$tree->addRoute($regex, [$name, $regex, $state->vars, $route, $hasTrailingSlash, $hasTrailingVar]);
327327
}
328328

329329
$code .= $this->compileStaticPrefixCollection($tree, $state, 0, $conditions);
@@ -413,15 +413,15 @@ private function compileRoute(Route $route, string $name, $vars, bool $hasTraili
413413
}
414414

415415
if ($condition = $route->getCondition()) {
416-
$condition = $this->getExpressionLanguage()->compile($condition, array('context', 'request'));
416+
$condition = $this->getExpressionLanguage()->compile($condition, ['context', 'request']);
417417
$condition = $conditions[$condition] ?? $conditions[$condition] = (false !== strpos($condition, '$request') ? 1 : -1) * \count($conditions);
418418
} else {
419419
$condition = 'null';
420420
}
421421

422422
return sprintf(
423423
" array(%s, %s, %s, %s, %s, %s, %s),\n",
424-
self::export(array('_route' => $name) + $defaults),
424+
self::export(['_route' => $name] + $defaults),
425425
self::export($vars),
426426
self::export(array_flip($route->getMethods()) ?: null),
427427
self::export(array_flip($route->getSchemes()) ?: null),

Matcher/Dumper/PhpMatcherTrait.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
trait PhpMatcherTrait
2525
{
2626
private $matchHost = false;
27-
private $staticRoutes = array();
28-
private $regexpList = array();
29-
private $dynamicRoutes = array();
27+
private $staticRoutes = [];
28+
private $regexpList = [];
29+
private $dynamicRoutes = [];
3030
private $checkCondition;
3131

3232
public function match($pathinfo)
3333
{
34-
$allow = $allowSchemes = array();
34+
$allow = $allowSchemes = [];
3535
if ($ret = $this->doMatch($pathinfo, $allow, $allowSchemes)) {
3636
return $ret;
3737
}
@@ -41,7 +41,7 @@ public function match($pathinfo)
4141
if (!$this instanceof RedirectableUrlMatcherInterface) {
4242
throw new ResourceNotFoundException();
4343
}
44-
if (!\in_array($this->context->getMethod(), array('HEAD', 'GET'), true)) {
44+
if (!\in_array($this->context->getMethod(), ['HEAD', 'GET'], true)) {
4545
// no-op
4646
} elseif ($allowSchemes) {
4747
redirect_scheme:
@@ -67,9 +67,9 @@ public function match($pathinfo)
6767
throw new ResourceNotFoundException();
6868
}
6969

70-
private function doMatch(string $pathinfo, array &$allow = array(), array &$allowSchemes = array()): array
70+
private function doMatch(string $pathinfo, array &$allow = [], array &$allowSchemes = []): array
7171
{
72-
$allow = $allowSchemes = array();
72+
$allow = $allowSchemes = [];
7373
$pathinfo = rawurldecode($pathinfo) ?: '/';
7474
$trimmedPathinfo = rtrim($pathinfo, '/') ?: '/';
7575
$context = $this->context;
@@ -84,14 +84,14 @@ private function doMatch(string $pathinfo, array &$allow = array(), array &$allo
8484
}
8585
$supportsRedirections = 'GET' === $canonicalMethod && $this instanceof RedirectableUrlMatcherInterface;
8686

87-
foreach ($this->staticRoutes[$trimmedPathinfo] ?? array() as list($ret, $requiredHost, $requiredMethods, $requiredSchemes, $hasTrailingSlash, , $condition)) {
87+
foreach ($this->staticRoutes[$trimmedPathinfo] ?? [] as list($ret, $requiredHost, $requiredMethods, $requiredSchemes, $hasTrailingSlash, , $condition)) {
8888
if ($condition && !($this->checkCondition)($condition, $context, 0 < $condition ? $request ?? $request = $this->request ?: $this->createRequest($pathinfo) : null)) {
8989
continue;
9090
}
9191

9292
if ('/' !== $pathinfo && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) {
9393
if ($supportsRedirections && (!$requiredMethods || isset($requiredMethods['GET']))) {
94-
return $allow = $allowSchemes = array();
94+
return $allow = $allowSchemes = [];
9595
}
9696
continue;
9797
}
@@ -140,7 +140,7 @@ private function doMatch(string $pathinfo, array &$allow = array(), array &$allo
140140

141141
if ('/' !== $pathinfo && $hasTrailingSlash === ($trimmedPathinfo === $pathinfo)) {
142142
if ($supportsRedirections && (!$requiredMethods || isset($requiredMethods['GET']))) {
143-
return $allow = $allowSchemes = array();
143+
return $allow = $allowSchemes = [];
144144
}
145145
if ($trimmedPathinfo === $pathinfo || !$hasTrailingVar) {
146146
continue;
@@ -177,6 +177,6 @@ private function doMatch(string $pathinfo, array &$allow = array(), array &$allo
177177
throw new NoConfigurationException();
178178
}
179179

180-
return array();
180+
return [];
181181
}
182182
}

0 commit comments

Comments
 (0)