@@ -37,7 +37,7 @@ class DebugCommand extends Command
37
37
private $ twigDefaultPath ;
38
38
private $ rootDir ;
39
39
40
- public function __construct (Environment $ twig , string $ projectDir = null , array $ bundlesMetadata = array () , string $ twigDefaultPath = null , string $ rootDir = null )
40
+ public function __construct (Environment $ twig , string $ projectDir = null , array $ bundlesMetadata = [] , string $ twigDefaultPath = null , string $ rootDir = null )
41
41
{
42
42
parent ::__construct ();
43
43
@@ -51,11 +51,11 @@ public function __construct(Environment $twig, string $projectDir = null, array
51
51
protected function configure ()
52
52
{
53
53
$ this
54
- ->setDefinition (array (
54
+ ->setDefinition ([
55
55
new InputArgument ('name ' , InputArgument::OPTIONAL , 'The template name ' ),
56
56
new InputOption ('filter ' , null , InputOption::VALUE_REQUIRED , 'Show details for all entries matching this filter ' ),
57
57
new InputOption ('format ' , null , InputOption::VALUE_REQUIRED , 'The output format (text or json) ' , 'text ' ),
58
- ) )
58
+ ] )
59
59
->setDescription ('Shows a list of twig functions, filters, globals and tests ' )
60
60
->setHelp (<<<'EOF'
61
61
The <info>%command.name%</info> command outputs a list of twig functions,
@@ -115,11 +115,11 @@ private function displayPathsText(SymfonyStyle $io, string $name)
115
115
$ io ->listing ($ files );
116
116
}
117
117
} else {
118
- $ alternatives = array () ;
118
+ $ alternatives = [] ;
119
119
120
120
if ($ paths ) {
121
- $ shortnames = array () ;
122
- $ dirs = array () ;
121
+ $ shortnames = [] ;
122
+ $ dirs = [] ;
123
123
foreach (current ($ paths ) as $ path ) {
124
124
$ dirs [] = $ this ->isAbsolutePath ($ path ) ? $ path : $ this ->projectDir .'/ ' .$ path ;
125
125
}
@@ -141,9 +141,9 @@ private function displayPathsText(SymfonyStyle $io, string $name)
141
141
142
142
$ io ->section ('Configured Paths ' );
143
143
if ($ paths ) {
144
- $ io ->table (array ( 'Namespace ' , 'Paths ' ) , $ this ->buildTableRows ($ paths ));
144
+ $ io ->table ([ 'Namespace ' , 'Paths ' ] , $ this ->buildTableRows ($ paths ));
145
145
} else {
146
- $ alternatives = array () ;
146
+ $ alternatives = [] ;
147
147
$ namespace = $ this ->parseTemplateName ($ name )[0 ];
148
148
149
149
if (FilesystemLoader::MAIN_NAMESPACE === $ namespace ) {
@@ -159,7 +159,7 @@ private function displayPathsText(SymfonyStyle $io, string $name)
159
159
$ this ->error ($ io , $ message , $ alternatives );
160
160
161
161
if (!$ alternatives && $ paths = $ this ->getLoaderPaths ()) {
162
- $ io ->table (array ( 'Namespace ' , 'Paths ' ) , $ this ->buildTableRows ($ paths ));
162
+ $ io ->table ([ 'Namespace ' , 'Paths ' ] , $ this ->buildTableRows ($ paths ));
163
163
}
164
164
}
165
165
}
@@ -184,9 +184,9 @@ private function displayPathsJson(SymfonyStyle $io, string $name)
184
184
185
185
private function displayGeneralText (SymfonyStyle $ io , string $ filter = null )
186
186
{
187
- $ types = array ( 'functions ' , 'filters ' , 'tests ' , 'globals ' ) ;
187
+ $ types = [ 'functions ' , 'filters ' , 'tests ' , 'globals ' ] ;
188
188
foreach ($ types as $ index => $ type ) {
189
- $ items = array () ;
189
+ $ items = [] ;
190
190
foreach ($ this ->twig ->{'get ' .ucfirst ($ type )}() as $ name => $ entity ) {
191
191
if (!$ filter || false !== strpos ($ name , $ filter )) {
192
192
$ items [$ name ] = $ name .$ this ->getPrettyMetadata ($ type , $ entity );
@@ -205,7 +205,7 @@ private function displayGeneralText(SymfonyStyle $io, string $filter = null)
205
205
206
206
if (!$ filter && $ paths = $ this ->getLoaderPaths ()) {
207
207
$ io ->section ('Loader Paths ' );
208
- $ io ->table (array ( 'Namespace ' , 'Paths ' ) , $ this ->buildTableRows ($ paths ));
208
+ $ io ->table ([ 'Namespace ' , 'Paths ' ] , $ this ->buildTableRows ($ paths ));
209
209
}
210
210
211
211
if ($ wrongBundles = $ this ->findWrongBundleOverrides ()) {
@@ -217,8 +217,8 @@ private function displayGeneralText(SymfonyStyle $io, string $filter = null)
217
217
218
218
private function displayGeneralJson (SymfonyStyle $ io , $ filter )
219
219
{
220
- $ types = array ( 'functions ' , 'filters ' , 'tests ' , 'globals ' ) ;
221
- $ data = array () ;
220
+ $ types = [ 'functions ' , 'filters ' , 'tests ' , 'globals ' ] ;
221
+ $ data = [] ;
222
222
foreach ($ types as $ type ) {
223
223
foreach ($ this ->twig ->{'get ' .ucfirst ($ type )}() as $ name => $ entity ) {
224
224
if (!$ filter || false !== strpos ($ name , $ filter )) {
@@ -245,15 +245,15 @@ private function getLoaderPaths(string $name = null): array
245
245
{
246
246
/** @var FilesystemLoader $loader */
247
247
$ loader = $ this ->twig ->getLoader ();
248
- $ loaderPaths = array () ;
248
+ $ loaderPaths = [] ;
249
249
$ namespaces = $ loader ->getNamespaces ();
250
250
if (null !== $ name ) {
251
251
$ namespace = $ this ->parseTemplateName ($ name )[0 ];
252
- $ namespaces = array_intersect (array ( $ namespace) , $ namespaces );
252
+ $ namespaces = array_intersect ([ $ namespace] , $ namespaces );
253
253
}
254
254
255
255
foreach ($ namespaces as $ namespace ) {
256
- $ paths = array_map (array ( $ this , 'getRelativePath ' ) , $ loader ->getPaths ($ namespace ));
256
+ $ paths = array_map ([ $ this , 'getRelativePath ' ] , $ loader ->getPaths ($ namespace ));
257
257
258
258
if (FilesystemLoader::MAIN_NAMESPACE === $ namespace ) {
259
259
$ namespace = '(None) ' ;
@@ -357,8 +357,8 @@ private function getPrettyMetadata($type, $entity)
357
357
358
358
private function findWrongBundleOverrides (): array
359
359
{
360
- $ alternatives = array () ;
361
- $ bundleNames = array () ;
360
+ $ alternatives = [] ;
361
+ $ bundleNames = [] ;
362
362
363
363
if ($ this ->rootDir && $ this ->projectDir ) {
364
364
$ folders = glob ($ this ->rootDir .'/Resources/*/views ' , GLOB_ONLYDIR );
@@ -391,7 +391,7 @@ private function findWrongBundleOverrides(): array
391
391
}
392
392
393
393
if ($ notFoundBundles = array_diff_key ($ bundleNames , $ this ->bundlesMetadata )) {
394
- $ alternatives = array () ;
394
+ $ alternatives = [] ;
395
395
foreach ($ notFoundBundles as $ notFoundBundle => $ path ) {
396
396
$ alternatives [$ path ] = $ this ->findAlternatives ($ notFoundBundle , array_keys ($ this ->bundlesMetadata ));
397
397
}
@@ -402,7 +402,7 @@ private function findWrongBundleOverrides(): array
402
402
403
403
private function buildWarningMessages (array $ wrongBundles ): array
404
404
{
405
- $ messages = array () ;
405
+ $ messages = [] ;
406
406
foreach ($ wrongBundles as $ path => $ alternatives ) {
407
407
$ message = sprintf ('Path "%s" not matching any bundle found ' , $ path );
408
408
if ($ alternatives ) {
@@ -421,7 +421,7 @@ private function buildWarningMessages(array $wrongBundles): array
421
421
return $ messages ;
422
422
}
423
423
424
- private function error (SymfonyStyle $ io , string $ message , array $ alternatives = array () ): void
424
+ private function error (SymfonyStyle $ io , string $ message , array $ alternatives = [] ): void
425
425
{
426
426
if ($ alternatives ) {
427
427
if (1 === \count ($ alternatives )) {
@@ -439,7 +439,7 @@ private function findTemplateFiles(string $name): array
439
439
{
440
440
/** @var FilesystemLoader $loader */
441
441
$ loader = $ this ->twig ->getLoader ();
442
- $ files = array () ;
442
+ $ files = [] ;
443
443
list ($ namespace , $ shortname ) = $ this ->parseTemplateName ($ name );
444
444
445
445
foreach ($ loader ->getPaths ($ namespace ) as $ path ) {
@@ -470,29 +470,29 @@ private function parseTemplateName(string $name, string $default = FilesystemLoa
470
470
$ namespace = substr ($ name , 1 , $ pos - 1 );
471
471
$ shortname = substr ($ name , $ pos + 1 );
472
472
473
- return array ( $ namespace , $ shortname) ;
473
+ return [ $ namespace , $ shortname] ;
474
474
}
475
475
476
- return array ( $ default , $ name) ;
476
+ return [ $ default , $ name] ;
477
477
}
478
478
479
479
private function buildTableRows (array $ loaderPaths ): array
480
480
{
481
- $ rows = array () ;
481
+ $ rows = [] ;
482
482
$ firstNamespace = true ;
483
483
$ prevHasSeparator = false ;
484
484
485
485
foreach ($ loaderPaths as $ namespace => $ paths ) {
486
486
if (!$ firstNamespace && !$ prevHasSeparator && \count ($ paths ) > 1 ) {
487
- $ rows [] = array ( '' , '' ) ;
487
+ $ rows [] = [ '' , '' ] ;
488
488
}
489
489
$ firstNamespace = false ;
490
490
foreach ($ paths as $ path ) {
491
- $ rows [] = array ( $ namespace , $ path .\DIRECTORY_SEPARATOR ) ;
491
+ $ rows [] = [ $ namespace , $ path .\DIRECTORY_SEPARATOR ] ;
492
492
$ namespace = '' ;
493
493
}
494
494
if (\count ($ paths ) > 1 ) {
495
- $ rows [] = array ( '' , '' ) ;
495
+ $ rows [] = [ '' , '' ] ;
496
496
$ prevHasSeparator = true ;
497
497
} else {
498
498
$ prevHasSeparator = false ;
@@ -507,7 +507,7 @@ private function buildTableRows(array $loaderPaths): array
507
507
508
508
private function findAlternatives (string $ name , array $ collection ): array
509
509
{
510
- $ alternatives = array () ;
510
+ $ alternatives = [] ;
511
511
foreach ($ collection as $ item ) {
512
512
$ lev = levenshtein ($ name , $ item );
513
513
if ($ lev <= \strlen ($ name ) / 3 || false !== strpos ($ item , $ name )) {
0 commit comments