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 );
@@ -760,18 +760,18 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
760760 }
761761
762762 $ width = $ this ->terminal ->getWidth () ? $ this ->terminal ->getWidth () - 1 : PHP_INT_MAX ;
763- $ lines = array () ;
764- foreach ('' !== $ message ? preg_split ('/\r?\n/ ' , $ message ) : array () as $ line ) {
763+ $ lines = [] ;
764+ foreach ('' !== $ message ? preg_split ('/\r?\n/ ' , $ message ) : [] as $ line ) {
765765 foreach ($ this ->splitStringByWidth ($ line , $ width - 4 ) as $ line ) {
766766 // pre-format lines to get the right string length
767767 $ lineLength = Helper::strlen ($ line ) + 4 ;
768- $ lines [] = array ( $ line , $ lineLength) ;
768+ $ lines [] = [ $ line , $ lineLength] ;
769769
770770 $ len = max ($ lineLength , $ len );
771771 }
772772 }
773773
774- $ messages = array () ;
774+ $ messages = [] ;
775775 if (!$ e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $ output ->getVerbosity ()) {
776776 $ messages [] = sprintf ('<comment>%s</comment> ' , OutputFormatter::escape (sprintf ('In %s line %s: ' , basename ($ e ->getFile ()) ?: 'n/a ' , $ e ->getLine () ?: 'n/a ' )));
777777 }
@@ -793,12 +793,12 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
793793 // exception related properties
794794 $ trace = $ e ->getTrace ();
795795
796- array_unshift ($ trace , array (
796+ array_unshift ($ trace , [
797797 'function ' => '' ,
798798 'file ' => $ e ->getFile () ?: 'n/a ' ,
799799 'line ' => $ e ->getLine () ?: 'n/a ' ,
800- 'args ' => array () ,
801- ) );
800+ 'args ' => [] ,
801+ ] );
802802
803803 for ($ i = 0 , $ count = \count ($ trace ); $ i < $ count ; ++$ i ) {
804804 $ class = isset ($ trace [$ i ]['class ' ]) ? $ trace [$ i ]['class ' ] : '' ;
@@ -820,13 +820,13 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
820820 */
821821 protected function configureIO (InputInterface $ input , OutputInterface $ output )
822822 {
823- if (true === $ input ->hasParameterOption (array ( '--ansi ' ) , true )) {
823+ if (true === $ input ->hasParameterOption ([ '--ansi ' ] , true )) {
824824 $ output ->setDecorated (true );
825- } elseif (true === $ input ->hasParameterOption (array ( '--no-ansi ' ) , true )) {
825+ } elseif (true === $ input ->hasParameterOption ([ '--no-ansi ' ] , true )) {
826826 $ output ->setDecorated (false );
827827 }
828828
829- if (true === $ input ->hasParameterOption (array ( '--no-interaction ' , '-n ' ) , true )) {
829+ if (true === $ input ->hasParameterOption ([ '--no-interaction ' , '-n ' ] , true )) {
830830 $ input ->setInteractive (false );
831831 } elseif (\function_exists ('posix_isatty ' )) {
832832 $ inputStream = null ;
@@ -848,7 +848,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
848848 default : $ shellVerbosity = 0 ; break ;
849849 }
850850
851- if (true === $ input ->hasParameterOption (array ( '--quiet ' , '-q ' ) , true )) {
851+ if (true === $ input ->hasParameterOption ([ '--quiet ' , '-q ' ] , true )) {
852852 $ output ->setVerbosity (OutputInterface::VERBOSITY_QUIET );
853853 $ shellVerbosity = -1 ;
854854 } else {
@@ -949,7 +949,7 @@ protected function getCommandName(InputInterface $input)
949949 */
950950 protected function getDefaultInputDefinition ()
951951 {
952- return new InputDefinition (array (
952+ return new InputDefinition ([
953953 new InputArgument ('command ' , InputArgument::REQUIRED , 'The command to execute ' ),
954954
955955 new InputOption ('--help ' , '-h ' , InputOption::VALUE_NONE , 'Display this help message ' ),
@@ -959,7 +959,7 @@ protected function getDefaultInputDefinition()
959959 new InputOption ('--ansi ' , '' , InputOption::VALUE_NONE , 'Force ANSI output ' ),
960960 new InputOption ('--no-ansi ' , '' , InputOption::VALUE_NONE , 'Disable ANSI output ' ),
961961 new InputOption ('--no-interaction ' , '-n ' , InputOption::VALUE_NONE , 'Do not ask any interactive question ' ),
962- ) );
962+ ] );
963963 }
964964
965965 /**
@@ -969,7 +969,7 @@ protected function getDefaultInputDefinition()
969969 */
970970 protected function getDefaultCommands ()
971971 {
972- return array ( new HelpCommand (), new ListCommand ()) ;
972+ return [ new HelpCommand (), new ListCommand ()] ;
973973 }
974974
975975 /**
@@ -979,12 +979,12 @@ protected function getDefaultCommands()
979979 */
980980 protected function getDefaultHelperSet ()
981981 {
982- return new HelperSet (array (
982+ return new HelperSet ([
983983 new FormatterHelper (),
984984 new DebugFormatterHelper (),
985985 new ProcessHelper (),
986986 new QuestionHelper (),
987- ) );
987+ ] );
988988 }
989989
990990 /**
@@ -1029,9 +1029,9 @@ public function extractNamespace($name, $limit = null)
10291029 private function findAlternatives ($ name , $ collection )
10301030 {
10311031 $ threshold = 1e3 ;
1032- $ alternatives = array () ;
1032+ $ alternatives = [] ;
10331033
1034- $ collectionParts = array () ;
1034+ $ collectionParts = [] ;
10351035 foreach ($ collection as $ item ) {
10361036 $ collectionParts [$ item ] = explode (': ' , $ item );
10371037 }
@@ -1108,7 +1108,7 @@ private function splitStringByWidth($string, $width)
11081108 }
11091109
11101110 $ utf8String = mb_convert_encoding ($ string , 'utf8 ' , $ encoding );
1111- $ lines = array () ;
1111+ $ lines = [] ;
11121112 $ line = '' ;
11131113 foreach (preg_split ('//u ' , $ utf8String ) as $ char ) {
11141114 // test if $char could be appended to current line
@@ -1139,7 +1139,7 @@ private function extractAllNamespaces($name)
11391139 {
11401140 // -1 as third argument is needed to skip the command short name when exploding
11411141 $ parts = explode (': ' , $ name , -1 );
1142- $ namespaces = array () ;
1142+ $ namespaces = [] ;
11431143
11441144 foreach ($ parts as $ part ) {
11451145 if (\count ($ namespaces )) {
0 commit comments