Skip to content

Commit 7aa47f7

Browse files
committed
fixed CS
1 parent 2a898a2 commit 7aa47f7

File tree

4 files changed

+49
-48
lines changed

4 files changed

+49
-48
lines changed

ContainerBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ private function doGet($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_
616616
* the parameters passed to the container constructor to have precedence
617617
* over the loaded ones.
618618
*
619-
* $container = new ContainerBuilder(new ParameterBag(array('foo' => 'bar')));
619+
* $container = new ContainerBuilder(new ParameterBag(['foo' => 'bar']));
620620
* $loader = new LoaderXXX($container);
621621
* $loader->load('resource_name');
622622
* $container->register('foo', 'stdClass');
@@ -1243,7 +1243,7 @@ private function doResolveServices($value, array &$inlineServices = [], $isConst
12431243
*
12441244
* Example:
12451245
*
1246-
* $container->register('foo')->addTag('my.tag', array('hello' => 'world'));
1246+
* $container->register('foo')->addTag('my.tag', ['hello' => 'world']);
12471247
*
12481248
* $serviceIds = $container->findTaggedServiceIds('my.tag');
12491249
* foreach ($serviceIds as $serviceId => $tags) {

Dumper/PhpDumper.php

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ public function dump(array $options = [])
223223
}
224224
if ($ids = array_keys($ids)) {
225225
sort($ids);
226-
$c = "<?php\n\nreturn array(\n";
226+
$c = "<?php\n\nreturn [\n";
227227
foreach ($ids as $id) {
228228
$c .= ' '.$this->doExport($id)." => true,\n";
229229
}
230-
$files['removed-ids.php'] = $c .= ");\n";
230+
$files['removed-ids.php'] = $c .= "];\n";
231231
}
232232

233233
foreach ($this->generateServiceFiles() as $file => $c) {
@@ -266,11 +266,11 @@ public function dump(array $options = [])
266266
\\class_alias(\\Container{$hash}\\{$options['class']}::class, {$options['class']}::class, false);
267267
}
268268
269-
return new \\Container{$hash}\\{$options['class']}(array(
269+
return new \\Container{$hash}\\{$options['class']}([
270270
'container.build_hash' => '$hash',
271271
'container.build_id' => '$id',
272272
'container.build_time' => $time,
273-
), __DIR__.\\DIRECTORY_SEPARATOR.'Container{$hash}');
273+
], __DIR__.\\DIRECTORY_SEPARATOR.'Container{$hash}');
274274
275275
EOF;
276276
} else {
@@ -913,12 +913,12 @@ private function startClass(string $class, string $baseClass, string $baseClassW
913913
class $class extends $baseClass
914914
{
915915
private \$parameters;
916-
private \$targetDirs = array();
916+
private \$targetDirs = [];
917917
918918
/*{$this->docStar}
919919
* @internal but protected for BC on cache:clear
920920
*/
921-
protected \$privates = array();
921+
protected \$privates = [];
922922
923923
public function __construct()
924924
{
@@ -936,7 +936,7 @@ public function __construct()
936936
}
937937
if ($this->asFiles) {
938938
$code = str_replace('$parameters', "\$buildParameters;\n private \$containerDir;\n private \$parameters", $code);
939-
$code = str_replace('__construct()', '__construct(array $buildParameters = array(), $containerDir = __DIR__)', $code);
939+
$code = str_replace('__construct()', '__construct(array $buildParameters = [], $containerDir = __DIR__)', $code);
940940
$code .= " \$this->buildParameters = \$buildParameters;\n";
941941
$code .= " \$this->containerDir = \$containerDir;\n";
942942
}
@@ -956,7 +956,7 @@ public function __construct()
956956
if ($this->container->getParameterBag()->all()) {
957957
$code .= " \$this->parameters = \$this->getDefaultParameters();\n\n";
958958
}
959-
$code .= " \$this->services = \$this->privates = array();\n";
959+
$code .= " \$this->services = \$this->privates = [];\n";
960960

961961
$code .= $this->addSyntheticIds();
962962
$code .= $this->addMethodMap();
@@ -968,7 +968,7 @@ public function __construct()
968968
969969
public function reset()
970970
{
971-
\$this->privates = array();
971+
\$this->privates = [];
972972
parent::reset();
973973
}
974974
@@ -1036,7 +1036,7 @@ private function addSyntheticIds(): string
10361036
}
10371037
}
10381038

1039-
return $code ? " \$this->syntheticIds = array(\n{$code} );\n" : '';
1039+
return $code ? " \$this->syntheticIds = [\n{$code} ];\n" : '';
10401040
}
10411041

10421042
private function addRemovedIds(): string
@@ -1063,7 +1063,7 @@ private function addRemovedIds(): string
10631063
$code .= ' '.$this->doExport($id)." => true,\n";
10641064
}
10651065

1066-
$code = "array(\n{$code} )";
1066+
$code = "[\n{$code} ]";
10671067
}
10681068

