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 );
@@ -768,18 +768,18 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
768
768
}
769
769
770
770
$ 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 ) {
773
773
foreach ($ this ->splitStringByWidth ($ line , $ width - 4 ) as $ line ) {
774
774
// pre-format lines to get the right string length
775
775
$ lineLength = Helper::strlen ($ line ) + 4 ;
776
- $ lines [] = array ( $ line , $ lineLength) ;
776
+ $ lines [] = [ $ line , $ lineLength] ;
777
777
778
778
$ len = max ($ lineLength , $ len );
779
779
}
780
780
}
781
781
782
- $ messages = array () ;
782
+ $ messages = [] ;
783
783
if (!$ e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $ output ->getVerbosity ()) {
784
784
$ messages [] = sprintf ('<comment>%s</comment> ' , OutputFormatter::escape (sprintf ('In %s line %s: ' , basename ($ e ->getFile ()) ?: 'n/a ' , $ e ->getLine () ?: 'n/a ' )));
785
785
}
@@ -801,12 +801,12 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
801
801
// exception related properties
802
802
$ trace = $ e ->getTrace ();
803
803
804
- array_unshift ($ trace , array (
804
+ array_unshift ($ trace , [
805
805
'function ' => '' ,
806
806
'file ' => $ e ->getFile () ?: 'n/a ' ,
807
807
'line ' => $ e ->getLine () ?: 'n/a ' ,
808
- 'args ' => array () ,
809
- ) );
808
+ 'args ' => [] ,
809
+ ] );
810
810
811
811
for ($ i = 0 , $ count = \count ($ trace ); $ i < $ count ; ++$ i ) {
812
812
$ class = isset ($ trace [$ i ]['class ' ]) ? $ trace [$ i ]['class ' ] : '' ;
@@ -828,13 +828,13 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
828
828
*/
829
829
protected function configureIO (InputInterface $ input , OutputInterface $ output )
830
830
{
831
- if (true === $ input ->hasParameterOption (array ( '--ansi ' ) , true )) {
831
+ if (true === $ input ->hasParameterOption ([ '--ansi ' ] , true )) {
832
832
$ output ->setDecorated (true );
833
- } elseif (true === $ input ->hasParameterOption (array ( '--no-ansi ' ) , true )) {
833
+ } elseif (true === $ input ->hasParameterOption ([ '--no-ansi ' ] , true )) {
834
834
$ output ->setDecorated (false );
835
835
}
836
836
837
- if (true === $ input ->hasParameterOption (array ( '--no-interaction ' , '-n ' ) , true )) {
837
+ if (true === $ input ->hasParameterOption ([ '--no-interaction ' , '-n ' ] , true )) {
838
838
$ input ->setInteractive (false );
839
839
} elseif (\function_exists ('posix_isatty ' )) {
840
840
$ inputStream = null ;
@@ -856,7 +856,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
856
856
default : $ shellVerbosity = 0 ; break ;
857
857
}
858
858
859
- if (true === $ input ->hasParameterOption (array ( '--quiet ' , '-q ' ) , true )) {
859
+ if (true === $ input ->hasParameterOption ([ '--quiet ' , '-q ' ] , true )) {
860
860
$ output ->setVerbosity (OutputInterface::VERBOSITY_QUIET );
861
861
$ shellVerbosity = -1 ;
862
862
} else {
@@ -957,7 +957,7 @@ protected function getCommandName(InputInterface $input)
957
957
*/
958
958
protected function getDefaultInputDefinition ()
959
959
{
960
- return new InputDefinition (array (
960
+ return new InputDefinition ([
961
961
new InputArgument ('command ' , InputArgument::REQUIRED , 'The command to execute ' ),
962
962
963
963
new InputOption ('--help ' , '-h ' , InputOption::VALUE_NONE , 'Display this help message ' ),
@@ -967,7 +967,7 @@ protected function getDefaultInputDefinition()
967
967
new InputOption ('--ansi ' , '' , InputOption::VALUE_NONE , 'Force ANSI output ' ),
968
968
new InputOption ('--no-ansi ' , '' , InputOption::VALUE_NONE , 'Disable ANSI output ' ),
969
969
new InputOption ('--no-interaction ' , '-n ' , InputOption::VALUE_NONE , 'Do not ask any interactive question ' ),
970
- ) );
970
+ ] );
971
971
}
972
972
973
973
/**
@@ -977,7 +977,7 @@ protected function getDefaultInputDefinition()
977
977
*/
978
978
protected function getDefaultCommands ()
979
979
{
980
- return array ( new HelpCommand (), new ListCommand ()) ;
980
+ return [ new HelpCommand (), new ListCommand ()] ;
981
981
}
982
982
983
983
/**
@@ -987,12 +987,12 @@ protected function getDefaultCommands()
987
987
*/
988
988
protected function getDefaultHelperSet ()
989
989
{
990
- return new HelperSet (array (
990
+ return new HelperSet ([
991
991
new FormatterHelper (),
992
992
new DebugFormatterHelper (),
993
993
new ProcessHelper (),
994
994
new QuestionHelper (),
995
- ) );
995
+ ] );
996
996
}
997
997
998
998
/**
@@ -1037,9 +1037,9 @@ public function extractNamespace($name, $limit = null)
1037
1037
private function findAlternatives ($ name , $ collection )
1038
1038
{
1039
1039
$ threshold = 1e3 ;
1040
- $ alternatives = array () ;
1040
+ $ alternatives = [] ;
1041
1041
1042
- $ collectionParts = array () ;
1042
+ $ collectionParts = [] ;
1043
1043
foreach ($ collection as $ item ) {
1044
1044
$ collectionParts [$ item ] = explode (': ' , $ item );
1045
1045
}
@@ -1116,7 +1116,7 @@ private function splitStringByWidth($string, $width)
1116
1116
}
1117
1117
1118
1118
$ utf8String = mb_convert_encoding ($ string , 'utf8 ' , $ encoding );
1119
- $ lines = array () ;
1119
+ $ lines = [] ;
1120
1120
$ line = '' ;
1121
1121
foreach (preg_split ('//u ' , $ utf8String ) as $ char ) {
1122
1122
// test if $char could be appended to current line
@@ -1147,7 +1147,7 @@ private function extractAllNamespaces($name)
1147
1147
{
1148
1148
// -1 as third argument is needed to skip the command short name when exploding
1149
1149
$ parts = explode (': ' , $ name , -1 );
1150
- $ namespaces = array () ;
1150
+ $ namespaces = [] ;
1151
1151
1152
1152
foreach ($ parts as $ part ) {
1153
1153
if (\count ($ namespaces )) {
0 commit comments