Skip to content

Commit fc292f9

Browse files
committed
fixed CS on generated container files
1 parent ea1c2fd commit fc292f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+522
-521
lines changed

Dumper/PhpDumper.php

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,11 @@ public function dump(array $options = [])
215215

216216
if ($ids = array_keys($this->container->getRemovedIds())) {
217217
sort($ids);
218-
$c = "<?php\n\nreturn array(\n";
218+
$c = "<?php\n\nreturn [\n";
219219
foreach ($ids as $id) {
220220
$c .= ' '.$this->doExport($id)." => true,\n";
221221
}
222-
$files['removed-ids.php'] = $c .= ");\n";
222+
$files['removed-ids.php'] = $c .= "];\n";
223223
}
224224

225225
foreach ($this->generateServiceFiles() as $file => $c) {
@@ -258,11 +258,11 @@ public function dump(array $options = [])
258258
\\class_alias(\\Container{$hash}\\{$options['class']}::class, {$options['class']}::class, false);
259259
}
260260
261-
return new \\Container{$hash}\\{$options['class']}(array(
261+
return new \\Container{$hash}\\{$options['class']}([
262262
'container.build_hash' => '$hash',
263263
'container.build_id' => '$id',
264264
'container.build_time' => $time,
265-
), __DIR__.\\DIRECTORY_SEPARATOR.'Container{$hash}');
265+
], __DIR__.\\DIRECTORY_SEPARATOR.'Container{$hash}');
266266
267267
EOF;
268268
} else {
@@ -607,7 +607,7 @@ private function addServiceConfigurator(Definition $definition, $variableName =
607607
return sprintf(" (%s)->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
608608
}
609609

610-
return sprintf(" \\call_user_func(array(%s, '%s'), \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
610+
return sprintf(" \\call_user_func([%s, '%s'], \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
611611
}
612612

613613
return sprintf(" %s(\$%s);\n", $callable, $variableName);
@@ -900,7 +900,7 @@ private function addNewInstance(Definition $definition, $return, $instantiation,
900900
return $return.sprintf("(%s)->%s(%s);\n", $class, $callable[1], $arguments ? implode(', ', $arguments) : '');
901901
}
902902

903-
return $return.sprintf("\\call_user_func(array(%s, '%s')%s);\n", $class, $callable[1], $arguments ? ', '.implode(', ', $arguments) : '');
903+
return $return.sprintf("\\call_user_func([%s, '%s']%s);\n", $class, $callable[1], $arguments ? ', '.implode(', ', $arguments) : '');
904904
}
905905

906906
return $return.sprintf("%s(%s);\n", $this->dumpLiteralClass($this->dumpValue($callable)), $arguments ? implode(', ', $arguments) : '');
@@ -947,7 +947,7 @@ private function startClass($class, $baseClass, $baseClassWithNamespace)
947947
class $class extends $baseClass
948948
{
949949
private \$parameters;
950-
private \$targetDirs = array();
950+
private \$targetDirs = [];
951951
952952
public function __construct()
953953
{
@@ -965,7 +965,7 @@ public function __construct()
965965
}
966966
if ($this->asFiles) {
967967
$code = str_replace('$parameters', "\$buildParameters;\n private \$containerDir;\n private \$parameters", $code);
968-
$code = str_replace('__construct()', '__construct(array $buildParameters = array(), $containerDir = __DIR__)', $code);
968+
$code = str_replace('__construct()', '__construct(array $buildParameters = [], $containerDir = __DIR__)', $code);
969969
$code .= " \$this->buildParameters = \$buildParameters;\n";
970970
$code .= " \$this->containerDir = \$containerDir;\n";
971971
}
@@ -987,7 +987,7 @@ public function __construct()
987987
$code .= " \$this->parameters = \$this->getDefaultParameters();\n\n";
988988
}
989989

990-
$code .= " \$this->services = array();\n";
990+
$code .= " \$this->services = [];\n";
991991
} else {
992992
$arguments = $this->container->getParameterBag()->all() ? 'new ParameterBag($this->getDefaultParameters())' : null;
993993
$code .= " parent::__construct($arguments);\n";
@@ -1085,7 +1085,7 @@ private function addNormalizedIds()
10851085
}
10861086
}
10871087

1088-
return $code ? " \$this->normalizedIds = array(\n".$code." );\n" : '';
1088+
return $code ? " \$this->normalizedIds = [\n".$code." ];\n" : '';
10891089
}
10901090

