61
61
*/
62
62
class Application
63
63
{
64
- private $ commands = array () ;
64
+ private $ commands = [] ;
65
65
private $ wantHelps = false ;
66
66
private $ runningCommand ;
67
67
private $ name ;
@@ -196,17 +196,17 @@ public function run(InputInterface $input = null, OutputInterface $output = null
196
196
*/
197
197
public function doRun (InputInterface $ input , OutputInterface $ output )
198
198
{
199
- if (true === $ input ->hasParameterOption (array ( '--version ' , '-V ' ) , true )) {
199
+ if (true === $ input ->hasParameterOption ([ '--version ' , '-V ' ] , true )) {
200
200
$ output ->writeln ($ this ->getLongVersion ());
201
201
202
202
return 0 ;
203
203
}
204
204
205
205
$ name = $ this ->getCommandName ($ input );
206
- if (true === $ input ->hasParameterOption (array ( '--help ' , '-h ' ) , true )) {
206
+ if (true === $ input ->hasParameterOption ([ '--help ' , '-h ' ] , true )) {
207
207
if (!$ name ) {
208
208
$ name = 'help ' ;
209
- $ input = new ArrayInput (array ( 'command_name ' => $ this ->defaultCommand ) );
209
+ $ input = new ArrayInput ([ 'command_name ' => $ this ->defaultCommand ] );
210
210
} else {
211
211
$ this ->wantHelps = true ;
212
212
}
@@ -217,9 +217,9 @@ public function doRun(InputInterface $input, OutputInterface $output)
217
217
$ definition = $ this ->getDefinition ();
218
218
$ definition ->setArguments (array_merge (
219
219
$ definition ->getArguments (),
220
- array (
220
+ [
221
221
'command ' => new InputArgument ('command ' , InputArgument::OPTIONAL , $ definition ->getArgument ('command ' )->getDescription (), $ name ),
222
- )
222
+ ]
223
223
));
224
224
}
225
225
@@ -521,7 +521,7 @@ public function has($name)
521
521
*/
522
522
public function getNamespaces ()
523
523
{
524
- $ namespaces = array () ;
524
+ $ namespaces = [] ;
525
525
foreach ($ this ->all () as $ command ) {
526
526
$ namespaces = array_merge ($ namespaces , $ this ->extractAllNamespaces ($ command ->getName ()));
527
527
@@ -588,7 +588,7 @@ public function find($name)
588
588
{
589
589
$ this ->init ();
590
590
591
- $ aliases = array () ;
591
+ $ aliases = [] ;
592
592
$ allCommands = $ this ->commandLoader ? array_merge ($ this ->commandLoader ->getNames (), array_keys ($ this ->commands )) : array_keys ($ this ->commands );
593
593
$ expr = preg_replace_callback ('{([^:]+|)} ' , function ($ matches ) { return preg_quote ($ matches [1 ]).'[^:]* ' ; }, $ name );
594
594
$ commands = preg_grep ('{^ ' .$ expr .'} ' , $ allCommands );
@@ -681,7 +681,7 @@ public function all($namespace = null)
681
681
return $ commands ;
682
682
}
683
683
684
- $ commands = array () ;
684
+ $ commands = [] ;
685
685
foreach ($ this ->commands as $ name => $ command ) {
686
686
if ($ namespace === $ this ->extractNamespace ($ name , substr_count ($ namespace , ': ' ) + 1 )) {
687
687
$ commands [$ name ] = $ command ;
@@ -708,7 +708,7 @@ public function all($namespace = null)
708
708
*/
709
709
public static function getAbbreviations ($ names )
710
710
{
711
- $ abbrevs = array () ;
711
+ $ abbrevs = [] ;
712
712
foreach ($ names as $ name ) {
713
713
for ($ len = \strlen ($ name ); $ len > 0 ; --$ len ) {
714
714
$ abbrev = substr ($ name , 0 , $ len );
@@ -750,18 +750,18 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
750
750
if (\defined ('HHVM_VERSION ' ) && $ width > 1 << 31 ) {
751
751
$ width = 1 << 31 ;
752
752
}
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 ) {
755
755
foreach ($ this ->splitStringByWidth ($ line , $ width - 4 ) as $ line ) {
756
756
// pre-format lines to get the right string length
757
757
$ lineLength = Helper::strlen ($ line ) + 4 ;
758
- $ lines [] = array ( $ line , $ lineLength) ;
758
+ $ lines [] = [ $ line , $ lineLength] ;
759
759
760
760
$ len = max ($ lineLength , $ len );
761
761
}
762
762
}
763
763
764
- $ messages = array () ;
764
+ $ messages = [] ;
765
765
if (!$ e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $ output ->getVerbosity ()) {
766
766
$ messages [] = sprintf ('<comment>%s</comment> ' , OutputFormatter::escape (sprintf ('In %s line %s: ' , basename ($ e ->getFile ()) ?: 'n/a ' , $ e ->getLine () ?: 'n/a ' )));
767
767
}
@@ -783,12 +783,12 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
783
783
// exception related properties
784
784
$ trace = $ e ->getTrace ();
785
785
786
- array_unshift ($ trace , array (
786
+ array_unshift ($ trace , [
787
787
'function ' => '' ,
788
788
'file ' => $ e ->getFile () ?: 'n/a ' ,
789
789
'line ' => $ e ->getLine () ?: 'n/a ' ,
790
- 'args ' => array () ,
791
- ) );
790
+ 'args ' => [] ,
791
+ ] );
792
792
793
793
for ($ i = 0 , $ count = \count ($ trace ); $ i < $ count ; ++$ i ) {
794
794
$ class = isset ($ trace [$ i ]['class ' ]) ? $ trace [$ i ]['class ' ] : '' ;
@@ -844,7 +844,7 @@ public function getTerminalDimensions()
844
844
{
845
845
@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 );
846
846
847
- return array ( $ this ->terminal ->getWidth (), $ this ->terminal ->getHeight ()) ;
847
+ return [ $ this ->terminal ->getWidth (), $ this ->terminal ->getHeight ()] ;
848
848
}
849
849
850
850
/**
@@ -874,13 +874,13 @@ public function setTerminalDimensions($width, $height)
874
874
*/
875
875
protected function configureIO (InputInterface $ input , OutputInterface $ output )
876
876
{
877
- if (true === $ input ->hasParameterOption (array ( '--ansi ' ) , true )) {
877
+ if (true === $ input ->hasParameterOption ([ '--ansi ' ] , true )) {
878
878
$ output ->setDecorated (true );
879
- } elseif (true === $ input ->hasParameterOption (array ( '--no-ansi ' ) , true )) {
879
+ } elseif (true === $ input ->hasParameterOption ([ '--no-ansi ' ] , true )) {
880
880
$ output ->setDecorated (false );
881
881
}
882
882
883
- if (true === $ input ->hasParameterOption (array ( '--no-interaction ' , '-n ' ) , true )) {
883
+ if (true === $ input ->hasParameterOption ([ '--no-interaction ' , '-n ' ] , true )) {
884
884
$ input ->setInteractive (false );
885
885
} elseif (\function_exists ('posix_isatty ' )) {
886
886
$ inputStream = null ;
@@ -908,7 +908,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
908
908
default : $ shellVerbosity = 0 ; break ;
909
909
}
910
910
911
- if (true === $ input ->hasParameterOption (array ( '--quiet ' , '-q ' ) , true )) {
911
+ if (true === $ input ->hasParameterOption ([ '--quiet ' , '-q ' ] , true )) {
912
912
$ output ->setVerbosity (OutputInterface::VERBOSITY_QUIET );
913
913
$ shellVerbosity = -1 ;
914
914
} else {
@@ -1021,7 +1021,7 @@ protected function getCommandName(InputInterface $input)
1021
1021
*/
1022
1022
protected function getDefaultInputDefinition ()
1023
1023
{
1024
- return new InputDefinition (array (
1024
+ return new InputDefinition ([
1025
1025
new InputArgument ('command ' , InputArgument::REQUIRED , 'The command to execute ' ),
1026
1026
1027
1027
new InputOption ('--help ' , '-h ' , InputOption::VALUE_NONE , 'Display this help message ' ),
@@ -1031,7 +1031,7 @@ protected function getDefaultInputDefinition()
1031
1031
new InputOption ('--ansi ' , '' , InputOption::VALUE_NONE , 'Force ANSI output ' ),
1032
1032
new InputOption ('--no-ansi ' , '' , InputOption::VALUE_NONE , 'Disable ANSI output ' ),
1033
1033
new InputOption ('--no-interaction ' , '-n ' , InputOption::VALUE_NONE , 'Do not ask any interactive question ' ),
1034
- ) );
1034
+ ] );
1035
1035
}
1036
1036
1037
1037
/**
@@ -1041,7 +1041,7 @@ protected function getDefaultInputDefinition()
1041
1041
*/
1042
1042
protected function getDefaultCommands ()
1043
1043
{
1044
- return array ( new HelpCommand (), new ListCommand ()) ;
1044
+ return [ new HelpCommand (), new ListCommand ()] ;
1045
1045
}
1046
1046
1047
1047
/**
@@ -1051,12 +1051,12 @@ protected function getDefaultCommands()
1051
1051
*/
1052
1052
protected function getDefaultHelperSet ()
1053
1053
{
1054
- return new HelperSet (array (
1054
+ return new HelperSet ([
1055
1055
new FormatterHelper (),
1056
1056
new DebugFormatterHelper (),
1057
1057
new ProcessHelper (),
1058
1058
new QuestionHelper (),
1059
- ) );
1059
+ ] );
1060
1060
}
1061
1061
1062
1062
/**
@@ -1101,9 +1101,9 @@ public function extractNamespace($name, $limit = null)
1101
1101
private function findAlternatives ($ name , $ collection )
1102
1102
{
1103
1103
$ threshold = 1e3 ;
1104
- $ alternatives = array () ;
1104
+ $ alternatives = [] ;
1105
1105
1106
- $ collectionParts = array () ;
1106
+ $ collectionParts = [] ;
1107
1107
foreach ($ collection as $ item ) {
1108
1108
$ collectionParts [$ item ] = explode (': ' , $ item );
1109
1109
}
@@ -1180,7 +1180,7 @@ private function splitStringByWidth($string, $width)
1180
1180
}
1181
1181
1182
1182
$ utf8String = mb_convert_encoding ($ string , 'utf8 ' , $ encoding );
1183
- $ lines = array () ;
1183
+ $ lines = [] ;
1184
1184
$ line = '' ;
1185
1185
foreach (preg_split ('//u ' , $ utf8String ) as $ char ) {
1186
1186
// test if $char could be appended to current line
@@ -1211,7 +1211,7 @@ private function extractAllNamespaces($name)
1211
1211
{
1212
1212
// -1 as third argument is needed to skip the command short name when exploding
1213
1213
$ parts = explode (': ' , $ name , -1 );
1214
- $ namespaces = array () ;
1214
+ $ namespaces = [] ;
1215
1215
1216
1216
foreach ($ parts as $ part ) {
1217
1217
if (\count ($ namespaces )) {
0 commit comments