Skip to content

Commit 4b1b180

Browse files
committed
fixed CS
1 parent 700aa78 commit 4b1b180

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

Dumper/PhpDumper.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public function dump(array $options = [])
224224
if ($this->addGetService) {
225225
$code = preg_replace(
226226
"/(\r?\n\r?\n public function __construct.+?\\{\r?\n)/s",
227-
"\n private \$getService;$1 \$this->getService = \\Closure::fromCallable(array(\$this, 'getService'));\n",
227+
"\n private \$getService;$1 \$this->getService = \\Closure::fromCallable([\$this, 'getService']);\n",
228228
$code,
229229
1
230230
);
@@ -250,11 +250,11 @@ public function dump(array $options = [])
250250
}
251251
if ($ids = array_keys($ids)) {
252252
sort($ids);
253-
$c = "<?php\n\nreturn array(\n";
253+
$c = "<?php\n\nreturn [\n";
254254
foreach ($ids as $id) {
255255
$c .= ' '.$this->doExport($id)." => true,\n";
256256
}
257-
$files['removed-ids.php'] = $c .= ");\n";
257+
$files['removed-ids.php'] = $c .= "];\n";
258258
}
259259

260260
foreach ($this->generateServiceFiles($services) as $file => $c) {
@@ -293,11 +293,11 @@ public function dump(array $options = [])
293293
\\class_alias(\\Container{$hash}\\{$options['class']}::class, {$options['class']}::class, false);
294294
}
295295
296-
return new \\Container{$hash}\\{$options['class']}(array(
296+
return new \\Container{$hash}\\{$options['class']}([
297297
'container.build_hash' => '$hash',
298298
'container.build_id' => '$id',
299299
'container.build_time' => $time,
300-
), __DIR__.\\DIRECTORY_SEPARATOR.'Container{$hash}');
300+
], __DIR__.\\DIRECTORY_SEPARATOR.'Container{$hash}');
301301
302302
EOF;
303303
} else {
@@ -952,7 +952,7 @@ private function startClass(string $class, string $baseClass, string $baseClassW
952952
class $class extends $baseClass
953953
{
954954
private \$parameters;
955-
private \$targetDirs = array();
955+
private \$targetDirs = [];
956956
957957
public function __construct()
958958
{
@@ -970,7 +970,7 @@ public function __construct()
970970
}
971971
if ($this->asFiles) {
972972
$code = str_replace('$parameters', "\$buildParameters;\n private \$containerDir;\n private \$parameters", $code);
973-
$code = str_replace('__construct()', '__construct(array $buildParameters = array(), $containerDir = __DIR__)', $code);
973+
$code = str_replace('__construct()', '__construct(array $buildParameters = [], $containerDir = __DIR__)', $code);
974974
$code .= " \$this->buildParameters = \$buildParameters;\n";
975975
$code .= " \$this->containerDir = \$containerDir;\n";
976976
}
@@ -990,7 +990,7 @@ public function __construct()
990990
if ($this->container->getParameterBag()->all()) {
991991
$code .= " \$this->parameters = \$this->getDefaultParameters();\n\n";
992992
}
993-
$code .= " \$this->services = \$this->privates = array();\n";
993+
$code .= " \$this->services = \$this->privates = [];\n";
994994

995995
$code .= $this->addSyntheticIds();
996996
$code .= $this->addMethodMap();
@@ -1064,7 +1064,7 @@ private function addSyntheticIds(): string
10641064
}
10651065
}
10661066

1067-
return $code ? " \$this->syntheticIds = array(\n{$code} );\n" : '';
1067+
return $code ? " \$this->syntheticIds = [\n{$code} ];\n" : '';
10681068
}
10691069

10701070
private function addRemovedIds(): string
@@ -1091,7 +1091,7 @@ private function addRemovedIds(): string
10911091
$code .= ' '.$this->doExport($id)." => true,\n";
10921092
}
10931093

