6161 */
6262class Application
6363{
64- private $ commands = array () ;
64+ private $ commands = [] ;
6565 private $ wantHelps = false ;
6666 private $ runningCommand ;
6767 private $ name ;
@@ -196,17 +196,17 @@ public function run(InputInterface $input = null, OutputInterface $output = null
196196 */
197197 public function doRun (InputInterface $ input , OutputInterface $ output )
198198 {
199- if (true === $ input ->hasParameterOption (array ( '--version ' , '-V ' ) , true )) {
199+ if (true === $ input ->hasParameterOption ([ '--version ' , '-V ' ] , true )) {
200200 $ output ->writeln ($ this ->getLongVersion ());
201201
202202 return 0 ;
203203 }
204204
205205 $ name = $ this ->getCommandName ($ input );
206- if (true === $ input ->hasParameterOption (array ( '--help ' , '-h ' ) , true )) {
206+ if (true === $ input ->hasParameterOption ([ '--help ' , '-h ' ] , true )) {
207207 if (!$ name ) {
208208 $ name = 'help ' ;
209- $ input = new ArrayInput (array ( 'command_name ' => $ this ->defaultCommand ) );
209+ $ input = new ArrayInput ([ 'command_name ' => $ this ->defaultCommand ] );
210210 } else {
211211 $ this ->wantHelps = true ;
212212 }
@@ -217,9 +217,9 @@ public function doRun(InputInterface $input, OutputInterface $output)
217217 $ definition = $ this ->getDefinition ();
218218 $ definition ->setArguments (array_merge (
219219 $ definition ->getArguments (),
220- array (
220+ [
221221 'command ' => new InputArgument ('command ' , InputArgument::OPTIONAL , $ definition ->getArgument ('command ' )->getDescription (), $ name ),
222- )
222+ ]
223223 ));
224224 }
225225
@@ -521,7 +521,7 @@ public function has($name)
521521 */
522522 public function getNamespaces ()
523523 {
524- $ namespaces = array () ;
524+ $ namespaces = [] ;
525525 foreach ($ this ->all () as $ command ) {
526526 $ namespaces = array_merge ($ namespaces , $ this ->extractAllNamespaces ($ command ->getName ()));
527527
@@ -588,7 +588,7 @@ public function find($name)
588588 {
589589 $ this ->init ();
590590
591- $ aliases = array () ;
591+ $ aliases = [] ;
592592 $ allCommands = $ this ->commandLoader ? array_merge ($ this ->commandLoader ->getNames (), array_keys ($ this ->commands )) : array_keys ($ this ->commands );
593593 $ expr = preg_replace_callback ('{([^:]+|)} ' , function ($ matches ) { return preg_quote ($ matches [1 ]).'[^:]* ' ; }, $ name );
594594 $ commands = preg_grep ('{^ ' .$ expr .'} ' , $ allCommands );
@@ -681,7 +681,7 @@ public function all($namespace = null)
681681 return $ commands ;
682682 }
683683
684- $ commands = array () ;
684+ $ commands = [] ;
685685 foreach ($ this ->commands as $ name => $ command ) {
686686 if ($ namespace === $ this ->extractNamespace ($ name , substr_count ($ namespace , ': ' ) + 1 )) {
687687 $ commands [$ name ] = $ command ;
@@ -708,7 +708,7 @@ public function all($namespace = null)
708708 */
709709 public static function getAbbreviations ($ names )
710710 {
711- $ abbrevs = array () ;
711+ $ abbrevs = [] ;
712712 foreach ($ names as $ name ) {
713713 for ($ len = \strlen ($ name ); $ len > 0 ; --$ len ) {
714714 $ abbrev = substr ($ name , 0 , $ len );
@@ -750,18 +750,18 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
750750 if (\defined ('HHVM_VERSION ' ) && $ width > 1 << 31 ) {
751751 $ width = 1 << 31 ;
752752 }
753- $ lines = array () ;
754- foreach ('' !== $ message ? preg_split ('/\r?\n/ ' , $ message ) : array () as $ line ) {
753+ $ lines = [] ;
754+ foreach ('' !== $ message ? preg_split ('/\r?\n/ ' , $ message ) : [] as $ line ) {
755755 foreach ($ this ->splitStringByWidth ($ line , $ width - 4 ) as $ line ) {
756756 // pre-format lines to get the right string length
757757 $ lineLength = Helper::strlen ($ line ) + 4 ;
758- $ lines [] = array ( $ line , $ lineLength) ;
758+ $ lines [] = [ $ line , $ lineLength] ;
759759
760760 $ len = max ($ lineLength , $ len );
761761 }
762762 }
763763
764- $ messages = array () ;
764+ $ messages = [] ;
765765 if (!$ e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $ output ->getVerbosity ()) {
766766 $ messages [] = sprintf ('<comment>%s</comment> ' , OutputFormatter::escape (sprintf ('In %s line %s: ' , basename ($ e ->getFile ()) ?: 'n/a ' , $ e ->getLine () ?: 'n/a ' )));
767767 }
@@ -783,12 +783,12 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
783783 // exception related properties
784784 $ trace = $ e ->getTrace ();
785785
786- array_unshift ($ trace , array (
786+ array_unshift ($ trace , [
787787 'function ' => '' ,
788788 'file ' => $ e ->getFile () ?: 'n/a ' ,
789789 'line ' => $ e ->getLine () ?: 'n/a ' ,
790- 'args ' => array () ,
791- ) );
790+ 'args ' => [] ,
791+ ] );
792792
793793 for ($ i = 0 , $ count = \count ($ trace ); $ i < $ count ; ++$ i ) {
794794 $ class = isset ($ trace [$ i ]['class ' ]) ? $ trace [$ i ]['class ' ] : '' ;
@@ -844,7 +844,7 @@ public function getTerminalDimensions()
844844 {
845845 @trigger_error (sprintf ('The "%s()" method is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead. ' , __METHOD__ ), E_USER_DEPRECATED );
846846
847- return array ( $ this ->terminal ->getWidth (), $ this ->terminal ->getHeight ()) ;
847+ return [ $ this ->terminal ->getWidth (), $ this ->terminal ->getHeight ()] ;
848848 }
849849
850850 /**
@@ -874,13 +874,13 @@ public function setTerminalDimensions($width, $height)
874874 */
875875 protected function configureIO (InputInterface $ input , OutputInterface $ output )
876876 {
877- if (true === $ input ->hasParameterOption (array ( '--ansi ' ) , true )) {
877+ if (true === $ input ->hasParameterOption ([ '--ansi ' ] , true )) {
878878 $ output ->setDecorated (true );
879- } elseif (true === $ input ->hasParameterOption (array ( '--no-ansi ' ) , true )) {
879+ } elseif (true === $ input ->hasParameterOption ([ '--no-ansi ' ] , true )) {
880880 $ output ->setDecorated (false );
881881 }
882882
883- if (true === $ input ->hasParameterOption (array ( '--no-interaction ' , '-n ' ) , true )) {
883+ if (true === $ input ->hasParameterOption ([ '--no-interaction ' , '-n ' ] , true )) {
884884 $ input ->setInteractive (false );
885885 } elseif (\function_exists ('posix_isatty ' )) {
886886 $ inputStream = null ;
@@ -908,7 +908,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
908908 default : $ shellVerbosity = 0 ; break ;
909909 }
910910
911- if (true === $ input ->hasParameterOption (array ( '--quiet ' , '-q ' ) , true )) {
911+ if (true === $ input ->hasParameterOption ([ '--quiet ' , '-q ' ] , true )) {
912912 $ output ->setVerbosity (OutputInterface::VERBOSITY_QUIET );
913913 $ shellVerbosity = -1 ;
914914 } else {
@@ -1021,7 +1021,7 @@ protected function getCommandName(InputInterface $input)
10211021 */
10221022 protected function getDefaultInputDefinition ()
10231023 {
1024- return new InputDefinition (array (
1024+ return new InputDefinition ([
10251025 new InputArgument ('command ' , InputArgument::REQUIRED , 'The command to execute ' ),
10261026
10271027 new InputOption ('--help ' , '-h ' , InputOption::VALUE_NONE , 'Display this help message ' ),
@@ -1031,7 +1031,7 @@ protected function getDefaultInputDefinition()
10311031 new InputOption ('--ansi ' , '' , InputOption::VALUE_NONE , 'Force ANSI output ' ),
10321032 new InputOption ('--no-ansi ' , '' , InputOption::VALUE_NONE , 'Disable ANSI output ' ),
10331033 new InputOption ('--no-interaction ' , '-n ' , InputOption::VALUE_NONE , 'Do not ask any interactive question ' ),
1034- ) );
1034+ ] );
10351035 }
10361036
10371037 /**
@@ -1041,7 +1041,7 @@ protected function getDefaultInputDefinition()
10411041 */
10421042 protected function getDefaultCommands ()
10431043 {
1044- return array ( new HelpCommand (), new ListCommand ()) ;
1044+ return [ new HelpCommand (), new ListCommand ()] ;
10451045 }
10461046
10471047 /**
@@ -1051,12 +1051,12 @@ protected function getDefaultCommands()
10511051 */
10521052 protected function getDefaultHelperSet ()
10531053 {
1054- return new HelperSet (array (
1054+ return new HelperSet ([
10551055 new FormatterHelper (),
10561056 new DebugFormatterHelper (),
10571057 new ProcessHelper (),
10581058 new QuestionHelper (),
1059- ) );
1059+ ] );
10601060 }
10611061
10621062 /**
@@ -1101,9 +1101,9 @@ public function extractNamespace($name, $limit = null)
11011101 private function findAlternatives ($ name , $ collection )
11021102 {
11031103 $ threshold = 1e3 ;
1104- $ alternatives = array () ;
1104+ $ alternatives = [] ;
11051105
1106- $ collectionParts = array () ;
1106+ $ collectionParts = [] ;
11071107 foreach ($ collection as $ item ) {
11081108 $ collectionParts [$ item ] = explode (': ' , $ item );
11091109 }
@@ -1180,7 +1180,7 @@ private function splitStringByWidth($string, $width)
11801180 }
11811181
11821182 $ utf8String = mb_convert_encoding ($ string , 'utf8 ' , $ encoding );
1183- $ lines = array () ;
1183+ $ lines = [] ;
11841184 $ line = '' ;
11851185 foreach (preg_split ('//u ' , $ utf8String ) as $ char ) {
11861186 // test if $char could be appended to current line
@@ -1211,7 +1211,7 @@ private function extractAllNamespaces($name)
12111211 {
12121212 // -1 as third argument is needed to skip the command short name when exploding
12131213 $ parts = explode (': ' , $ name , -1 );
1214- $ namespaces = array () ;
1214+ $ namespaces = [] ;
12151215
12161216 foreach ($ parts as $ part ) {
12171217 if (\count ($ namespaces )) {
0 commit comments