@@ -215,11 +215,11 @@ public function dump(array $options = [])
215
215
216
216
if ($ ids = array_keys ($ this ->container ->getRemovedIds ())) {
217
217
sort ($ ids );
218
- $ c = "<?php \n\nreturn array( \n" ;
218
+ $ c = "<?php \n\nreturn [ \n" ;
219
219
foreach ($ ids as $ id ) {
220
220
$ c .= ' ' .$ this ->doExport ($ id )." => true, \n" ;
221
221
}
222
- $ files ['removed-ids.php ' ] = $ c .= ") ; \n" ;
222
+ $ files ['removed-ids.php ' ] = $ c .= "] ; \n" ;
223
223
}
224
224
225
225
foreach ($ this ->generateServiceFiles () as $ file => $ c ) {
@@ -258,11 +258,11 @@ public function dump(array $options = [])
258
258
\\class_alias(\\Container {$ hash }\\ {$ options ['class ' ]}::class, {$ options ['class ' ]}::class, false);
259
259
}
260
260
261
- return new \\Container {$ hash }\\ {$ options ['class ' ]}(array(
261
+ return new \\Container {$ hash }\\ {$ options ['class ' ]}([
262
262
'container.build_hash' => ' $ hash',
263
263
'container.build_id' => ' $ id',
264
264
'container.build_time' => $ time,
265
- ) , __DIR__.\\DIRECTORY_SEPARATOR.'Container {$ hash }');
265
+ ] , __DIR__.\\DIRECTORY_SEPARATOR.'Container {$ hash }');
266
266
267
267
EOF ;
268
268
} else {
@@ -607,7 +607,7 @@ private function addServiceConfigurator(Definition $definition, $variableName =
607
607
return sprintf (" (%s)->%s( \$%s); \n" , $ this ->dumpValue ($ callable [0 ]), $ callable [1 ], $ variableName );
608
608
}
609
609
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 );
611
611
}
612
612
613
613
return sprintf (" %s( \$%s); \n" , $ callable , $ variableName );
@@ -900,7 +900,7 @@ private function addNewInstance(Definition $definition, $return, $instantiation,
900
900
return $ return .sprintf ("(%s)->%s(%s); \n" , $ class , $ callable [1 ], $ arguments ? implode (', ' , $ arguments ) : '' );
901
901
}
902
902
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 ) : '' );
904
904
}
905
905
906
906
return $ return .sprintf ("%s(%s); \n" , $ this ->dumpLiteralClass ($ this ->dumpValue ($ callable )), $ arguments ? implode (', ' , $ arguments ) : '' );
@@ -947,7 +947,7 @@ private function startClass($class, $baseClass, $baseClassWithNamespace)
947
947
class $ class extends $ baseClass
948
948
{
949
949
private \$parameters;
950
- private \$targetDirs = array() ;
950
+ private \$targetDirs = [] ;
951
951
952
952
public function __construct()
953
953
{
@@ -965,7 +965,7 @@ public function __construct()
965
965
}
966
966
if ($ this ->asFiles ) {
967
967
$ 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 );
969
969
$ code .= " \$this->buildParameters = \$buildParameters; \n" ;
970
970
$ code .= " \$this->containerDir = \$containerDir; \n" ;
971
971
}
@@ -987,7 +987,7 @@ public function __construct()
987
987
$ code .= " \$this->parameters = \$this->getDefaultParameters(); \n\n" ;
988
988
}
989
989
990
- $ code .= " \$this->services = array() ; \n" ;
990
+ $ code .= " \$this->services = [] ; \n" ;
991
991
} else {
992
992
$ arguments = $ this ->container ->getParameterBag ()->all () ? 'new ParameterBag($this->getDefaultParameters()) ' : null ;
993
993
$ code .= " parent::__construct( $ arguments); \n" ;
@@ -1085,7 +1085,7 @@ private function addNormalizedIds()
1085
1085
}
1086
1086
}
1087
1087
1088
- return $ code ? " \$this->normalizedIds = array( \n" .$ code ." ) ; \n" : '' ;
1088
+ return $ code ? " \$this->normalizedIds = [ \n" .$ code ." ] ; \n" : '' ;
1089
1089
}
1090
1090
1091
1091
/**
@@ -1104,7 +1104,7 @@ private function addSyntheticIds()
1104
1104
}
1105
1105
}
1106
1106
1107
- return $ code ? " \$this->syntheticIds = array( \n{$ code } ) ; \n" : '' ;
1107
+ return $ code ? " \$this->syntheticIds = [ \n{$ code } ] ; \n" : '' ;
1108
1108
}
1109
1109
1110
1110
/**
@@ -1130,7 +1130,7 @@ private function addRemovedIds()
1130
1130
$ code .= ' ' .$ this ->doExport ($ id )." => true, \n" ;
1131
1131
}
1132
1132
1133
- $ code = "array( \n{$ code } ) " ;
1133
+ $ code = "[ \n{$ code } ] " ;
1134
1134
}
1135
1135
1136
1136
return <<<EOF
@@ -1159,7 +1159,7 @@ private function addMethodMap()
1159
1159
}
1160
1160
}
1161
1161
1162
- return $ code ? " \$this->methodMap = array( \n{$ code } ) ; \n" : '' ;
1162
+ return $ code ? " \$this->methodMap = [ \n{$ code } ] ; \n" : '' ;
1163
1163
}
1164
1164
1165
1165
/**
@@ -1178,7 +1178,7 @@ private function addFileMap()
1178
1178
}
1179
1179
}
1180
1180
1181
- return $ code ? " \$this->fileMap = array( \n{$ code } ) ; \n" : '' ;
1181
+ return $ code ? " \$this->fileMap = [ \n{$ code } ] ; \n" : '' ;
1182
1182
}
1183
1183
1184
1184
/**
@@ -1210,9 +1210,9 @@ private function addPrivateServices()
1210
1210
return '' ;
1211
1211
}
1212
1212
1213
- $ out = " \$this->privates = array( \n" ;
1213
+ $ out = " \$this->privates = [ \n" ;
1214
1214
$ out .= $ code ;
1215
- $ out .= " ) ; \n" ;
1215
+ $ out .= " ] ; \n" ;
1216
1216
1217
1217
return $ out ;
1218
1218
}
@@ -1225,10 +1225,10 @@ private function addPrivateServices()
1225
1225
private function addAliases ()
1226
1226
{
1227
1227
if (!$ aliases = $ this ->container ->getAliases ()) {
1228
- return $ this ->container ->isCompiled () ? "\n \$this->aliases = array() ; \n" : '' ;
1228
+ return $ this ->container ->isCompiled () ? "\n \$this->aliases = [] ; \n" : '' ;
1229
1229
}
1230
1230
1231
- $ code = " \$this->aliases = array( \n" ;
1231
+ $ code = " \$this->aliases = [ \n" ;
1232
1232
ksort ($ aliases );
1233
1233
foreach ($ aliases as $ alias => $ id ) {
1234
1234
$ id = $ this ->container ->normalizeId ($ id );
@@ -1238,7 +1238,7 @@ private function addAliases()
1238
1238
$ code .= ' ' .$ this ->doExport ($ alias ).' => ' .$ this ->doExport ($ id ).", \n" ;
1239
1239
}
1240
1240
1241
- return $ code ." ) ; \n" ;
1241
+ return $ code ." ] ; \n" ;
1242
1242
}
1243
1243
1244
1244
private function addInlineRequires ()
@@ -1295,15 +1295,16 @@ private function addDefaultParametersMethod()
1295
1295
$ normalizedParams [] = sprintf (' %s => %s, ' , $ this ->export ($ lcKey ), $ this ->export ($ key ));
1296
1296
}
1297
1297
$ 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 );
1299
1299
1300
1300
if (preg_match ("/ \\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDirs\[\d++\])/ " , $ export [1 ])) {
1301
1301
$ dynamicPhp [$ key ] = sprintf ('%scase %s: $value = %s; break; ' , $ export [0 ], $ this ->export ($ key ), $ export [1 ]);
1302
1302
} else {
1303
1303
$ php [] = sprintf ('%s%s => %s, ' , $ export [0 ], $ this ->export ($ key ), $ export [1 ]);
1304
1304
}
1305
1305
}
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 ));
1307
1308
1308
1309
$ code = '' ;
1309
1310
if ($ this ->container ->isCompiled ()) {
@@ -1379,14 +1380,14 @@ public function getParameterBag()
1379
1380
EOF;
1380
1381
$ getDynamicParameter = sprintf ($ getDynamicParameter , implode ("\n" , $ dynamicPhp ));
1381
1382
} else {
1382
- $ loadedDynamicParameters = 'array() ' ;
1383
+ $ loadedDynamicParameters = '[] ' ;
1383
1384
$ getDynamicParameter = str_repeat (' ' , 8 ).'throw new InvalidArgumentException(sprintf( \'The dynamic parameter "%s" must be defined. \', $name)); ' ;
1384
1385
}
1385
1386
1386
1387
$ code .= <<<EOF
1387
1388
1388
1389
private \$loadedDynamicParameters = {$ loadedDynamicParameters };
1389
- private \$dynamicParameters = array() ;
1390
+ private \$dynamicParameters = [] ;
1390
1391
1391
1392
/* {$ this ->docStar }
1392
1393
* Computes a dynamic parameter.
@@ -1405,7 +1406,7 @@ private function getDynamicParameter(\$name)
1405
1406
1406
1407
EOF ;
1407
1408
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" ;
1409
1410
$ code .= <<<'EOF'
1410
1411
1411
1412
private function normalizeParameterName($name)
@@ -1478,7 +1479,7 @@ private function exportParameters(array $parameters, $path = '', $indent = 12)
1478
1479
$ php [] = sprintf ('%s%s => %s, ' , str_repeat (' ' , $ indent ), $ this ->export ($ key ), $ value );
1479
1480
}
1480
1481
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 ));
1482
1483
}
1483
1484
1484
1485
/**
@@ -1599,7 +1600,7 @@ private function dumpValue($value, $interpolate = true)
1599
1600
$ code [] = sprintf ('%s => %s ' , $ this ->dumpValue ($ k , $ interpolate ), $ this ->dumpValue ($ v , $ interpolate ));
1600
1601
}
1601
1602
1602
- return sprintf ('array(%s) ' , implode (', ' , $ code ));
1603
+ return sprintf ('[%s] ' , implode (', ' , $ code ));
1603
1604
} elseif ($ value instanceof ArgumentInterface) {
1604
1605
$ scope = [$ this ->definitionVariables , $ this ->referenceVariables ];
1605
1606
$ this ->definitionVariables = $ this ->referenceVariables = null ;
@@ -1691,7 +1692,7 @@ private function dumpValue($value, $interpolate = true)
1691
1692
return sprintf ('(%s)->%s(%s) ' , $ class , $ factory [1 ], implode (', ' , $ arguments ));
1692
1693
}
1693
1694
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 ) : '' );
1695
1696
}
1696
1697
1697
1698
if ($ factory [0 ] instanceof Reference) {
0 commit comments