1094-
$code = "array(\n{$code} )";
1094+
$code = "[\n{$code} ]";
10951095
}
10961096

10971097
return <<<EOF
@@ -1115,7 +1115,7 @@ private function addMethodMap(): string
11151115
}
11161116
}
11171117

1118-
return $code ? " \$this->methodMap = array(\n{$code} );\n" : '';
1118+
return $code ? " \$this->methodMap = [\n{$code} ];\n" : '';
11191119
}
11201120

11211121
private function addFileMap(): string
@@ -1129,16 +1129,16 @@ private function addFileMap(): string
11291129
}
11301130
}
11311131

1132-
return $code ? " \$this->fileMap = array(\n{$code} );\n" : '';
1132+
return $code ? " \$this->fileMap = [\n{$code} ];\n" : '';
11331133
}
11341134

11351135
private function addAliases(): string
11361136
{
11371137
if (!$aliases = $this->container->getAliases()) {
1138-
return "\n \$this->aliases = array();\n";
1138+
return "\n \$this->aliases = [];\n";
11391139
}
11401140

1141-
$code = " \$this->aliases = array(\n";
1141+
$code = " \$this->aliases = [\n";
11421142
ksort($aliases);
11431143
foreach ($aliases as $alias => $id) {
11441144
$id = (string) $id;
@@ -1148,7 +1148,7 @@ private function addAliases(): string
11481148
$code .= ' '.$this->doExport($alias).' => '.$this->doExport($id).",\n";
11491149
}
11501150

1151-
return $code." );\n";
1151+
return $code." ];\n";
11521152
}
11531153

11541154
private function addInlineRequires(): string
@@ -1196,15 +1196,15 @@ private function addDefaultParametersMethod(): string
11961196
throw new InvalidArgumentException(sprintf('Parameter name cannot use env parameters: %s.', $resolvedKey));
11971197
}
11981198
$export = $this->exportParameters([$value]);
1199-
$export = explode('0 => ', substr(rtrim($export, " )\n"), 7, -1), 2);
1199+
$export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2);
12001200

12011201
if (preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDirs\[\d++\])/", $export[1])) {
12021202
$dynamicPhp[$key] = sprintf('%scase %s: $value = %s; break;', $export[0], $this->export($key), $export[1]);
12031203
} else {
12041204
$php[] = sprintf('%s%s => %s,', $export[0], $this->export($key), $export[1]);
12051205
}
12061206
}
1207-
$parameters = sprintf("array(\n%s\n%s)", implode("\n", $php), str_repeat(' ', 8));
1207+
$parameters = sprintf("[\n%s\n%s]", implode("\n", $php), str_repeat(' ', 8));
12081208

12091209
$code = <<<'EOF'
12101210
@@ -1274,14 +1274,14 @@ public function getParameterBag()
12741274
EOF;
12751275
$getDynamicParameter = sprintf($getDynamicParameter, implode("\n", $dynamicPhp));
12761276
} else {
1277-
$loadedDynamicParameters = 'array()';
1277+
$loadedDynamicParameters = '[]';
12781278
$getDynamicParameter = str_repeat(' ', 8).'throw new InvalidArgumentException(sprintf(\'The dynamic parameter "%s" must be defined.\', $name));';
12791279
}
12801280