10691069
return <<<EOF
@@ -1087,7 +1087,7 @@ private function addMethodMap(): string
10871087
}
10881088
}
10891089

1090-
return $code ? " \$this->methodMap = array(\n{$code} );\n" : '';
1090+
return $code ? " \$this->methodMap = [\n{$code} ];\n" : '';
10911091
}
10921092

10931093
private function addFileMap(): string
@@ -1101,16 +1101,16 @@ private function addFileMap(): string
11011101
}
11021102
}
11031103

1104-
return $code ? " \$this->fileMap = array(\n{$code} );\n" : '';
1104+
return $code ? " \$this->fileMap = [\n{$code} ];\n" : '';
11051105
}
11061106

11071107
private function addAliases(): string
11081108
{
11091109
if (!$aliases = $this->container->getAliases()) {
1110-
return "\n \$this->aliases = array();\n";
1110+
return "\n \$this->aliases = [];\n";
11111111
}
11121112

1113-
$code = " \$this->aliases = array(\n";
1113+
$code = " \$this->aliases = [\n";
11141114
ksort($aliases);
11151115
foreach ($aliases as $alias => $id) {
11161116
$id = (string) $id;
@@ -1120,7 +1120,7 @@ private function addAliases(): string
11201120
$code .= ' '.$this->doExport($alias).' => '.$this->doExport($id).",\n";
11211121
}
11221122

1123-
return $code." );\n";
1123+
return $code." ];\n";
11241124
}
11251125

11261126
private function addInlineRequires(): string
@@ -1168,15 +1168,16 @@ private function addDefaultParametersMethod(): string
11681168
throw new InvalidArgumentException(sprintf('Parameter name cannot use env parameters: %s.', $resolvedKey));
11691169
}
11701170
$export = $this->exportParameters([$value]);
1171-
$export = explode('0 => ', substr(rtrim($export, " )\n"), 7, -1), 2);
1171+
$export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2);
11721172

11731173
if (preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDirs\[\d++\])/", $export[1])) {
11741174
$dynamicPhp[$key] = sprintf('%scase %s: $value = %s; break;', $export[0], $this->export($key), $export[1]);
11751175
} else {
11761176
$php[] = sprintf('%s%s => %s,', $export[0], $this->export($key), $export[1]);
11771177
}
11781178
}
1179-
$parameters = sprintf("array(\n%s\n%s)", implode("\n", $php), str_repeat(' ', 8));
1179+
1180+
$parameters = sprintf("[\n%s\n%s]", implode("\n", $php), str_repeat(' ', 8));
11801181

11811182
$code = <<<'EOF'
11821183
@@ -1246,14 +1247,14 @@ public function getParameterBag()
12461247
EOF;
12471248
$getDynamicParameter = sprintf($getDynamicParameter, implode("\n", $dynamicPhp));
12481249
} else {
1249-
$loadedDynamicParameters = 'array()';
1250+
$loadedDynamicParameters = '[]';
12501251
$getDynamicParameter = str_repeat(' ', 8).'throw new InvalidArgumentException(sprintf(\'The dynamic parameter "%s" must be defined.\', $name));';
12511252
}
12521253

