@@ -224,7 +224,7 @@ public function dump(array $options = [])
224
224
if ($ this ->addGetService ) {
225
225
$ code = preg_replace (
226
226
"/( \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" ,
228
228
$ code ,
229
229
1
230
230
);
@@ -250,11 +250,11 @@ public function dump(array $options = [])
250
250
}
251
251
if ($ ids = array_keys ($ ids )) {
252
252
sort ($ ids );
253
- $ c = "<?php \n\nreturn array( \n" ;
253
+ $ c = "<?php \n\nreturn [ \n" ;
254
254
foreach ($ ids as $ id ) {
255
255
$ c .= ' ' .$ this ->doExport ($ id )." => true, \n" ;
256
256
}
257
- $ files ['removed-ids.php ' ] = $ c .= ") ; \n" ;
257
+ $ files ['removed-ids.php ' ] = $ c .= "] ; \n" ;
258
258
}
259
259
260
260
foreach ($ this ->generateServiceFiles ($ services ) as $ file => $ c ) {
@@ -293,11 +293,11 @@ public function dump(array $options = [])
293
293
\\class_alias(\\Container {$ hash }\\ {$ options ['class ' ]}::class, {$ options ['class ' ]}::class, false);
294
294
}
295
295
296
- return new \\Container {$ hash }\\ {$ options ['class ' ]}(array(
296
+ return new \\Container {$ hash }\\ {$ options ['class ' ]}([
297
297
'container.build_hash' => ' $ hash',
298
298
'container.build_id' => ' $ id',
299
299
'container.build_time' => $ time,
300
- ) , __DIR__.\\DIRECTORY_SEPARATOR.'Container {$ hash }');
300
+ ] , __DIR__.\\DIRECTORY_SEPARATOR.'Container {$ hash }');
301
301
<
10000
/code>
302
302
EOF ;
303
303
} else {
@@ -952,7 +952,7 @@ private function startClass(string $class, string $baseClass, string $baseClassW
952
952
class $ class extends $ baseClass
953
953
{
954
954
private \$parameters;
955
- private \$targetDirs = array() ;
955
+ private \$targetDirs = [] ;
956
956
957
957
public function __construct()
958
958
{
@@ -970,7 +970,7 @@ public function __construct()
970
970
}
971
971
if ($ this ->asFiles ) {
972
972
$ 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 );
974
974
$ code .= " \$this->buildParameters = \$buildParameters; \n" ;
975
975
$ code .= " \$this->containerDir = \$containerDir; \n" ;
976
976
}
@@ -990,7 +990,7 @@ public function __construct()
990
990
if ($ this ->container ->getParameterBag ()->all ()) {
991
991
$ code .= " \$this->parameters = \$this->getDefaultParameters(); \n\n" ;
992
992
}
993
- $ code .= " \$this->services = \$this->privates = array() ; \n" ;
993
+ $ code .= " \$this->services = \$this->privates = [] ; \n" ;
994
994
995
995
$ code .= $ this ->addSyntheticIds ();
996
996
$ code .= $ this ->addMethodMap ();
@@ -1064,7 +1064,7 @@ private function addSyntheticIds(): string
1064
1064
}
1065
1065
}
1066
1066
1067
- return $ code ? " \$this->syntheticIds = array( \n{$ code } ) ; \n" : '' ;
1067
+ return $ code ? " \$this->syntheticIds = [ \n{$ code } ] ; \n" : '' ;
1068
1068
}
1069
1069
1070
1070
private function addRemovedIds (): string
@@ -1091,7 +1091,7 @@ private function addRemovedIds(): string
1091
1091
$ code .= ' ' .$ this ->doExport ($ id )." => true, \n" ;
1092
1092
}
1093
1093
1094
- $ code = "array( \n{$ code } ) " ;
1094
+ $ code = "[ \n{$ code } ] " ;
1095
1095
}
1096
1096
1097
1097
return <<<EOF
@@ -1115,7 +1115,7 @@ private function addMethodMap(): string
1115
1115
}
1116
1116
}
1117
1117
1118
- return $ code ? " \$this->methodMap = array( \n{$ code } ) ; \n" : '' ;
1118
+ return $ code ? " \$this->methodMap = [ \n{$ code } ] ; \n" : '' ;
1119
1119
}
1120
1120
1121
1121
private function addFileMap (): string
@@ -1129,16 +1129,16 @@ private function addFileMap(): string
1129
1129
}
1130
1130
}
1131
1131
1132
- return $ code ? " \$this->fileMap = array( \n{$ code } ) ; \n" : '' ;
1132
+ return $ code ? " \$this->fileMap = [ \n{$ code } ] ; \n" : '' ;
1133
1133
}
1134
1134
1135
1135
private function addAliases (): string
1136
1136
{
1137
1137
if (!$ aliases = $ this ->container ->getAliases ()) {
1138
- return "\n \$this->aliases = array() ; \n" ;
1138
+ return "\n \$this->aliases = [] ; \n" ;
1139
1139
}
1140
1140
1141
- $ code = " \$this->aliases = array( \n" ;
1141
+ $ code = " \$this->aliases = [ \n" ;
1142
1142
ksort ($ aliases );
1143
1143
foreach ($ aliases as $ alias => $ id ) {
1144
1144
$ id = (string ) $ id ;
@@ -1148,7 +1148,7 @@ private function addAliases(): string
1148
1148
$ code .= ' ' .$ this ->doExport ($ alias ).' => ' .$ this ->doExport ($ id ).", \n" ;
1149
1149
}
1150
1150
1151
- return $ code ." ) ; \n" ;
1151
+ return $ code ." ] ; \n" ;
1152
1152
}
1153
1153
1154
1154
private function addInlineRequires (): string
@@ -1196,15 +1196,15 @@ private function addDefaultParametersMethod(): string
1196
1196
throw new InvalidArgumentException (sprintf ('Parameter name cannot use env parameters: %s. ' , $ resolvedKey ));
1197
1197
}
1198
1198
$ 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 );
1200
1200
1201
1201
if (preg_match ("/ \\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDirs\[\d++\])/ " , $ export [1 ])) {
1202
1202
$ dynamicPhp [$ key ] = sprintf ('%scase %s: $value = %s; break; ' , $ export [0 ], $ this ->export ($ key ), $ export [1 ]);
1203
1203
} else {
1204
1204
$ php [] = sprintf ('%s%s => %s, ' , $ export [0 ], $ this ->export ($ key ), $ export [1 ]);
1205
1205
}
1206
1206
}
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 ));
1208
1208
1209
1209
$ code = <<<'EOF'
1210
1210
@@ -1274,14 +1274,14 @@ public function getParameterBag()
1274
1274
EOF;
1275
1275
$ getDynamicParameter = sprintf ($ getDynamicParameter , implode ("\n" , $ dynamicPhp ));
1276
1276
} else {
1277
- $ loadedDynamicParameters = 'array() ' ;
1277
+ $ loadedDynamicParameters = '[] ' ;
1278
1278
$ getDynamicParameter = str_repeat (' ' , 8 ).'throw new InvalidArgumentException(sprintf( \'The dynamic parameter "%s" must be defined. \', $name)); ' ;
1279
1279
}
1280
1280
1281
1281
$ code .= <<<EOF
1282
1282
1283
1283
private \$loadedDynamicParameters = {$ loadedDynamicParameters };
1284
- private \$dynamicParameters = array() ;
1284
+ private \$dynamicParameters = [] ;
1285
1285
1286
1286
/* {$ this ->docStar }
1287
1287
* Computes a dynamic parameter.
@@ -1338,7 +1338,7 @@ private function exportParameters(array $parameters, string $path = '', int $ind
1338
1338
$ php [] = sprintf ('%s%s => %s, ' , str_repeat (' ' , $ indent ), $ this ->export ($ key ), $ value );
1339
1339
}
1340
1340
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 ));
1342
1342
}
1343
1343
1344
1344
private function endClass (): string
@@ -1444,7 +1444,7 @@ private function dumpValue($value, bool $interpolate = true): string
1444
1444
$ code [] = sprintf ('%s => %s ' , $ this ->dumpValue ($ k , $ interpolate ), $ this ->dumpValue ($ v , $ interpolate ));
1445
1445
}
1446
1446
1447
- return sprintf ('array(%s) ' , implode (', ' , $ code ));
1447
+ return sprintf ('[%s] ' , implode (', ' , $ code ));
1448
1448
} elseif ($ value instanceof ArgumentInterface) {
1449
1449
$ scope = [$ this ->definitionVariables , $ this ->referenceVariables ];
1450
1450
$ this ->definitionVariables = $ this ->referenceVariables = null ;
@@ -1502,7 +1502,7 @@ private function dumpValue($value, bool $interpolate = true): string
1502
1502
}
1503
1503
$ definition = $ this ->container ->findDefinition ($ id = (string ) $ v );
1504
1504
$ 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] , " ,
1506
1506
$ this ->export ($ k ),
1507
1507
$ this ->export ($ definition ->isShared () ? ($ definition ->isPublic () ? 'services ' : 'privates ' ) : false ),
1508
1508
$ this ->export ($ id ),
@@ -1513,7 +1513,7 @@ private function dumpValue($value, bool $interpolate = true): string
1513
1513
}
1514
1514
$ this ->addGetService = true ;
1515
1515
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 " : '' );
1517
1517
}
1518
1518
} finally {
1519
1519
list ($ this ->definitionVariables , $ this ->referenceVariables ) = $ scope ;
0 commit comments