Skip to content

Commit 0dfa0f7

Browse files
committed
switched array() to []
1 parent f76eed0 commit 0dfa0f7

File tree

97 files changed

+1525
-1525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1525
-1525
lines changed

Application.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
*/
6262
class 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)) {

Command/Command.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Command
3737
private $application;
3838
private $name;
3939
private $processTitle;
40-
private $aliases = array();
40+
private $aliases = [];
4141
private $definition;
4242
private $hidden = false;
4343
private $help;
@@ -46,8 +46,8 @@ class Command
4646
private $applicationDefinitionMerged = false;
4747
private $applicationDefinitionMergedWithArgs = false;
4848
private $code;
49-
private $synopsis = array();
50-
private $usages = array();
49+
private $synopsis = [];
50+
private $usages = [];
5151
private $helperSet;
5252

5353
/**
@@ -535,14 +535,14 @@ public function getProcessedHelp()
535535
$name = $this->name;
536536
$isSingleCommand = $this->application && $this->application->isSingleCommand();
537537

538-
$placeholders = array(
538+
$placeholders = [
539539
'%command.name%',
540540
'%command.full_name%',
541-
);
542-
$replacements = array(
541+
];
542+
$replacements = [
543543
$name,
544544
$isSingleCommand ? $_SERVER['PHP_SELF'] : $_SERVER['PHP_SELF'].' '.$name,
545-
);
545+
];
546546

547547
return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
548548
}

Command/HelpCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ protected function configure()
3535

3636
$this
3737
->setName('help')
38-
->setDefinition(array(
38+
->setDefinition([
3939
new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
4040
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
4141
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
42-
))
42+
])
4343
->setDescription('Displays help for a command')
4444
->setHelp(<<<'EOF'
4545
The <info>%command.name%</info> command displays help for a given command:
@@ -71,10 +71,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
7171
}
7272

7373
$helper = new DescriptorHelper();
74-
$helper->describe($output, $this->command, array(
74+
$helper->describe($output, $this->command, [
7575
'format' => $input->getOption('format'),
7676
'raw_text' => $input->getOption('raw'),
77-
));
77+
]);
7878

7979
$this->command = null;
8080
}

Command/ListCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,22 @@ public function getNativeDefinition()
6969
protected function execute(InputInterface $input, OutputInterface $output)
7070
{
7171
$helper = new DescriptorHelper();
72-
$helper->describe($output, $this->getApplication(), array(
72+
$helper->describe($output, $this->getApplication(), [
7373
'format' => $input->getOption('format'),
7474
'raw_text' => $input->getOption('raw'),
7575
'namespace' => $input->getArgument('namespace'),
76-
));
76+
]);
7777
}
7878

7979
/**
8080
* {@inheritdoc}
8181
*/
8282
private function createDefinition()
8383
{
84-
return new InputDefinition(array(
84+
return new InputDefinition([
8585
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
8686
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
8787
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
88-
));
88+
]);
8989
}
9090
}

DependencyInjection/AddConsoleCommandPass.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public function __construct($commandLoaderServiceId = 'console.command_loader',
3838
public function process(ContainerBuilder $container)
3939
{
4040
$commandServices = $container->findTaggedServiceIds($this->commandTag, true);
41-
$lazyCommandMap = array();
42-
$lazyCommandRefs = array();
43-
$serviceIds = array();
44-
$lazyServiceIds = array();
41+
$lazyCommandMap = [];
42+
$lazyCommandRefs = [];
43+
$serviceIds = [];
44+
$lazyServiceIds = [];
4545

4646
foreach ($commandServices as $id => $tags) {
4747
$definition = $container->getDefinition($id);
@@ -79,7 +79,7 @@ public function process(ContainerBuilder $container)
7979
unset($tags[0]);
8080
$lazyCommandMap[$commandName] = $id;
8181
$lazyCommandRefs[$id] = new TypedReference($id, $class);
82-
$aliases = array();
82+
$aliases = [];
8383

8484
foreach ($tags as $tag) {
8585
if (isset($tag['command'])) {
@@ -88,17 +88,17 @@ public function process(ContainerBuilder $container)
8888
}
8989
}
9090

91-
$definition->addMethodCall('setName', array($commandName));
91+
$definition->addMethodCall('setName', [$commandName]);
9292

9393
if ($aliases) {
94-
$definition->addMethodCall('setAliases', array($aliases));
94+
$definition->addMethodCall('setAliases', [$aliases]);
9595
}
9696
}
9797

9898
$container
9999
->register($this->commandLoaderServiceId, ContainerCommandLoader::class)
100100
->setPublic(true)
101-
->setArguments(array(ServiceLocatorTagPass::register($container, $lazyCommandRefs), $lazyCommandMap));
101+
->setArguments([ServiceLocatorTagPass::register($container, $lazyCommandRefs), $lazyCommandMap]);
102102

103103
$container->setParameter('console.command.ids', $serviceIds);
104104
$container->setParameter('console.lazy_command.ids', $lazyServiceIds);

Descriptor/ApplicationDescription.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ public function getCommand($name)
9797

9898
private function inspectApplication()
9999
{
100-
$this->commands = array();
101-
$this->namespaces = array();
100+
$this->commands = [];
101+
$this->namespaces = [];
102102

103103
$all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
104104
foreach ($this->sortCommands($all) as $namespace => $commands) {
105-
$names = array();
105+
$names = [];
106106

107107
/** @var Command $command */
108108
foreach ($commands as $name => $command) {
@@ -119,7 +119,7 @@ private function inspectApplication()
119119
$names[] = $name;
120120
}
121121

122-
$this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names);
122+
$this->namespaces[$namespace] = ['id' => $namespace, 'commands' => $names];
123123
}
124124
}
125125

@@ -128,8 +128,8 @@ private function inspectApplication()
128128
*/
129129
private function sortCommands(array $commands)
130130
{
131-
$namespacedCommands = array();
132-
$globalCommands = array();
131+
$namespacedCommands = [];
132+
$globalCommands = [];
133133
foreach ($commands as $name => $command) {
134134
$key = $this->application->extractNamespace($name, 1);
135135
if (!$key) {

0 commit comments

Comments
 (0)