12811281
$code .= <<<EOF
12821282
12831283
private \$loadedDynamicParameters = {$loadedDynamicParameters};
1284-
private \$dynamicParameters = array();
1284+
private \$dynamicParameters = [];
12851285
12861286
/*{$this->docStar}
12871287
* Computes a dynamic parameter.
@@ -1338,7 +1338,7 @@ private function exportParameters(array $parameters, string $path = '', int $ind
13381338
$php[] = sprintf('%s%s => %s,', str_repeat(' ', $indent), $this->export($key), $value);
13391339
}
13401340

1341-
return sprintf("array(\n%s\n%s)", implode("\n", $php), str_repeat(' ', $indent - 4));
1341+
return sprintf("[\n%s\n%s]", implode("\n", $php), str_repeat(' ', $indent - 4));
13421342
}
13431343

13441344
private function endClass(): string
@@ -1444,7 +1444,7 @@ private function dumpValue($value, bool $interpolate = true): string
14441444
$code[] = sprintf('%s => %s', $this->dumpValue($k, $interpolate), $this->dumpValue($v, $interpolate));
14451445
}
14461446

1447-
return sprintf('array(%s)', implode(', ', $code));
1447+
return sprintf('[%s]', implode(', ', $code));
14481448
} elseif ($value instanceof ArgumentInterface) {
14491449
$scope = [$this->definitionVariables, $this->referenceVariables];
14501450
$this->definitionVariables = $this->referenceVariables = null;
@@ -1502,7 +1502,7 @@ private function dumpValue($value, bool $interpolate = true): string
15021502
}
15031503
$definition = $this->container->findDefinition($id = (string) $v);
15041504
$load = !($definition->hasErrors() && $e = $definition->getErrors()) ? $this->asFiles && !$this->isHotPath($definition) : reset($e);
1505-
$serviceMap .= sprintf("\n %s => array(%s, %s, %s, %s),",
1505+
$serviceMap .= sprintf("\n %s => [%s, %s, %s, %s],",
15061506
$this->export($k),
15071507
$this->export($definition->isShared() ? ($definition->isPublic() ? 'services' : 'privates') : false),
15081508
$this->export($id),
@@ -1513,7 +1513,7 @@ private function dumpValue($value, bool $interpolate = true): string
15131513
}
15141514
$this->addGetService = true;
15151515

1516-
return sprintf('new \%s($this->getService, array(%s%s))', ServiceLocator::class, $serviceMap, $serviceMap ? "\n " : '');
1516+
return sprintf('new \%s($this->getService, [%s%s])', ServiceLocator::class, $serviceMap, $serviceMap ? "\n " : '');
15171517
}
15181518
} finally {
15191519
list($this->definitionVariables, $this->referenceVariables) = $scope;

Tests/Fixtures/php/services_default_env.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
class Symfony_DI_PhpDumper_Test_DefaultParameters extends Container
1818
{
1919
private $parameters;
20-
private $targetDirs = array();
20+
private $targetDirs = [];
2121

2222
public function __construct()
2323
{
2424
$this->parameters = $this->getDefaultParameters();
2525

26-
$this->services = $this->privates = array();
26+
$this->services = $this->privates = [];
2727

28-
$this->aliases = array();
28+
$this->aliases = [];
2929
}
3030

3131
public function compile()
@@ -40,10 +40,10 @@ public function isCompiled()
4040

4141
public function getRemovedIds()
4242
{
43-
return array(
43+
return [
4444
'Psr\\Container\\ContainerInterface' => true,
4545
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
46-
);
46+
];
4747
}
4848

4949
public function getParameter($name)
@@ -85,12 +85,12 @@ public function getParameterBag()
8585
return $this->parameterBag;
8686
}
8787

88-
private $loadedDynamicParameters = array(
88+
private $loadedDynamicParameters = [
8989
'fallback_env' => false,
9090
'hello' => false,
9191
'hello-bar' => false,
92-
);
93-
private $dynamicParameters = array();
92+
];
93+
private $dynamicParameters = [];
9494

9595
/**
9696
* Computes a dynamic parameter.
@@ -121,10 +121,10 @@ private function getDynamicParameter($name)
121121
*/
122122
protected function getDefaultParameters()
123123
{
124-
return array(
124+
return [
125125
'fallback_param' => 'baz',
126126
'env(foobar)' => 'foobaz',
127127
'env(foo)' => '{"foo": "bar"}',
128-
);
128+
];
129129
}
130130
}

0 commit comments

Comments
 (0)