@@ -62,7 +62,7 @@ class PhpDumper extends Dumper
62
62
private $ variableCount ;
63
63
private $ inlinedDefinitions ;
64
64
private $ serviceCalls ;
65
- private $ reservedVariables = array ( 'instance ' , 'class ' , 'this ' ) ;
65
+ private $ reservedVariables = [ 'instance ' , 'class ' , 'this ' ] ;
66
66
private $ expressionLanguage ;
67
67
private $ targetDirRegex ;
68
68
private $ targetDirMaxMatches ;
@@ -73,14 +73,14 @@ class PhpDumper extends Dumper
73
73
private $ asFiles ;
74
74
private $ hotPathTag ;
75
75
private $ inlineRequires ;
76
- private $ inlinedRequires = array () ;
77
- private $ circularReferences = array () ;
78
- private $ singleUsePrivateIds = array () ;
76
+ private $ inlinedRequires = [] ;
77
+ private $ circularReferences = [] ;
78
+ private $ singleUsePrivateIds = [] ;
79
79
private $ addThrow = false ;
80
80
private $ addGetService = false ;
81
- private $ locatedIds = array () ;
81
+ private $ locatedIds = [] ;
82
82
private $ serviceLocatorTag ;
83
- private $ exportedVariables = array () ;
83
+ private $ exportedVariables = [] ;
84
84
85
85
/**
86
86
* @var ProxyDumper
@@ -121,13 +121,13 @@ public function setProxyDumper(ProxyDumper $proxyDumper)
121
121
*
122
122
* @throws EnvParameterException When an env var exists but has not been dumped
123
123
*/
124
- public function dump (array $ options = array () )
124
+ public function dump (array $ options = [] )
125
125
{
126
- $ this ->locatedIds = array () ;
126
+ $ this ->locatedIds = [] ;
127
127
$ this ->targetDirRegex = null ;
128
- $ this ->inlinedRequires = array () ;
129
- $ this ->exportedVariables = array () ;
130
- $ options = array_merge (array (
128
+ $ this ->inlinedRequires = [] ;
129
+ $ this ->exportedVariables = [] ;
130
+ $ options = array_merge ([
131
131
'class ' => 'ProjectServiceContainer ' ,
132
132
'base_class ' => 'Container ' ,
133
133
'namespace ' => '' ,
@@ -137,7 +137,7 @@ public function dump(array $options = array())
137
137
'inline_class_loader_parameter ' => 'container.dumper.inline_class_loader ' ,
138
138
'service_locator_tag ' => 'container.service_locator ' ,
139
139
'build_time ' => time (),
140
- ) , $ options );
140
+ ] , $ options );
141
141
142
142
$ this ->addThrow = $ this ->addGetService = false ;
143
143
$ this ->namespace = $ options ['namespace ' ];
@@ -171,9 +171,9 @@ public function dump(array $options = array())
171
171
}
172
172
173
173
(new AnalyzeServiceReferencesPass (false , !$ this ->getProxyDumper () instanceof NullDumper))->process ($ this ->container );
174
- $ checkedNodes = array () ;
175
- $ this ->circularReferences = array () ;
176
- $ this ->singleUsePrivateIds = array () ;
174
+ $ checkedNodes = [] ;
175
+ $ this ->circularReferences = [] ;
176
+ $ this ->singleUsePrivateIds = [] ;
177
177
foreach ($ this ->container ->getCompiler ()->getServiceReferenceGraph ()->getNodes () as $ id => $ node ) {
178
178
if (!$ node ->getValue () instanceof Definition) {
179
179
continue ;
@@ -186,7 +186,7 @@ public function dump(array $options = array())
186
186
}
187
187
}
188
188
$ this ->container ->getCompiler ()->getServiceReferenceGraph ()->clear ();
189
- $ checkedNodes = array () ;
189
+ $ checkedNodes = [] ;
190
190
191
191
$ this ->docStar = $ options ['debug ' ] ? '* ' : '' ;
192
192
@@ -240,7 +240,7 @@ public function dump(array $options = array())
240
240
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
241
241
242
242
EOF ;
243
- $ files = array () ;
243
+ $ files = [] ;
244
244
245
245
$ ids = $ this ->container ->getRemovedIds ();
246
246
foreach ($ this ->container ->getDefinitions () as $ id => $ definition ) {
@@ -265,7 +265,7 @@ public function dump(array $options = array())
265
265
}
266
266
$ files [$ options ['class ' ].'.php ' ] = $ code .$ this ->endClass ();
267
267
$ hash = ucfirst (strtr (ContainerBuilder::hash ($ files ), '._ ' , 'xx ' ));
268
- $ code = array () ;
268
+ $ code = [] ;
269
269
270
270
foreach ($ files as $ file => $ c ) {
271
271
$ code ["Container {$ hash }/ {$ file }" ] = $ c ;
@@ -308,12 +308,12 @@ public function dump(array $options = array())
308
308
}
309
309
310
310
$ this ->targetDirRegex = null ;
311
- $ this ->inlinedRequires = array () ;
312
- $ this ->circularReferences = array () ;
313
- $ this ->locatedIds = array () ;
314
- $ this ->exportedVariables = array () ;
311
+ $ this ->inlinedRequires = [] ;
312
+ $ this ->circularReferences = [] ;
313
+ $ this ->locatedIds = [] ;
314
+ $ this ->exportedVariables = [] ;
315
315
316
- $ unusedEnvs = array () ;
316
+ $ unusedEnvs = [] ;
317
317
foreach ($ this ->container ->getEnvCounters () as $ env => $ use ) {
318
318
if (!$ use ) {
319
319
$ unusedEnvs [] = $ env ;
@@ -338,7 +338,7 @@ private function getProxyDumper(): ProxyDumper
338
338
return $ this ->proxyDumper ;
339
339
}
340
340
341
- private function analyzeCircularReferences ($ sourceId , array $ edges , &$ checkedNodes , &$ currentPath = array () )
341
+ private function analyzeCircularReferences ($ sourceId , array $ edges , &$ checkedNodes , &$ currentPath = [] )
342
342
{
343
343
$ checkedNodes [$ sourceId ] = true ;
344
344
$ currentPath [$ sourceId ] = $ sourceId ;
@@ -367,7 +367,7 @@ private function analyzeCircularReferences($sourceId, array $edges, &$checkedNod
367
367
unset($ currentPath [$ sourceId ]);
368
368
}
369
369
370
- private function connectCircularReferences ($ sourceId , &$ currentPath , &$ subPath = array () )
370
+ private function connectCircularReferences ($ sourceId , &$ currentPath , &$ subPath = [] )
371
371
{
372
372
$ subPath [$ sourceId ] = $ sourceId ;
373
373
$ currentPath [$ sourceId ] = $ sourceId ;
@@ -423,7 +423,7 @@ private function collectLineage($class, array &$lineage)
423
423
424
424
private function generateProxyClasses ()
425
425
{
426
- $ alreadyGenerated = array () ;
426
+ $ alreadyGenerated = [] ;
427
427
$ definitions = $ this ->container ->getDefinitions ();
428
428
$ strip = '' === $ this ->docStar && method_exists ('Symfony\Component\HttpKernel\Kernel ' , 'stripComments ' );
429
429
$ proxyDumper = $ this ->getProxyDumper ();
@@ -454,7 +454,7 @@ private function addServiceInclude(string $cId, Definition $definition): string
454
454
$ code = '' ;
455
455
456
456
if ($ this ->inlineRequires && !$ this ->isHotPath ($ definition )) {
457
- $ lineage = array () ;
457
+ $ lineage = [] ;
458
458
foreach ($ this ->inlinedDefinitions as $ def ) {
459
459
if (!$ def ->isDeprecated () && \is_string ($ class = \is_array ($ factory = $ def ->getFactory ()) && \is_string ($ factory [0 ]) ? $ factory [0 ] : $ def ->getClass ())) {
460
460
$ this ->collectLineage ($ class , $ lineage );
@@ -566,7 +566,7 @@ private function addServiceMethodCalls(Definition $definition, string $variableN
566
566
{
567
567
$ calls = '' ;
568
568
foreach ($ definition ->getMethodCalls () as $ call ) {
569
- $ arguments = array () ;
569
+ $ arguments = [] ;
570
570
foreach ($ call [1 ] as $ value ) {
571
571
$ arguments [] = $ this ->dumpValue ($ value );
572
572
}
@@ -619,11 +619,11 @@ private function addServiceConfigurator(Definition $definition, string $variable
619
619
private function addService (string $ id , Definition $ definition ): array
620
620
{
621
621
$ this ->definitionVariables = new \SplObjectStorage ();
622
- $ this ->referenceVariables = array () ;
622
+ $ this ->referenceVariables = [] ;
623
623
$ this ->variableCount = 0 ;
624
624
$ this ->referenceVariables [$ id ] = new Variable ('instance ' );
625
625
626
- $ return = array () ;
626
+ $ return = [] ;
627
627
628
628
if ($ class = $ definition ->getClass ()) {
629
629
$ class = $ class instanceof Parameter ? '% ' .$ class .'% ' : $ this ->container ->resolveEnvPlaceholders ($ class );
@@ -680,8 +680,8 @@ protected function {$methodName}($lazyInitialization)
680
680
EOF ;
681
681
}
682
682
683
- $ this ->serviceCalls = array () ;
684
- $ this ->inlinedDefinitions = $ this ->getDefinitionsFromArguments (array ( $ definition) , null , $ this ->serviceCalls );
683
+ $ this ->serviceCalls = [] ;
684
+ $ this ->inlinedDefinitions = $ this ->getDefinitionsFromArguments ([ $ definition] , null , $ this ->serviceCalls );
685
685
686
686
$ code .= $ this ->addServiceInclude ($ id , $ definition );
687
687
@@ -705,7 +705,7 @@ protected function {$methodName}($lazyInitialization)
705
705
$ this ->definitionVariables = $ this ->inlinedDefinitions = null ;
706
706
$ this ->referenceVariables = $ this ->serviceCalls = null ;
707
707
708
- return array ( $ file , $ code) ;
708
+ return [ $ file , $ code] ;
709
709
}
710
710
711
711
private function addInlineVariables (string $ id , Definition $ definition , array $ arguments , bool $ forConstructor ): string
@@ -782,11 +782,11 @@ private function addInlineService(string $id, Definition $definition, Definition
782
782
return '' ;
783
783
}
784
784
785
- $ arguments = array ( $ inlineDef ->getArguments (), $ inlineDef ->getFactory ()) ;
785
+ $ arguments = [ $ inlineDef ->getArguments (), $ inlineDef ->getFactory ()] ;
786
786
787
787
$ code = $ this ->addInlineVariables ($ id , $ definition , $ arguments , $ forConstructor );
788
788
789
- if ($ arguments = array_filter (array ( $ inlineDef ->getProperties (), $ inlineDef ->getMethodCalls (), $ inlineDef ->getConfigurator ()) )) {
789
+ if ($ arguments = array_filter ([ $ inlineDef ->getProperties (), $ inlineDef ->getMethodCalls (), $ inlineDef ->getConfigurator ()] )) {
790
790
$ isSimpleInstance = false ;
791
791
} elseif ($ definition !== $ inlineDef && 2 > $ this ->inlinedDefinitions [$ inlineDef ]) {
792
792
return $ code ;
@@ -855,9 +855,9 @@ private function generateServiceFiles(array $services)
855
855
if (!$ definition ->isShared ()) {
856
856
$ i = strpos ($ code , "\n\ninclude_once " );
857
857
if (false !== $ i && false !== $ i = strpos ($ code , "\n\n" , 2 + $ i )) {
858
- $ code = array ( substr ($ code , 0 , 2 + $ i ), substr ($ code , 2 + $ i )) ;
858
+ $ code = [ substr ($ code , 0 , 2 + $ i ), substr ($ code , 2 + $ i )] ;
859
859
} else {
860
- $ code = array ( "\n" , $ code) ;
860
+ $ code = [ "\n" , $ code] ;
861
861
}
862
862
$ code [1 ] = implode ("\n" , array_map (function ($ line ) { return $ line ? ' ' .$ line : $ line ; }, explode ("\n" , $ code [1 ])));
863
863
$ factory = sprintf ('$this->factories%s[ \'%s \'] ' , $ definition ->isPublic () ? '' : "['service_container'] " , $ id );
@@ -875,15 +875,15 @@ private function addNewInstance(Definition $definition, string $return = '', str
875
875
$ tail = $ return ? "; \n" : '' ;
876
876
877
877
if (BaseServiceLocator::class === $ definition ->getClass () && $ definition ->hasTag ($ this ->serviceLocatorTag )) {
878
- $ arguments = array () ;
878
+ $ arguments = [] ;
879
879
foreach ($ definition ->getArgument (0 ) as $ k => $ argument ) {
880
880
$ arguments [$ k ] = $ argument ->getValues ()[0 ];
881
881
}
882
882
883
883
return $ return .$ this ->dumpValue (new ServiceLocatorArgument ($ arguments )).$ tail ;
884
884
}
885
885
886
- $ arguments = array () ;
886
+ $ arguments = [] ;
887
887
foreach ($ definition ->getArguments () as $ value ) {
888
888
$ arguments [] = $ this ->dumpValue ($ value );
889
889
}
@@ -1157,11 +1157,11 @@ private function addInlineRequires(): string
1157
1157
return '' ;
1158
1158
}
1159
1159
1160
- $ lineage = array () ;
1160
+ $ lineage = [] ;
1161
1161
1162
1162
foreach ($ this ->container ->findTaggedServiceIds ($ this ->hotPathTag ) as $ id => $ tags ) {
1163
1163
$ definition = $ this ->container ->getDefinition ($ id );
1164
- $ inlinedDefinitions = $ this ->getDefinitionsFromArguments (array ( $ definition) );
1164
+ $ inlinedDefinitions = $ this ->getDefinitionsFromArguments ([ $ definition] );
1165
1165
1166
1166
foreach ($ inlinedDefinitions as $ def ) {
1167
1167
if (\is_string ($ class = \is_array ($ factory = $ def ->getFactory ()) && \is_string ($ factory [0 ]) ? $ factory [0 ] : $ def ->getClass ())) {
@@ -1188,14 +1188,14 @@ private function addDefaultParametersMethod(): string
1188
1188
return '' ;
1189
1189
}
1190
1190
1191
- $ php = array () ;
1192
- $ dynamicPhp = array () ;
1191
+ $ php = [] ;
1192
+ $ dynamicPhp = [] ;
1193
1193
1194
1194
foreach ($ this ->container ->getParameterBag ()->all () as $ key => $ value ) {
1195
1195
if ($ key !== $ resolvedKey = $ this ->container ->resolveEnvPlaceholders ($ key )) {
1196
1196
throw new InvalidArgumentException (sprintf ('Parameter name cannot use env parameters: %s. ' , $ resolvedKey ));
1197
1197
}
1198
- $ export = $ this ->exportParameters (array ( $ value) );
1198
+ $ export = $ this ->exportParameters ([ $ value] );
1199
1199
$ export = explode ('0 => ' , substr (rtrim ($ export , " ) \n" ), 7 , -1 ), 2 );
1200
1200
1201
1201
if (preg_match ("/ \\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDirs\[\d++\])/ " , $ export [1 ])) {
@@ -1317,7 +1317,7 @@ protected function getDefaultParameters()
1317
1317
*/
1318
1318
private function exportParameters (array $ parameters , string $ path = '' , int $ indent = 12 ): string
1319
1319
{
1320
- $ php = array () ;
1320
+ $ php = [] ;
1321
1321
foreach ($ parameters as $ key => $ value ) {
1322
1322
if (\is_array ($ value )) {
1323
1323
$ value = $ this ->exportParameters ($ value , $ path .'/ ' .$ key , $ indent + 4 );
@@ -1375,7 +1375,7 @@ private function wrapServiceConditionals($value, string $code): string
1375
1375
1376
1376
private function getServiceConditionals ($ value ): string
1377
1377
{
1378
- $ conditions = array () ;
1378
+ $ conditions = [] ;
1379
1379
foreach (ContainerBuilder::getInitializedConditionals ($ value ) as $ service ) {
1380
1380
if (!$ this ->container ->hasDefinition ($ service )) {
1381
1381
return 'false ' ;
@@ -1397,7 +1397,7 @@ private function getServiceConditionals($value): string
1397
1397
return implode (' && ' , $ conditions );
1398
1398
}
1399
1399
1400
- private function getDefinitionsFromArguments (array $ arguments , \SplObjectStorage $ definitions = null , array &$ calls = array () ): \SplObjectStorage
1400
+ private function getDefinitionsFromArguments (array $ arguments , \SplObjectStorage $ definitions = null , array &$ calls = [] ): \SplObjectStorage
1401
1401
{
1402
1402
if (null === $ definitions ) {
1403
1403
$ definitions = new \SplObjectStorage ();
@@ -1410,7 +1410,7 @@ private function getDefinitionsFromArguments(array $arguments, \SplObjectStorage
1410
1410
$ id = (string ) $ argument ;
1411
1411
1412
1412
if (!isset ($ calls [$ id ])) {
1413
- $ calls [$ id ] = array ( 0 , $ argument ->getInvalidBehavior ()) ;
1413
+ $ calls [$ id ] = [ 0 , $ argument ->getInvalidBehavior ()] ;
1414
1414
} else {
1415
1415
$ calls [$ id ][1 ] = min ($ calls [$ id ][1 ], $ argument ->getInvalidBehavior ());
1416
1416
}
@@ -1422,7 +1422,7 @@ private function getDefinitionsFromArguments(array $arguments, \SplObjectStorage
1422
1422
$ definitions [$ argument ] = 1 + $ definitions [$ argument ];
1423
1423
} else {
1424
1424
$ definitions [$ argument ] = 1 ;
1425
- $ arguments = array ( $ argument ->getArguments (), $ argument ->getFactory (), $ argument ->getProperties (), $ argument ->getMethodCalls (), $ argument ->getConfigurator ()) ;
1425
+ $ arguments = [ $ argument ->getArguments (), $ argument ->getFactory (), $ argument ->getProperties (), $ argument ->getMethodCalls (), $ argument ->getConfigurator ()] ;
1426
1426
$ this ->getDefinitionsFromArguments ($ arguments , $ definitions , $ calls );
1427
1427
}
1428
1428
}
@@ -1439,14 +1439,14 @@ private function dumpValue($value, bool $interpolate = true): string
1439
1439
if ($ value && $ interpolate && false !== $ param = array_search ($ value , $ this ->container ->getParameterBag ()->all (), true )) {
1440
1440
return $ this ->dumpValue ("% $ param% " );
1441
1441
}
1442
- $ code = array () ;
1442
+ $ code = [] ;
1443
1443
foreach ($ value as $ k => $ v ) {
1444
1444
$ code [] = sprintf ('%s => %s ' , $ this ->dumpValue ($ k , $ interpolate ), $ this ->dumpValue ($ v , $ interpolate ));
1445
1445
}
1446
1446
1447
1447
return sprintf ('array(%s) ' , implode (', ' , $ code ));
1448
1448
} elseif ($ value instanceof ArgumentInterface) {
1449
- $ scope = array ( $ this ->definitionVariables , $ this ->referenceVariables ) ;
1449
+ $ scope = [ $ this ->definitionVariables , $ this ->referenceVariables ] ;
1450
1450
$ this ->definitionVariables = $ this ->referenceVariables = null ;
1451
1451
1452
1452
try {
@@ -1465,14 +1465,14 @@ private function dumpValue($value, bool $interpolate = true): string
1465
1465
}
1466
1466
1467
1467
if ($ value instanceof IteratorArgument) {
1468
- $ operands = array ( 0 ) ;
1469
- $ code = array () ;
1468
+ $ operands = [ 0 ] ;
1469
+ $ code = [] ;
1470
1470
$ code [] = 'new RewindableGenerator(function () { ' ;
1471
1471
1472
1472
if (!$ values = $ value ->getValues ()) {
1473
1473
$ code [] = ' return new \EmptyIterator(); ' ;
1474
1474
} else {
1475
- $ countCode = array () ;
1475
+ $ countCode = [] ;
1476
1476
$ countCode [] = 'function () { ' ;
1477
1477
1478
1478
foreach ($ values as $ k => $ v ) {
@@ -1548,7 +1548,7 @@ private function dumpValue($value, bool $interpolate = true): string
1548
1548
1549
1549
return $ this ->getServiceCall ($ id , $ value );
1550
1550
} elseif ($ value instanceof Expression) {
1551
- return $ this ->getExpressionLanguage ()->compile ((string ) $ value , array ( 'this ' => 'container ' ) );
1551
+ return $ this ->getExpressionLanguage ()->compile ((string ) $ value , [ 'this ' => 'container ' ] );
1552
1552
} elseif ($ value instanceof Parameter) {
1553
1553
return $ this ->dumpParameter ($ value );
1554
1554
} elseif (true === $ interpolate && \is_string ($ value )) {
@@ -1670,8 +1670,8 @@ private function getServiceCall(string $id, Reference $reference = null): string
1670
1670
*/
1671
1671
private function initializeMethodNamesMap (string $ class )
1672
1672
{
1673
- $ this ->serviceIdToMethodNameMap = array () ;
1674
- $ this ->usedMethodNames = array () ;
1673
+ $ this ->serviceIdToMethodNameMap = [] ;
1674
+ $ this ->usedMethodNames = [] ;
1675
1675
1676
1676
if ($ reflectionClass = $ this ->container ->getReflectionClass ($ class )) {
1677
1677
foreach ($ reflectionClass ->getMethods () as $ method ) {
@@ -1776,7 +1776,7 @@ private function isSingleUsePrivateNode(ServiceReferenceGraphNode $node): bool
1776
1776
if ($ node ->getValue ()->isPublic ()) {
1777
1777
return false ;
1778
1778
}
1779
- $ ids = array () ;
1779
+ $ ids = [] ;
1780
1780
foreach ($ node ->getInEdges () as $ edge ) {
1781
1781
if (!$ value = $ edge ->getSourceNode ()->getValue ()) {
1782
1782
continue ;
0 commit comments