Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a3b601

Browse files
committed
switched array() to []
1 parent 5f35706 commit 9a3b601

89 files changed

Lines changed: 709 additions & 709 deletions

File tree

Some content is hidden

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

Catalogue/AbstractOperation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function __construct(MessageCatalogueInterface $source, MessageCatalogueI
7070
$this->source = $source;
7171
$this->target = $target;
7272
$this->result = new MessageCatalogue($source->getLocale());
73-
$this->messages = array();
73+
$this->messages = [];
7474
}
7575

7676
/**

Catalogue/MergeOperation.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ class MergeOperation extends AbstractOperation
2727
*/
2828
protected function processDomain($domain)
2929
{
30-
$this->messages[$domain] = array(
31-
'all' => array(),
32-
'new' => array(),
33-
'obsolete' => array(),
34-
);
30+
$this->messages[$domain] = [
31+
'all' => [],
32+
'new' => [],
33+
'obsolete' => [],
34+
];
3535

3636
foreach ($this->source->all($domain) as $id => $message) {
3737
$this->messages[$domain]['all'][$id] = $message;
38-
$this->result->add(array($id => $message), $domain);
38+
$this->result->add([$id => $message], $domain);
3939
if (null !== $keyMetadata = $this->source->getMetadata($id, $domain)) {
4040
$this->result->setMetadata($id, $keyMetadata, $domain);
4141
}
@@ -45,7 +45,7 @@ protected function processDomain($domain)
4545
if (!$this->source->has($id, $domain)) {
4646
$this->messages[$domain]['all'][$id] = $message;
4747
$this->messages[$domain]['new'][$id] = $message;
48-
$this->result->add(array($id => $message), $domain);
48+
$this->result->add([$id => $message], $domain);
4949
if (null !== $keyMetadata = $this->target->getMetadata($id, $domain)) {
5050
$this->result->setMetadata($id, $keyMetadata, $domain);
5151
}

Catalogue/TargetOperation.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ class TargetOperation extends AbstractOperation
2828
*/
2929
protected function processDomain($domain)
3030
{
31-
$this->messages[$domain] = array(
32-
'all' => array(),
33-
'new' => array(),
34-
'obsolete' => array(),
35-
);
31+
$this->messages[$domain] = [
32+
'all' => [],
33+
'new' => [],
34+
'obsolete' => [],
35+
];
3636

3737
// For 'all' messages, the code can't be simplified as ``$this->messages[$domain]['all'] = $target->all($domain);``,
3838
// because doing so will drop messages like {x: x ∈ source ∧ x ∉ target.all ∧ x ∈ target.fallback}
@@ -46,7 +46,7 @@ protected function processDomain($domain)
4646
foreach ($this->source->all($domain) as $id => $message) {
4747
if ($this->target->has($id, $domain)) {
4848
$this->messages[$domain]['all'][$id] = $message;
49-
$this->result->add(array($id => $message), $domain);
49+
$this->result->add([$id => $message], $domain);
5050
if (null !== $keyMetadata = $this->source->getMetadata($id, $domain)) {
5151
$this->result->setMetadata($id, $keyMetadata, $domain);
5252
}
@@ -59,7 +59,7 @@ protected function processDomain($domain)
5959
if (!$this->source->has($id, $domain)) {
6060
$this->messages[$domain]['all'][$id] = $message;
6161
$this->messages[$domain]['new'][$id] = $message;
62-
$this->result->add(array($id => $message), $domain);
62+
$this->result->add([$id => $message], $domain);
6363
if (null !== $keyMetadata = $this->target->getMetadata($id, $domain)) {
6464
$this->result->setMetadata($id, $keyMetadata, $domain);
6565
}

Command/XliffLintCommand.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
8585
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
8686
}
8787

88-
return $this->display($io, array($this->validate($stdin)));
88+
return $this->display($io, [$this->validate($stdin)]);
8989
}
9090

9191
if (!$this->isReadable($filename)) {
9292
throw new RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));
9393
}
9494

95-
$filesInfo = array();
95+
$filesInfo = [];
9696
foreach ($this->getFiles($filename) as $file) {
9797
$filesInfo[] = $this->validate(file_get_contents($file), $file);
9898
}
@@ -104,29 +104,29 @@ private function validate($content, $file = null)
104104
{
105105
// Avoid: Warning DOMDocument::loadXML(): Empty string supplied as input
106106
if ('' === trim($content)) {
107-
return array('file' => $file, 'valid' => true);
107+
return ['file' => $file, 'valid' => true];
108108
}
109109

110110
libxml_use_internal_errors(true);
111111

112112
$document = new \DOMDocument();
113113
$document->loadXML($content);
114114
if ($document->schemaValidate(__DIR__.'/../Resources/schemas/xliff-core-1.2-strict.xsd')) {
115-
return array('file' => $file, 'valid' => true);
115+
return ['file' => $file, 'valid' => true];
116116
}
117117

118118
$errorMessages = array_map(function ($error) {
119-
return array(
119+
return [
120120
'line' => $error->line,
121121
'column' => $error->column,
122122
'message' => trim($error->message),
123-
);
123+
];
124124
}, libxml_get_errors());
125125

126126
libxml_clear_errors();
127127
libxml_use_internal_errors(false);
128128

129-
return array('file' => $file, 'valid' => false, 'messages' => $errorMessages);
129+
return ['file' => $file, 'valid' => false, 'messages' => $errorMessages];
130130
}
131131

132132
private function display(SymfonyStyle $io, array $files)
@@ -193,7 +193,7 @@ private function getFiles($fileOrDirectory)
193193
}
194194

195195
foreach ($this->getDirectoryIterator($fileOrDirectory) as $file) {
196-
if (!\in_array($file->getExtension(), array('xlf', 'xliff'))) {
196+
if (!\in_array($file->getExtension(), ['xlf', 'xliff'])) {
197197
continue;
198198
}
199199

DataCollector/TranslationDataCollector.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ public function collect(Request $request, Response $response, \Exception $except
5757
*/
5858
public function reset()
5959
{
60-
$this->data = array();
60+
$this->data = [];
6161
}
6262

6363
/**
6464
* @return array
6565
*/
6666
public function getMessages()
6767
{
68-
return isset($this->data['messages']) ? $this->data['messages'] : array();
68+
return isset($this->data['messages']) ? $this->data['messages'] : [];
6969
}
7070

7171
/**
@@ -99,7 +99,7 @@ public function getLocale()
9999

100100
public function getFallbackLocales()
101101
{
102-
return (isset($this->data['fallback_locales']) && \count($this->data['fallback_locales']) > 0) ? $this->data['fallback_locales'] : array();
102+
return (isset($this->data['fallback_locales']) && \count($this->data['fallback_locales']) > 0) ? $this->data['fallback_locales'] : [];
103103
}
104104

105105
/**
@@ -112,13 +112,13 @@ public function getName()
112112

113113
private function sanitizeCollectedMessages($messages)
114114
{
115-
$result = array();
115+
$result = [];
116116
foreach ($messages as $key => $message) {
117117
$messageId = $message['locale'].$message['domain'].$message['id'];
118118

119119
if (!isset($result[$messageId])) {
120120
$message['count'] = 1;
121-
$message['parameters'] = !empty($message['parameters']) ? array($message['parameters']) : array();
121+
$message['parameters'] = !empty($message['parameters']) ? [$message['parameters']] : [];
122122
$messages[$key]['translation'] = $this->sanitizeString($message['translation']);
123123
$result[$messageId] = $message;
124124
} else {
@@ -137,11 +137,11 @@ private function sanitizeCollectedMessages($messages)
137137

138138
private function computeCount($messages)
139139
{
140-
$count = array(
140+
$count = [
141141
DataCollectorTranslator::MESSAGE_DEFINED => 0,
142142
DataCollectorTranslator::MESSAGE_MISSING => 0,
143143
DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK => 0,
144-
);
144+
];
145145

146146
foreach ($messages as $message) {
147147
++$count[$message['state']];

DataCollectorTranslator.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
2727
*/
2828
private $translator;
2929

30-
private $messages = array();
30+
private $messages = [];
3131

3232
/**
3333
* @param TranslatorInterface $translator The translator must implement TranslatorBagInterface
@@ -44,7 +44,7 @@ public function __construct(TranslatorInterface $translator)
4444
/**
4545
* {@inheritdoc}
4646
*/
47-
public function trans($id, array $parameters = array(), $domain = null, $locale = null)
47+
public function trans($id, array $parameters = [], $domain = null, $locale = null)
4848
{
4949
$trans = $this->translator->trans($id, $parameters, $domain, $locale);
5050
$this->collectMessage($locale, $domain, $id, $trans, $parameters);
@@ -55,7 +55,7 @@ public function trans($id, array $parameters = array(), $domain = null, $locale
5555
/**
5656
* {@inheritdoc}
5757
*/
58-
public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null)
58+
public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
5959
{
6060
$trans = $this->translator->transChoice($id, $number, $parameters, $domain, $locale);
6161
$this->collectMessage($locale, $domain, $id, $trans, $parameters, $number);
@@ -98,15 +98,15 @@ public function getFallbackLocales()
9898
return $this->translator->getFallbackLocales();
9999
}
100100

101-
return array();
101+
return [];
102102
}
103103

104104
/**
105105
* Passes through all unknown calls onto the translator object.
106106
*/
107107
public function __call($method, $args)
108108
{
109-
return \call_user_func_array(array($this->translator, $method), $args);
109+
return \call_user_func_array([$this->translator, $method], $args);
110110
}
111111

112112
/**
@@ -125,7 +125,7 @@ public function getCollectedMessages()
125125
* @param array|null $parameters
126126
* @param int|null $number
127127
*/
128-
private function collectMessage($locale, $domain, $id, $translation, $parameters = array(), $number = null)
128+
private function collectMessage($locale, $domain, $id, $translation, $parameters = [], $number = null)
129129
{
130130
if (null === $domain) {
131131
$domain = 'messages';
@@ -152,14 +152,14 @@ private function collectMessage($locale, $domain, $id, $translation, $parameters
152152
$state = self::MESSAGE_MISSING;
153153
}
154154

155-
$this->messages[] = array(
155+
$this->messages[] = [
156156
'locale' => $locale,
157157
'domain' => $domain,
158158
'id' => $id,
159159
'translation' => $translation,
160160
'parameters' => $parameters,
161161
'transChoiceNumber' => $number,
162162
'state' => $state,
163-
);
163+
];
164164
}
165165
}

DependencyInjection/TranslationDumperPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function process(ContainerBuilder $container)
3838
$definition = $container->getDefinition($this->writerServiceId);
3939

4040
foreach ($container->findTaggedServiceIds($this->dumperTag, true) as $id => $attributes) {
41-
$definition->addMethodCall('addDumper', array($attributes[0]['alias'], new Reference($id)));
41+
$definition->addMethodCall('addDumper', [$attributes[0]['alias'], new Reference($id)]);
4242
}
4343
}
4444
}

DependencyInjection/TranslationExtractorPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function process(ContainerBuilder $container)
4343
throw new RuntimeException(sprintf('The alias for the tag "translation.extractor" of service "%s" must be set.', $id));
4444
}
4545

46-
$definition->addMethodCall('addExtractor', array($attributes[0]['alias'], new Reference($id)));
46+
$definition->addMethodCall('addExtractor', [$attributes[0]['alias'], new Reference($id)]);
4747
}
4848
}
4949
}

