@@ -37,7 +37,7 @@ class DebugCommand extends Command
3737 private $ twigDefaultPath ;
3838 private $ rootDir ;
3939
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 )
4141 {
4242 parent ::__construct ();
4343
@@ -51,11 +51,11 @@ public function __construct(Environment $twig, string $projectDir = null, array
5151 protected function configure ()
5252 {
5353 $ this
54- ->setDefinition (array (
54+ ->setDefinition ([
5555 new InputArgument ('name ' , InputArgument::OPTIONAL , 'The template name ' ),
5656 new InputOption ('filter ' , null , InputOption::VALUE_REQUIRED , 'Show details for all entries matching this filter ' ),
5757 new InputOption ('format ' , null , InputOption::VALUE_REQUIRED , 'The output format (text or json) ' , 'text ' ),
58- ) )
58+ ] )
5959 ->setDescription ('Shows a list of twig functions, filters, globals and tests ' )
6060 ->setHelp (<<<'EOF'
6161The <info>%command.name%</info> command outputs a list of twig functions,
@@ -115,11 +115,11 @@ private function displayPathsText(SymfonyStyle $io, string $name)
115115 $ io ->listing ($ files );
116116 }
117117 } else {
118- $ alternatives = array () ;
118+ $ alternatives = [] ;
119119
120120 if ($ paths ) {
121- $ shortnames = array () ;
122- $ dirs = array () ;
121+ $ shortnames = [] ;
122+ $ dirs = [] ;
123123 foreach (current ($ paths ) as $ path ) {
124124 $ dirs [] = $ this ->isAbsolutePath ($ path ) ? $ path : $ this ->projectDir .'/ ' .$ path ;
125125 }
@@ -141,9 +141,9 @@ private function displayPathsText(SymfonyStyle $io, string $name)
141141
142142 $ io ->section ('Configured Paths ' );
143143 if ($ paths ) {
144- $ io ->table (array ( 'Namespace ' , 'Paths ' ) , $ this ->buildTableRows ($ paths ));
144+ $ io ->table ([ 'Namespace ' , 'Paths ' ] , $ this ->buildTableRows ($ paths ));
145145 } else {
146- $ alternatives = array () ;
146+ $ alternatives = [] ;
147147 $ namespace = $ this ->parseTemplateName ($ name )[0 ];
148148
149149 if (FilesystemLoader::MAIN_NAMESPACE === $ namespace ) {
@@ -159,7 +159,7 @@ private function displayPathsText(SymfonyStyle $io, string $name)
159159 $ this ->error ($ io , $ message , $ alternatives );
160160
161161 if (!$ alternatives && $ paths = $ this ->getLoaderPaths ()) {
162- $ io ->table (array ( 'Namespace ' , 'Paths ' ) , $ this ->buildTableRows ($ paths ));
162+ $ io ->table ([ 'Namespace ' , 'Paths ' ] , $ this ->buildTableRows ($ paths ));
163163 }
164164 }
165165 }
@@ -184,9 +184,9 @@ private function displayPathsJson(SymfonyStyle $io, string $name)
184184
185185 private function displayGeneralText (SymfonyStyle $ io , string $ filter = null )
186186 {
187- $ types = array ( 'functions ' , 'filters ' , 'tests ' , 'globals ' ) ;
187+ $ types = [ 'functions ' , 'filters ' , 'tests ' , 'globals ' ] ;
188188 foreach ($ types as $ index => $ type ) {
189- $ items = array () ;
189+ $ items = [] ;
190190 foreach ($ this ->twig ->{'get ' .ucfirst ($ type )}() as $ name => $ entity ) {
191191 if (!$ filter || false !== strpos ($ name , $ filter )) {
192192 $ items [$ name ] = $ name .$ this ->getPrettyMetadata ($ type , $ entity );
@@ -205,7 +205,7 @@ private function displayGeneralText(SymfonyStyle $io, string $filter = null)
205205
206206 if (!$ filter && $ paths = $ this ->getLoaderPaths ()) {
207207 $ io ->section ('Loader Paths ' );
208- $ io ->table (array ( 'Namespace ' , 'Paths ' ) , $ this ->buildTableRows ($ paths ));
208+ $ io ->table ([ 'Namespace ' , 'Paths ' ] , $ this ->buildTableRows ($ paths ));
209209 }
210210
211211 if ($ wrongBundles = $ this ->findWrongBundleOverrides ()) {
@@ -217,8 +217,8 @@ private function displayGeneralText(SymfonyStyle $io, string $filter = null)
217217
218218 private function displayGeneralJson (SymfonyStyle $ io , $ filter )
219219 {
220- $ types = array ( 'functions ' , 'filters ' , 'tests ' , 'globals ' ) ;
221- $ data = array () ;
220+ $ types = [ 'functions ' , 'filters ' , 'tests ' , 'globals ' ] ;
221+ $ data = [] ;
222222 foreach ($ types as $ type ) {
223223 foreach ($ this ->twig ->{'get ' .ucfirst ($ type )}() as $ name => $ entity ) {
224224 if (!$ filter || false !== strpos ($ name , $ filter )) {
@@ -245,15 +245,15 @@ private function getLoaderPaths(string $name = null): array
245245 {
246246 /** @var FilesystemLoader $loader */
247247 $ loader = $ this ->twig ->getLoader ();
248- $ loaderPaths = array () ;
248+ $ loaderPaths = [] ;
249249 $ namespaces = $ loader ->getNamespaces ();
250250 if (null !== $ name ) {
251251 $ namespace = $ this ->parseTemplateName ($ name )[0 ];
252- $ namespaces = array_intersect (array ( $ namespace) , $ namespaces );
252+ $ namespaces = array_intersect ([ $ namespace] , $ namespaces );
253253 }
254254
255255 foreach ($ namespaces as $ namespace ) {
256- $ paths = array_map (array ( $ this , 'getRelativePath ' ) , $ loader ->getPaths ($ namespace ));
256+ $ paths = array_map ([ $ this , 'getRelativePath ' ] , $ loader ->getPaths ($ namespace ));
257257
258258 if (FilesystemLoader::MAIN_NAMESPACE === $ namespace ) {
259259 $ namespace = '(None) ' ;
@@ -357,8 +357,8 @@ private function getPrettyMetadata($type, $entity)
357357
358358 private function findWrongBundleOverrides (): array
359359 {
360- $ alternatives = array () ;
361- $ bundleNames = array () ;
360+ $ alternatives = [] ;
361+ $ bundleNames = [] ;
362362
363363 if ($ this ->rootDir && $ this ->projectDir ) {
364364 $ folders = glob ($ this ->rootDir .'/Resources/*/views ' , GLOB_ONLYDIR );
@@ -391,7 +391,7 @@ private function findWrongBundleOverrides(): array
391391 }
392392
393393 if ($ notFoundBundles = array_diff_key ($ bundleNames , $ this ->bundlesMetadata )) {
394- $ alternatives = array () ;
394+ $ alternatives = [] ;
395395 foreach ($ notFoundBundles as $ notFoundBundle => $ path ) {
396396 $ alternatives [$ path ] = $ this ->findAlternatives ($ notFoundBundle , array_keys ($ this ->bundlesMetadata ));
397397 }
@@ -402,7 +402,7 @@ private function findWrongBundleOverrides(): array
402402
403403 private function buildWarningMessages (array $ wrongBundles ): array
404404 {
405- $ messages = array () ;
405+ $ messages = [] ;
406406 foreach ($ wrongBundles as $ path => $ alternatives ) {
407407 $ message = sprintf ('Path "%s" not matching any bundle found ' , $ path );
408408 if ($ alternatives ) {
@@ -421,7 +421,7 @@ private function buildWarningMessages(array $wrongBundles): array
421421 return $ messages ;
422422 }
423423
424- private function error (SymfonyStyle $ io , string $ message , array $ alternatives = array () ): void
424+ private function error (SymfonyStyle $ io , string $ message , array $ alternatives = [] ): void
425425 {
426426 if ($ alternatives ) {
427427 if (1 === \count ($ alternatives )) {
@@ -439,7 +439,7 @@ private function findTemplateFiles(string $name): array
439439 {
440440 /** @var FilesystemLoader $loader */
441441 $ loader = $ this ->twig ->getLoader ();
442- $ files = array () ;
442+ $ files = [] ;
443443 list ($ namespace , $ shortname ) = $ this ->parseTemplateName ($ name );
444444
445445 foreach ($ loader ->getPaths ($ namespace ) as $ path ) {
@@ -470,29 +470,29 @@ private function parseTemplateName(string $name, string $default = FilesystemLoa
470470 $ namespace = substr ($ name , 1 , $ pos - 1 );
471471 $ shortname = substr ($ name , $ pos + 1 );
472472
473- return array ( $ namespace , $ shortname) ;
473+ return [ $ namespace , $ shortname] ;
474474 }
475475
476- return array ( $ default , $ name) ;
476+ return [ $ default , $ name] ;
477477 }
478478
479479 private function buildTableRows (array $ loaderPaths ): array
480480 {
481- $ rows = array () ;
481+ $ rows = [] ;
482482 $ firstNamespace = true ;
483483 $ prevHasSeparator = false ;
484484
485485 foreach ($ loaderPaths as $ namespace => $ paths ) {
486486 if (!$ firstNamespace && !$ prevHasSeparator && \count ($ paths ) > 1 ) {
487- $ rows [] = array ( '' , '' ) ;
487+ $ rows [] = [ '' , '' ] ;
488488 }
489489 $ firstNamespace = false ;
490490 foreach ($ paths as $ path ) {
491- $ rows [] = array ( $ namespace , $ path .\DIRECTORY_SEPARATOR ) ;
491+ $ rows [] = [ $ namespace , $ path .\DIRECTORY_SEPARATOR ] ;
492492 $ namespace = '' ;
493493 }
494494 if (\count ($ paths ) > 1 ) {
495- $ rows [] = array ( '' , '' ) ;
495+ $ rows [] = [ '' , '' ] ;
496496 $ prevHasSeparator = true ;
497497 } else {
498498 $ prevHasSeparator = false ;
@@ -507,7 +507,7 @@ private function buildTableRows(array $loaderPaths): array
507507
508508 private function findAlternatives (string $ name , array $ collection ): array
509509 {
510- $ alternatives = array () ;
510+ $ alternatives = [] ;
511511 foreach ($ collection as $ item ) {
512512 $ lev = levenshtein ($ name , $ item );
513513 if ($ lev <= \strlen ($ name ) / 3 || false !== strpos ($ item , $ name )) {
0 commit comments