10911091
/**
@@ -1104,7 +1104,7 @@ private function addSyntheticIds()
11041104
}
11051105
}
11061106

1107-
return $code ? " \$this->syntheticIds = array(\n{$code} );\n" : '';
1107+
return $code ? " \$this->syntheticIds = [\n{$code} ];\n" : '';
11081108
}
11091109

11101110
/**
@@ -1130,7 +1130,7 @@ private function addRemovedIds()
11301130
$code .= ' '.$this->doExport($id)." => true,\n";
11311131
}
11321132

1133-
$code = "array(\n{$code} )";
1133+
$code = "[\n{$code} ]";
11341134
}
11351135

11361136
return <<<EOF
@@ -1159,7 +1159,7 @@ private function addMethodMap()
11591159
}
11601160
}
11611161

1162-
return $code ? " \$this->methodMap = array(\n{$code} );\n" : '';
1162+
return $code ? " \$this->methodMap = [\n{$code} ];\n" : '';
11631163
}
11641164

11651165
/**
@@ -1178,7 +1178,7 @@ private function addFileMap()
11781178
}
11791179
}
11801180

1181-
return $code ? " \$this->fileMap = array(\n{$code} );\n" : '';
1181+
return $code ? " \$this->fileMap = [\n{$code} ];\n" : '';
11821182
}
11831183

11841184
/**
@@ -1210,9 +1210,9 @@ private function addPrivateServices()
12101210
return '';
12111211
}
12121212

1213-
$out = " \$this->privates = array(\n";
1213+
$out = " \$this->privates = [\n";
12141214
$out .= $code;
1215-
$out .= " );\n";
1215+
$out .= " ];\n";
12161216

12171217
return $out;
12181218
}
@@ -1225,10 +1225,10 @@ private function addPrivateServices()
12251225
private function addAliases()
12261226
{
12271227
if (!$aliases = $this->container->getAliases()) {
1228-
return $this->container->isCompiled() ? "\n \$this->aliases = array();\n" : '';
1228+
return $this->container->isCompiled() ? "\n \$this->aliases = [];\n" : '';
12291229
}
12301230

1231-
$code = " \$this->aliases = array(\n";
1231+
$code = " \$this->aliases = [\n";
12321232
ksort($aliases);
12331233
foreach ($aliases as $alias => $id) {
12341234
$id = $this->container->normalizeId($id);
@@ -1238,7 +1238,7 @@ private function addAliases()
12381238
$code .= ' '.$this->doExport($alias).' => '.$this->doExport($id).",\n";
12391239
}
12401240

1241-
return $code." );\n";
1241+
return $code." ];\n";
12421242
}
12431243

12441244
private function addInlineRequires()
@@ -1295,15 +1295,16 @@ private function addDefaultParametersMethod()
12951295
$normalizedParams[] = sprintf(' %s => %s,', $this->export($lcKey), $this->export($key));
12961296
}
12971297
$export = $this->exportParameters([$value]);
1298-
$export = explode('0 => ', substr(rtrim($export, " )\n"), 7, -1), 2);
1298+
$export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2);
12991299

13001300
if (preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDirs\[\d++\])/", $export[1])) {
13011301
$dynamicPhp[$key] = sprintf('%scase %s: $value = %s; break;', $export[0], $this->export($key), $export[1]);
13021302
} else {
13031303
$php[] = sprintf('%s%s => %s,', $export[0], $this->export($key), $export[1]);
13041304
}
13051305
}
1306-
$parameters = sprintf("array(\n%s\n%s)", implode("\n", $php), str_repeat(' ', 8));
1306+
1307+
$parameters = sprintf("[\n%s\n%s]", implode("\n", $php), str_repeat(' ', 8));
13071308

13081309
$code = '';
13091310
if ($this->container->isCompiled()) {
@@ -1379,14 +1380,14 @@ public function getParameterBag()
13791380
EOF;
13801381
$getDynamicParameter = sprintf($getDynamicParameter, implode("\n", $dynamicPhp));
13811382
} else {
1382-
$loadedDynamicParameters = 'array()';
1383+
$loadedDynamicParameters = '[]';
13831384
$getDynamicParameter = str_repeat(' ', 8).'throw new InvalidArgumentException(sprintf(\'The dynamic parameter "%s" must be defined.\', $name));';
13841385
}
13851386

13861387
$code .= <<<EOF
13871388
13881389
private \$loadedDynamicParameters = {$loadedDynamicParameters};
1389-
private \$dynamicParameters = array();
1390+
private \$dynamicParameters = [];
13901391
13911392
/*{$this->docStar}
13921393
* Computes a dynamic parameter.
@@ -1405,7 +1406,7 @@ private function getDynamicParameter(\$name)
14051406
14061407
EOF;
14071408

1408-
$code .= ' private $normalizedParameterNames = '.($normalizedParams ? sprintf("array(\n%s\n );", implode("\n", $normalizedParams)) : 'array();')."\n";
1409+
$code .= ' private $normalizedParameterNames = '.($normalizedParams ? sprintf("[\n%s\n ];", implode("\n", $normalizedParams)) : '[];')."\n";
14091410
$code .= <<<'EOF'
14101411
14111412
private function normalizeParameterName($name)
@@ -1478,7 +1479,7 @@ private function exportParameters(array $parameters, $path = '', $indent = 12)
14781479
$php[] = sprintf('%s%s => %s,', str_repeat(' ', $indent), $this->export($key), $value);
14791480
}
14801481

1481-
return sprintf("array(\n%s\n%s)", implode("\n", $php), str_repeat(' ', $indent - 4));
1482+
return sprintf("[\n%s\n%s]", implode("\n", $php), str_repeat(' ', $indent - 4));
14821483
}
14831484

14841485
/**
@@ -1599,7 +1600,7 @@ private function dumpValue($value, $interpolate = true)
15991600
$code[] = sprintf('%s => %s', $this->dumpValue($k, $interpolate), $this->dumpValue($v, $interpolate));
16001601
}
16011602

1602-
return sprintf('array(%s)', implode(', ', $code));
1603+
return sprintf('[%s]', implode(', ', $code));
16031604
} elseif ($value instanceof ArgumentInterface) {
16041605
$scope = [$this->definitionVariables, $this->referenceVariables];
16051606
$this->definitionVariables = $this->referenceVariables = null;
@@ -1691,7 +1692,7 @@ private function dumpValue($value, $interpolate = true)
16911692
return sprintf('(%s)->%s(%s)', $class, $factory[1], implode(', ', $arguments));
16921693
}
16931694

1694-
return sprintf("\\call_user_func(array(%s, '%s')%s)", $class, $factory[1], \count($arguments) > 0 ? ', '.implode(', ', $arguments) : '');
1695+
return sprintf("\\call_user_func([%s, '%s']%s)", $class, $factory[1], \count($arguments) > 0 ? ', '.implode(', ', $arguments) : '');
16951696
}
16961697

16971698
if ($factory[0] instanceof Reference) {

Tests/Fixtures/Bar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class Bar implements BarInterface
1515
{
16-
public function __construct($quz = null, \NonExistent $nonExistent = null, BarInterface $decorated = null, array $foo = array())
16+
public function __construct($quz = null, \NonExistent $nonExistent = null, BarInterface $decorated = null, array $foo = [])
1717
{
1818
}
1919

Tests/Fixtures/TestServiceSubscriber.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ public function __construct($container)
1212

1313
public static function getSubscribedServices()
1414
{
15-
return array(
15+
return [
1616
__CLASS__,
1717
'?'.CustomDefinition::class,
1818
'bar' => CustomDefinition::class,
1919
'baz' => '?'.CustomDefinition::class,
20-
);
20+
];
2121
}
2222
}

Tests/Fixtures/config/basic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
return function (ContainerConfigurator $c) {
88
$s = $c->services();
99
$s->set(BarService::class)
10-
->args(array(inline('FooClass')));
10+
->args([inline('FooClass')]);
1111
};

Tests/Fixtures/config/child.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
->set('foo')
1414
->parent(BarService::class)
1515
->decorate('bar', 'b', 1)
16-
->args(array(ref('b')))
16+
->args([ref('b')])
1717
->class('Class2')
1818
->file('file.php')
1919
->parent('bar')

Tests/Fixtures/config/defaults.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
->private()
1313
->autoconfigure()
1414
->autowire()
15-
->tag('t', array('a' => 'b'))
15+
->tag('t', ['a' => 'b'])
1616
->bind(Foo::class, ref('bar'))
1717
->private();
1818

19-
$s->set(Foo::class)->args(array(ref('bar')))->public();
19+
$s->set(Foo::class)->args([ref('bar')])->public();
2020
$s->set('bar', Foo::class)->call('setFoo')->autoconfigure(false);
2121
};

Tests/Fixtures/config/instanceof.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
$s = $c->services();
1010
$s->instanceof(Prototype\Foo::class)
1111
->property('p', 0)
12-
->call('setFoo', array(ref('foo')))
13-
->tag('tag', array('k' => 'v'))
12+
->call('setFoo', [ref('foo')])
13+
->tag('tag', ['k' => 'v'])
1414
->share(false)
1515
->lazy()
1616
->configurator('c')

Tests/Fixtures/config/prototype.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
->exclude('../Prototype/{OtherDir,BadClasses}')
1313
->factory('f')
1414
->deprecate('%service_id%')
15-
->args(array(0))
16-
->args(array(1))
15+
->args([0])
16+
->args([1])
1717
->autoconfigure(false)
1818
->tag('foo')
1919
->parent('foo');

0 commit comments

Comments
 (0)