Skip to content

Commit c948191

Browse files
committed
fixed CS
1 parent 150d53b commit c948191

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

Matcher/Dumper/PhpMatcherDumper.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private function generateMatchMethod(): string
111111

112112
$code = <<<EOF
113113
{
114-
\$allow = \$allowSchemes = array();
114+
\$allow = \$allowSchemes = [];
115115
\$pathinfo = rawurldecode(\$pathinfo) ?: '/';
116116
\$trimmedPathinfo = rtrim(\$pathinfo, '/') ?: '/';
117117
\$context = \$this->context;
@@ -129,14 +129,14 @@ private function generateMatchMethod(): string
129129
return <<<'EOF'
130130
public function match($pathinfo)
131131
{
132-
$allow = $allowSchemes = array();
132+
$allow = $allowSchemes = [];
133133
if ($ret = $this->doMatch($pathinfo, $allow, $allowSchemes)) {
134134
return $ret;
135135
}
136136
if ($allow) {
137137
throw new MethodNotAllowedException(array_keys($allow));
138138
}
139-
if (!in_array($this->context->getMethod(), array('HEAD', 'GET'), true)) {
139+
if (!in_array($this->context->getMethod(), ['HEAD', 'GET'], true)) {
140140
// no-op
141141
} elseif ($allowSchemes) {
142142
redirect_scheme:
@@ -162,10 +162,10 @@ public function match($pathinfo)
162162
throw new ResourceNotFoundException();
163163
}
164164
165-
private function doMatch(string $pathinfo, array &$allow = array(), array &$allowSchemes = array()): array
165+
private function doMatch(string $pathinfo, array &$allow = [], array &$allowSchemes = []): array
166166

167167
EOF
168-
.$code."\n return array();\n }";
168+
.$code."\n return [];\n }";
169169
}
170170

171171
return " public function match(\$pathinfo)\n".$code."\n throw \$allow ? new MethodNotAllowedException(array_keys(\$allow)) : new ResourceNotFoundException();\n }";
@@ -272,7 +272,7 @@ private function compileStaticRoutes(array $staticRoutes, bool $matchHost): stri
272272
unset($defaults['_canonical_route']);
273273
}
274274
$default .= sprintf(
275-
"%s => array(%s, %s, %s, %s, %s),\n",
275+
"%s => [%s, %s, %s, %s, %s],\n",
276276
self::export($url),
277277
self::export(['_route' => $name] + $defaults),
278278
self::export(!$route->compile()->getHostVariables() ? $route->getHost() : $route->compile()->getHostRegex() ?: null),
@@ -294,8 +294,8 @@ private function compileStaticRoutes(array $staticRoutes, bool $matchHost): stri
294294
if ($default) {
295295
$code .= <<<EOF
296296
default:
297-
\$routes = array(
298-
{$this->indent($default, 4)} );
297+
\$routes = [
298+
{$this->indent($default, 4)} ];
299299
300300
if (!isset(\$routes[\$trimmedPathinfo])) {
301301
break;
@@ -437,8 +437,8 @@ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHo
437437
if ($state->default) {
438438
$state->switch .= <<<EOF
439439
default:
440-
\$routes = array(
441-
{$this->indent($state->default, 4)} );
440+
\$routes = [
441+
{$this->indent($state->default, 4)} ];
442442
443443
list(\$ret, \$vars, \$requiredMethods, \$requiredSchemes, \$hasTrailingSlash, \$hasTrailingVar) = \$routes[\$m];
444444
{$this->compileSwitchDefault(true, $matchHost)}
@@ -450,8 +450,8 @@ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHo
450450

451451
return <<<EOF
452452
\$matchedPathinfo = {$matchedPathinfo};
453-
\$regexList = array({$code}
454-
);
453+
\$regexList = [{$code}
454+
];
455455
456456
foreach (\$regexList as \$offset => \$regex) {
457457
while (preg_match(\$regex, \$matchedPathinfo, \$matches)) {
@@ -518,7 +518,7 @@ private function compileStaticPrefixCollection(StaticPrefixCollection $tree, \st
518518
unset($defaults['_canonical_route']);
519519
}
520520
$state->default .= sprintf(
521-
"%s => array(%s, %s, %s, %s, %s, %s),\n",
521+
"%s => [%s, %s, %s, %s, %s, %s],\n",
522522
$state->mark,
523523
self::export(['_route' => $name] + $defaults),
524524
self::export($vars),
@@ -551,7 +551,7 @@ private function compileSwitchDefault(bool $hasVars, bool $matchHost): string
551551
$code = <<<'EOF'
552552
553553
if ('GET' === $canonicalMethod && (!$requiredMethods || isset($requiredMethods['GET']))) {
554-
return $allow = $allowSchemes = array();
554+
return $allow = $allowSchemes = [];
555555
}
556556
EOF;
557557
} else {
@@ -699,7 +699,7 @@ private function compileRoute(Route $route, string $name, bool $checkHost, bool
699699
$code = sprintf($code, <<<'EOF'
700700
701701
if ('GET' === $canonicalMethod) {
702-
return $allow = $allowSchemes = array();
702+
return $allow = $allowSchemes = [];
703703
}
704704
EOF
705705
,
@@ -710,11 +710,11 @@ private function compileRoute(Route $route, string $name, bool $checkHost, bool
710710
}
711711

712712
if ($vars) {
713-
$code .= ' $matches = array(';
713+
$code .= ' $matches = [';
714714
foreach ($vars as $j => $m) {
715715
$code .= sprintf('%s => $matches[%d] ?? null, ', self::export($m), 1 + $j);
716716
}
717-
$code = substr_replace($code, ");\n\n", -2);
717+
$code = substr_replace($code, "];\n\n", -2);
718718
}
719719

720720
if ($route->getCondition()) {
@@ -755,7 +755,7 @@ private function compileRoute(Route $route, string $name, bool $checkHost, bool
755755

756756
// optimize parameters array
757757
if ($matches || $hostMatches) {
758-
$vars = ["array('_route' => '$name')"];
758+
$vars = ["['_route' => '$name']"];
759759
if ($matches || ($hostMatches && !$checkHost)) {
760760
$vars[] = '$matches';
761761
}
@@ -771,7 +771,7 @@ private function compileRoute(Route $route, string $name, bool $checkHost, bool
771771
} elseif ($defaults) {
772772
$code .= sprintf(" \$ret = %s;\n", self::export(['_route' => $name] + $defaults));
773773
} else {
774-
$code .= sprintf(" \$ret = array('_route' => '%s');\n", $name);
774+
$code .= sprintf(" \$ret = ['_route' => '%s'];\n", $name);
775775
}
776776

777777
if ($methods) {
@@ -865,11 +865,11 @@ public static function export($value): string
865865
return str_replace("\n", '\'."\n".\'', var_export($value, true));
866866
}
867867
if (!$value) {
868-
return 'array()';
868+
return '[]';
869869
}
870870

871871
$i = 0;
872-
$export = 'array(';
872+
$export = '[';
873873

874874
foreach ($value as $k => $v) {
875875
if ($i === $k) {
@@ -885,6 +885,6 @@ public static function export($value): string
885885
$export .= self::export($v).', ';
886886
}
887887

888-
return substr_replace($export, ')', -2);
888+
return substr_replace($export, ']', -2);
889889
}
890890
}

0 commit comments

Comments
 (0)