6262 */
6363class Application
6464{
65- private $ commands = array () ;
65+ private $ commands = [] ;
6666 private $ wantHelps = false ;
6767 private $ runningCommand ;
6868 private $ name ;
@@ -193,17 +193,17 @@ public function run(InputInterface $input = null, OutputInterface $output = null
193193 */
194194 public function doRun (InputInterface $ input , OutputInterface $ output )
195195 {
196- if (true === $ input ->hasParameterOption (array ( '--version ' , '-V ' ) , true )) {
196+ if (true === $ input ->hasParameterOption ([ '--version ' , '-V ' ] , true )) {
197197 $ output ->writeln ($ this ->getLongVersion ());
198198
199199 return 0 ;
200200 }
201201
202202 $ name = $ this ->getCommandName ($ input );
203- if (true === $ input ->hasParameterOption (array ( '--help ' , '-h ' ) , true )) {
203+ if (true === $ input ->hasParameterOption ([ '--help ' , '-h ' ] , true )) {
204204 if (!$ name ) {
205205 $ name = 'help ' ;
206- $ input = new ArrayInput (array ( 'command_name ' => $ this ->defaultCommand ) );
206+ $ input = new ArrayInput ([ 'command_name ' => $ this ->defaultCommand ] );
207207 } else {
208208 $ this ->wantHelps = true ;
209209 }
@@ -214,9 +214,9 @@ public function doRun(InputInterface $input, OutputInterface $output)
214214 $ definition = $ this ->getDefinition ();
215215 $ definition ->setArguments (array_merge (
216216 $ definition ->getArguments (),
217- array (
217+ [
218218 'command ' => new InputArgument ('command ' , InputArgument::OPTIONAL , $ definition ->getArgument ('command ' )->getDescription (), $ name ),
219- )
219+ ]
220220 ));
221221 }
222222
@@ -535,7 +535,7 @@ public function has($name)
535535 */
536536 public function getNamespaces ()
537537 {
538- $ namespaces = array () ;
538+ $ namespaces = [] ;
539539 foreach ($ this ->all () as $ command ) {
540540 $ namespaces = array_merge ($ namespaces , $ this ->extractAllNamespaces ($ command ->getName ()));
541541
@@ -602,7 +602,7 @@ public function find($name)
602602 {
603603 $ this ->init ();
604604
605- $ aliases = array () ;
605+ $ aliases = [] ;
606606 $ allCommands = $ this ->commandLoader ? array_merge ($ this ->commandLoader ->getNames (), array_keys ($ this ->commands )) : array_keys ($ this ->commands );
607607 $ expr = preg_replace_callback ('{([^:]+|)} ' , function ($ matches ) { return preg_quote ($ matches [1 ]).'[^:]* ' ; }, $ name );
608608 $ commands = preg_grep ('{^ ' .$ expr .'} ' , $ allCommands );
@@ -695,7 +695,7 @@ public function all($namespace = null)
695695 return $ commands ;
696696 }
697697
698- $ commands = array () ;
698+ $ commands = [] ;
699699 foreach ($ this ->commands as $ name => $ command ) {
700700 if ($ namespace === $ this ->extractNamespace ($ name , substr_count ($ namespace , ': ' ) + 1 )) {
701701 $ commands [$ name ] = $ command ;
@@ -722,7 +722,7 @@ public function all($namespace = null)
722722 */
723723 public static function getAbbreviations ($ names )
724724 {
725- $ abbrevs = array () ;
725+ $ abbrevs = [] ;
726726 foreach ($ names as $ name ) {
727727 for ($ len = \strlen ($ name ); $ len > 0 ; --$ len ) {
728728 $ abbrev = substr ($ name , 0 , $ len );
@@ -768,18 +768,18 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
768768 }
769769
770770 $ width = $ this ->terminal ->getWidth () ? $ this ->terminal ->getWidth () - 1 : PHP_INT_MAX ;
771- $ lines = array () ;
772- foreach ('' !== $ message ? preg_split ('/\r?\n/ ' , $ message ) : array () as $ line ) {
771+ $ lines = [] ;
772+ foreach ('' !== $ message ? preg_split ('/\r?\n/ ' , $ message ) : [] as $ line ) {
773773 foreach ($ this ->splitStringByWidth ($ line , $ width - 4 ) as $ line ) {
774774 // pre-format lines to get the right string length
775775 $ lineLength = Helper::strlen ($ line ) + 4 ;
776- $ lines [] = array ( $ line , $ lineLength) ;
776+ $ lines [] = [ $ line , $ lineLength] ;
777777
778778 $ len = max ($ lineLength , $ len );
779779 }
780780 }
781781
782- $ messages = array () ;
782+ $ messages = [] ;
783783 if (!$ e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $ output ->getVerbosity ()) {
784784 $ messages [] = sprintf ('<comment>%s</comment> ' , OutputFormatter::escape (sprintf ('In %s line %s: ' , basename ($ e ->getFile ()) ?: 'n/a ' , $ e ->getLine () ?: 'n/a ' )));
785785 }
@@ -801,12 +801,12 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
801801 // exception related properties
802802 $ trace = $ e ->getTrace ();
803803
804- array_unshift ($ trace , array (
804+ array_unshift ($ trace , [
805805 'function ' => '' ,
806806 'file ' => $ e ->getFile () ?: 'n/a ' ,
807807 'line ' => $ e ->getLine () ?: 'n/a ' ,
808- 'args ' => array () ,
809- ) );
808+ 'args ' => [] ,
809+ ] );
810810
811811 for ($ i = 0 , $ count = \count ($ trace ); $ i < $ count ; ++$ i ) {
812812 $ class = isset ($ trace [$ i ]['class ' ]) ? $ trace [$ i ]['class ' ] : '' ;
@@ -828,13 +828,13 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
828828 */
829829 protected function configureIO (InputInterface $ input , OutputInterface $ output )
830830 {
831- if (true === $ input ->hasParameterOption (array ( '--ansi ' ) , true )) {
831+ if (true === $ input ->hasParameterOption ([ '--ansi ' ] , true )) {
832832 $ output ->setDecorated (true );
833- } elseif (true === $ input ->hasParameterOption (array ( '--no-ansi ' ) , true )) {
833+ } elseif (true === $ input ->hasParameterOption ([ '--no-ansi ' ] , true )) {
834834 $ output ->setDecorated (false );
835835 }
836836
837- if (true === $ input ->hasParameterOption (array ( '--no-interaction ' , '-n ' ) , true )) {
837+ if (true === $ input ->hasParameterOption ([ '--no-interaction ' , '-n ' ] , true )) {
838838 $ input ->setInteractive (false );
839839 } elseif (\function_exists ('posix_isatty ' )) {
840840 $ inputStream = null ;
@@ -856,7 +856,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
856856 default : $ shellVerbosity = 0 ; break ;
857857 }
858858
859- if (true === $ input ->hasParameterOption (array ( '--quiet ' , '-q ' ) , true )) {
859+ if (true === $ input ->hasParameterOption ([ '--quiet ' , '-q ' ] , true )) {
860860 $ output ->setVerbosity (OutputInterface::VERBOSITY_QUIET );
861861 $ shellVerbosity = -1 ;
862862 } else {
@@ -957,7 +957,7 @@ protected function getCommandName(InputInterface $input)
957957 */
958958 protected function getDefaultInputDefinition ()
959959 {
960- return new InputDefinition (array (
960+ return new InputDefinition ([
961961 new InputArgument ('command ' , InputArgument::REQUIRED , 'The command to execute ' ),
962962
963963 new InputOption ('--help ' , '-h ' , InputOption::VALUE_NONE , 'Display this help message ' ),
@@ -967,7 +967,7 @@ protected function getDefaultInputDefinition()
967967 new InputOption ('--ansi ' , '' , InputOption::VALUE_NONE , 'Force ANSI output ' ),
968968 new InputOption ('--no-ansi ' , '' , InputOption::VALUE_NONE , 'Disable ANSI output ' ),
969969 new InputOption ('--no-interaction ' , '-n ' , InputOption::VALUE_NONE , 'Do not ask any interactive question ' ),
970- ) );
970+ ] );
971971 }
972972
973973 /**
@@ -977,7 +977,7 @@ protected function getDefaultInputDefinition()
977977 */
978978 protected function getDefaultCommands ()
979979 {
980- return array ( new HelpCommand (), new ListCommand ()) ;
980+ return [ new HelpCommand (), new ListCommand ()] ;
981981 }
982982
983983 /**
@@ -987,12 +987,12 @@ protected function getDefaultCommands()
987987 */
988988 protected function getDefaultHelperSet ()
989989 {
990- return new HelperSet (array (
990+ return new HelperSet ([
991991 new FormatterHelper (),
992992 new DebugFormatterHelper (),
993993 new ProcessHelper (),
994994 new QuestionHelper (),
995- ) );
995+ ] );
996996 }
997997
998998 /**
@@ -1037,9 +1037,9 @@ public function extractNamespace($name, $limit = null)
10371037 private function findAlternatives ($ name , $ collection )
10381038 {
10391039 $ threshold = 1e3 ;
1040- $ alternatives = array () ;
1040+ $ alternatives = [] ;
10411041
1042- $ collectionParts = array () ;
1042+ $ collectionParts = [] ;
10431043 foreach ($ collection as $ item ) {
10441044 $ collectionParts [$ item ] = explode (': ' , $ item );
10451045 }
@@ -1116,7 +1116,7 @@ private function splitStringByWidth($string, $width)
11161116 }
11171117
11181118 $ utf8String = mb_convert_encoding ($ string , 'utf8 ' , $ encoding );
1119- $ lines = array () ;
1119+ $ lines = [] ;
11201120 $ line = '' ;
11211121 foreach (preg_split ('//u ' , $ utf8String ) as $ char ) {
11221122 // test if $char could be appended to current line
@@ -1147,7 +1147,7 @@ private function extractAllNamespaces($name)
11471147 {
11481148 // -1 as third argument is needed to skip the command short name when exploding
11491149 $ parts = explode (': ' , $ name , -1 );
1150- $ namespaces = array () ;
1150+ $ namespaces = [] ;
11511151
11521152 foreach ($ parts as $ part ) {
11531153 if (\count ($ namespaces )) {
0 commit comments