62
62
*/
63
63
class Application
64
64
{
65
- private $ commands = array () ;
65
+ private $ commands = [] ;
66
66
private $ wantHelps = false ;
67
67
private $ runningCommand ;
68
68
private $ name ;
@@ -193,17 +193,17 @@ public function run(InputInterface $input = null, OutputInterface $output = null
193
193
*/
194
194
public function doRun (InputInterface $ input , OutputInterface $ output )
195
195
{
196
- if (true === $ input ->hasParameterOption (array ( '--version ' , '-V ' ) , true )) {
196
+ if (true === $ input ->hasParameterOption ([ '--version ' , '-V ' ] , true )) {
197
197
$ output ->writeln ($ this ->getLongVersion ());
198
198
199
199
return 0 ;
200
200
}
201
201
202
202
$ name = $ this ->getCommandName ($ input );
203
- if (true === $ input ->hasParameterOption (array ( '--help ' , '-h ' ) , true )) {
203
+ if (true === $ input ->hasParameterOption ([ '--help ' , '-h ' ] , true )) {
204
204
if (!$ name ) {
205
205
$ name = 'help ' ;
206
- $ input = new ArrayInput (array ( 'command_name ' => $ this ->defaultCommand ) );
206
+ $ input = new ArrayInput ([ 'command_name ' => $ this ->defaultCommand ] );
207
207
} else {
208
208
$ this ->wantHelps = true ;
209
209
}
@@ -214,9 +214,9 @@ public function doRun(InputInterface $input, OutputInterface $output)
214
214
$ definition = $ this ->getDefinition ();
215
215
$ definition ->setArguments (array_merge (
216
216
$ definition ->getArguments (),
217
- array (
217
+ [
218
218
'command ' => new InputArgument ('command ' , InputArgument::OPTIONAL , $ definition ->getArgument ('command ' )->getDescription (), $ name ),
219
- )
219
+ ]
220
220
));
221
221
}
222
222
@@ -535,7 +535,7 @@ public function has($name)
535
535
*/
536
536
public function getNamespaces ()
537
537
{
538
- $ namespaces = array () ;
538
+ $ namespaces = [] ;
539
539
foreach ($ this ->all () as $ command ) {
540
540
$ namespaces = array_merge ($ namespaces , $ this ->extractAllNamespaces ($ command ->getName ()));
541
541
@@ -602,7 +602,7 @@ public function find($name)
602
602
{
603
603
$ this ->init ();
604
604
605
- $ aliases = array () ;
605
+ $ aliases = [] ;
606
606
$ allCommands = $ this ->commandLoader ? array_merge ($ this ->commandLoader ->getNames (), array_keys ($ this ->commands )) : array_keys ($ this ->commands );
607
607
$ expr = preg_replace_callback ('{([^:]+|)} ' , function ($ matches ) { return preg_quote ($ matches [1 ]).'[^:]* ' ; }, $ name );
608
608
$ commands = preg_grep ('{^ ' .$ expr .'} ' , $ allCommands );
@@ -695,7 +695,7 @@ public function all($namespace = null)
695
695
return $ commands ;
696
696
}
697
697
698
- $ commands = array () ;
698
+ $ commands = [] ;
699
699
foreach ($ this ->commands as $ name => $ command ) {
700
700
if ($ namespace === $ this ->extractNamespace ($ name , substr_count ($ namespace , ': ' ) + 1 )) {
701
701
$ commands [$ name ] = $ command ;
@@ -722,7 +722,7 @@ public function all($namespace = null)
722
722
*/
723
723
public static function getAbbreviations ($ names )
724
724
{
725
- $ abbrevs = array () ;
725
+ $ abbrevs = [] ;
726
726
foreach ($ names as $ name ) {
727
727
for ($ len = \strlen ($ name ); $ len > 0 ; --$ len ) {
728
728
$ abbrev = substr ($ name , 0 , $ len );
@@ -760,18 +760,18 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
760
760
}
761
761
762
762
$ 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 ) {
765
765
foreach ($ this ->splitStringByWidth ($ line , $ width - 4 ) as $ line ) {
766
766
// pre-format lines to get the right string length
767
767
$ lineLength = Helper::strlen ($ line ) + 4 ;
768
- $ lines [] = array ( $ line , $ lineLength) ;
768
+ $ lines [] = [ $ line , $ lineLength] ;
769
769
770
770
$ len = max ($ lineLength , $ len );
771
771
}
772
772
}
773
773
774
- $ messages = array () ;
774
+ $ messages = [] ;
775
775
if (!$ e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $ output ->getVerbosity ()) {
776
776
$ messages [] = sprintf ('<comment>%s</comment> ' , OutputFormatter::escape (sprintf ('In %s line %s: ' , basename ($ e ->getFile ()) ?: 'n/a ' , $ e ->getLine () ?: 'n/a ' )));
777
777
}
@@ -793,12 +793,12 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
793
793
// exception related properties
794
794
$ trace = $ e ->getTrace ();
795
795
796
- array_unshift ($ trace , array (
796
+ array_unshift ($ trace , [
797
797
'function ' => '' ,
798
798
'file ' => $ e ->getFile () ?: 'n/a ' ,
799
799
'line ' => $ e ->getLine () ?: 'n/a ' ,
800
- 'args ' => array () ,
801
- ) );
800
+ 'args ' => [] ,
801
+ ] );
802
802
803
803
for ($ i = 0 , $ count = \count ($ trace ); $ i < $ count ; ++$ i ) {
804
804
$ class = isset ($ trace [$ i ]['class ' ]) ? $ trace [$ i ]['class ' ] : '' ;
@@ -820,13 +820,13 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
820
820
*/
821
821
protected function configureIO (InputInterface $ input , OutputInterface $ output )
822
822
{
823
- if (true === $ input ->hasParameterOption (array ( '--ansi ' ) , true )) {
823
+ if (true === $ input ->hasParameterOption ([ '--ansi ' ] , true )) {
824
824
$ output ->setDecorated (true );
825
- } elseif (true === $ input ->hasParameterOption (array ( '--no-ansi ' ) , true )) {
825
+ } elseif (true === $ input ->hasParameterOption ([ '--no-ansi ' ] , true )) {
826
826
$ output ->setDecorated (false );
827
827
}
828
828
829
- if (true === $ input ->hasParameterOption (array ( '--no-interaction ' , '-n ' ) , true )) {
829
+ if (true === $ input ->hasParameterOption ([ '--no-interaction ' , '-n ' ] , true )) {
830
830
$ input ->setInteractive (false );
831
831
} elseif (\function_exists ('posix_isatty ' )) {
832
832
$ inputStream = null ;
@@ -848,7 +848,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
848
848
default : $ shellVerbosity = 0 ; break ;
849
849
}
850
850
851
- if (true === $ input ->hasParameterOption (array ( '--quiet ' , '-q ' ) , true )) {
851
+ if (true === $ input ->hasParameterOption ([ '--quiet ' , '-q ' ] , true )) {
852
852
$ output ->setVerbosity (OutputInterface::VERBOSITY_QUIET );
853
853
$ shellVerbosity = -1 ;
854
854
} else {
@@ -949,7 +949,7 @@ protected function getCommandName(InputInterface $input)
949
949
*/
950
950
protected function getDefaultInputDefinition ()
951
951
{
952
- return new InputDefinition (array (
952
+ return new InputDefinition ([
953
953
new InputArgument ('command ' , InputArgument::REQUIRED , 'The command to execute ' ),
954
954
955
955
new InputOption ('--help ' , '-h ' , InputOption::VALUE_NONE , 'Display this help message ' ),
@@ -959,7 +959,7 @@ protected function getDefaultInputDefinition()
959
959
new InputOption ('--ansi ' , '' , InputOption::VALUE_NONE , 'Force ANSI output ' ),
960
960
new InputOption ('--no-ansi ' , '' , InputOption::VALUE_NONE , 'Disable ANSI output ' ),
961
961
new InputOption ('--no-interaction ' , '-n ' , InputOption::VALUE_NONE , 'Do not ask any interactive question ' ),
962
- ) );
962
+ ] );
963
963
}
964
964
965
965
/**
@@ -969,7 +969,7 @@ protected function getDefaultInputDefinition()
969
969
*/
970
970
protected function getDefaultCommands ()
971
971
{
972
- return array ( new HelpCommand (), new ListCommand ()) ;
972
+ return [ new HelpCommand (), new ListCommand ()] ;
973
973
}
974
974
975
975
/**
@@ -979,12 +979,12 @@ protected function getDefaultCommands()
979
979
*/
980
980
protected function getDefaultHelperSet ()
981
981
{
982
- return new HelperSet (array (
982
+ return new HelperSet ([
983
983
new FormatterHelper (),
984
984
new DebugFormatterHelper (),
985
985
new ProcessHelper (),
986
986
new QuestionHelper (),
987
- ) );
987
+ ] );
988
988
}
989
989
990
990
/**
@@ -1029,9 +1029,9 @@ public function extractNamespace($name, $limit = null)
1029
1029
private function findAlternatives ($ name , $ collection )
1030
1030
{
1031
1031
$ threshold = 1e3 ;
1032
- $ alternatives = array () ;
1032
+ $ alternatives = [] ;
1033
1033
1034
- $ collectionParts = array () ;
1034
+ $ collectionParts = [] ;
1035
1035
foreach ($ collection as $ item ) {
1036
1036
$ collectionParts [$ item ] = explode (': ' , $ item );
1037
1037
}
@@ -1108,7 +1108,7 @@ private function splitStringByWidth($string, $width)
1108
1108
}
1109
1109
1110
1110
$ utf8String = mb_convert_encoding ($ string , 'utf8 ' , $ encoding );
1111
- $ lines = array () ;
1111
+ $ lines = [] ;
1112
1112
$ line = '' ;
1113
1113
foreach (preg_split ('//u ' , $ utf8String ) as $ char ) {
1114
1114
// test if $char could be appended to current line
@@ -1139,7 +1139,7 @@ private function extractAllNamespaces($name)
1139
1139
{
1140
1140
// -1 as third argument is needed to skip the command short name when exploding
1141
1141
$ parts = explode (': ' , $ name , -1 );
1142
- $ namespaces = array () ;
1142
+ $ namespaces = [] ;
1143
1143
1144
1144
foreach ($ parts as $ part ) {
1145
1145
if (\count ($ namespaces )) {
0 commit comments