12531254
$code .= <<<EOF
12541255
12551256
private \$loadedDynamicParameters = {$loadedDynamicParameters};
1256-
private \$dynamicParameters = array();
1257+
private \$dynamicParameters = [];
12571258
12581259
/*{$this->docStar}
12591260
* Computes a dynamic parameter.
@@ -1310,7 +1311,7 @@ private function exportParameters(array $parameters, string $path = '', int $ind
13101311
$php[] = sprintf('%s%s => %s,', str_repeat(' ', $indent), $this->export($key), $value);
13111312
}
13121313

1313-
return sprintf("array(\n%s\n%s)", implode("\n", $php), str_repeat(' ', $indent - 4));
1314+
return sprintf("[\n%s\n%s]", implode("\n", $php), str_repeat(' ', $indent - 4));
13141315
}
13151316

13161317
private function endClass(): string
@@ -1404,7 +1405,7 @@ private function dumpValue($value, bool $interpolate = true): string
14041405
$code[] = sprintf('%s => %s', $this->dumpValue($k, $interpolate), $this->dumpValue($v, $interpolate));
14051406
}
14061407

1407-
return sprintf('array(%s)', implode(', ', $code));
1408+
return sprintf('[%s]', implode(', ', $code));
14081409
} elseif ($value instanceof ArgumentInterface) {
14091410
$scope = [$this->definitionVariables, $this->referenceVariables];
14101411
$this->definitionVariables = $this->referenceVariables = null;

Tests/Fixtures/includes/autowiring_classes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ interface DecoratorInterface
361361

362362
class Decorated implements DecoratorInterface
363363
{
364-
public function __construct($quz = null, \NonExistent $nonExistent = null, DecoratorInterface $decorated = null, array $foo = array())
364+
public function __construct($quz = null, \NonExistent $nonExistent = null, DecoratorInterface $decorated = null, array $foo = [])
365365
{
366366
}
367367
}

Tests/Fixtures/php/services9_as_files.txt

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Array
22
(
33
[Container%s/removed-ids.php] => <?php
44

5-
return array(
5+
return [
66
'Psr\\Container\\ContainerInterface' => true,
77
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
88
'configurator_service' => true,
@@ -14,7 +14,7 @@ return array(
1414
'inlined' => true,
1515
'new_factory' => true,
1616
'tagged_iterator_foo' => true,
17-
);
17+
];
1818

1919
[Container%s/getBAR2Service.php] => <?php
2020

@@ -179,11 +179,11 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
179179

180180
$a = ($this->services['foo.baz'] ?? $this->load('getFoo_BazService.php'));
181181

182-
$this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, array('bar' => 'foo is bar', 'foobar' => 'bar'), true, $this);
182+
$this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, ['bar' => 'foo is bar', 'foobar' => 'bar'], true, $this);
183183

184184
$instance->foo = 'bar';
185185
$instance->moo = $a;
186-
$instance->qux = array('bar' => 'foo is bar', 'foobar' => 'bar');
186+
$instance->qux = ['bar' => 'foo is bar', 'foobar' => 'bar'];
187187
$instance->setBar(($this->services['bar'] ?? $this->getBarService()));
188188
$instance->initialize();
189189
sc_configure($instance);
@@ -383,14 +383,14 @@ class ProjectServiceContainer extends Container
383383
private $buildParameters;
384384
private $containerDir;
385385
private $parameters;
386-
private $targetDirs = array();
386+
private $targetDirs = [];
387387

388388
/**
389389
* @internal but protected for BC on cache:clear
390390
*/
391-
protected $privates = array();
391+
protected $privates = [];
392392

393-
public function __construct(array $buildParameters = array(), $containerDir = __DIR__)
393+
public function __construct(array $buildParameters = [], $containerDir = __DIR__)
394394
{
395395
$dir = $this->targetDirs[0] = \dirname($containerDir);
396396
for ($i = 1; $i <= 5; ++$i) {
@@ -400,14 +400,14 @@ class ProjectServiceContainer extends Container
400400
$this->containerDir = $containerDir;
401401
$this->parameters = $this->getDefaultParameters();
402402

403-
$this->services = $this->privates = array();
404-
$this->syntheticIds = array(
403+
$this->services = $this->privates = [];
404+
$this->syntheticIds = [
405405
'request' => true,
406-
);
407-
$this->methodMap = array(
406+
];
407+
$this->methodMap = [
408408
'bar' => 'getBarService',
409-
);
410-
$this->fileMap = array(
409+
];
410+
$this->fileMap = [
411411
'BAR' => 'getBAR2Service.php',
412412
'BAR2' => 'getBAR22Service.php',
413413
'bar2' => 'getBar23Service.php',
@@ -431,17 +431,17 @@ class ProjectServiceContainer extends Container
431431
'runtime_error' => 'getRuntimeErrorService.php',
432432
'service_from_static_method' => 'getServiceFromStaticMethodService.php',
433433
'tagged_iterator' => 'getTaggedIteratorService.php',
434-
);
435-
$this->aliases = array(
434+
];
435+
$this->aliases = [
436436
'alias_for_alias' => 'foo',
437437
'alias_for_foo' => 'foo',
438438
'decorated' => 'decorator_service_with_name',
439-
);
439+
];
440440
}
441441

442442
public function reset()
443443
{
444-
$this->privates = array();
444+
$this->privates = [];
445445
parent::reset();
446446
}
447447

@@ -529,8 +529,8 @@ class ProjectServiceContainer extends Container
529529
return $this->parameterBag;
530530
}
531531

532-
private $loadedDynamicParameters = array();
533-
private $dynamicParameters = array();
532+
private $loadedDynamicParameters = [];
533+
private $dynamicParameters = [];
534534

535535
/**
536536
* Computes a dynamic parameter.
@@ -553,11 +553,11 @@ class ProjectServiceContainer extends Container
553553
*/
554554
protected function getDefaultParameters()
555555
{
556-
return array(
556+
return [
557557
'baz_class' => 'BazClass',
558558
'foo_class' => 'Bar\\FooClass',
559559
'foo' => 'bar',
560-
);
560+
];
561561
}
562562
}
563563

@@ -577,10 +577,10 @@ if (!\class_exists(ProjectServiceContainer::class, false)) {
577577
\class_alias(\Container%s\ProjectServiceContainer::class, ProjectServiceContainer::class, false);
578578
}
579579

580-
return new \Container%s\ProjectServiceContainer(array(
580+
return new \Container%s\ProjectServiceContainer([
581581
'container.build_hash' => '%s',
582582
'container.build_id' => '%s',
583583
'container.build_time' => %d,
584-
), __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
584+
], __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
585585

586586
)

0 commit comments

Comments
 (0)