DependencyInjection/TranslatorPass.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public function process(ContainerBuilder $container)
4343
return;
4444
}
4545

46-
$loaders = array();
47-
$loaderRefs = array();
46+
$loaders = [];
47+
$loaderRefs = [];
4848
foreach ($container->findTaggedServiceIds($this->loaderTag, true) as $id => $attributes) {
4949
$loaderRefs[$id] = new Reference($id);
5050
$loaders[$id][] = $attributes[0]['alias'];
@@ -57,7 +57,7 @@ public function process(ContainerBuilder $container)
5757
$definition = $container->getDefinition($this->readerServiceId);
5858
foreach ($loaders as $id => $formats) {
5959
foreach ($formats as $format) {
60-
$definition->addMethodCall('addLoader', array($format, $loaderRefs[$id]));
60+
$definition->addMethodCall('addLoader', [$format, $loaderRefs[$id]]);
6161
}
6262
}
6363
}
@@ -68,7 +68,7 @@ public function process(ContainerBuilder $container)
6868
$definition = $container->getDefinition('translation.reader');
6969
foreach ($loaders as $id => $formats) {
7070
foreach ($formats as $format) {
71-
$definition->addMethodCall('addLoader', array($format, $loaderRefs[$id]));
71+
$definition->addMethodCall('addLoader', [$format, $loaderRefs[$id]]);
7272
}
7373
}
7474
}

Dumper/CsvFileDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ class CsvFileDumper extends FileDumper
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
29+
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = [])
3030
{
3131
$handle = fopen('php://memory', 'r+b');
3232

3333
foreach ($messages->all($domain) as $source => $target) {
34-
fputcsv($handle, array($source, $target), $this->delimiter, $this->enclosure);
34+
fputcsv($handle, [$source, $target], $this->delimiter, $this->enclosure);
3535
}
3636

3737
rewind($handle);

0 commit comments

Comments
 (0)