Skip to content

Commit 13014cc

Browse files
committed
fixed CS
1 parent 0ca6798 commit 13014cc

13 files changed

+247
-247
lines changed

Command/DebugCommand.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class DebugCommand extends Command
3737
private $twigDefaultPath;
3838
private $rootDir;
3939

40-
public function __construct(Environment $twig, string $projectDir = null, array $bundlesMetadata = array(), string $twigDefaultPath = null, string $rootDir = null)
40+
public function __construct(Environment $twig, string $projectDir = null, array $bundlesMetadata = [], string $twigDefaultPath = null, string $rootDir = null)
4141
{
4242
parent::__construct();
4343

@@ -51,11 +51,11 @@ public function __construct(Environment $twig, string $projectDir = null, array
5151
protected function configure()
5252
{
5353
$this
54-
->setDefinition(array(
54+
->setDefinition([
5555
new InputArgument('name', InputArgument::OPTIONAL, 'The template name'),
5656
new InputOption('filter', null, InputOption::VALUE_REQUIRED, 'Show details for all entries matching this filter'),
5757
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (text or json)', 'text'),
58-
))
58+
])
5959
->setDescription('Shows a list of twig functions, filters, globals and tests')
6060
->setHelp(<<<'EOF'
6161
The <info>%command.name%</info> command outputs a list of twig functions,
@@ -115,11 +115,11 @@ private function displayPathsText(SymfonyStyle $io, string $name)
115115
$io->listing($files);
116116
}
117117
} else {
118-
$alternatives = array();
118+
$alternatives = [];
119119

120120
if ($paths) {
121-
$shortnames = array();
122-
$dirs = array();
121+
$shortnames = [];
122+
$dirs = [];
123123
foreach (current($paths) as $path) {
124124
$dirs[] = $this->isAbsolutePath($path) ? $path : $this->projectDir.'/'.$path;
125125
}
@@ -141,9 +141,9 @@ private function displayPathsText(SymfonyStyle $io, string $name)
141141

142142
$io->section('Configured Paths');
143143
if ($paths) {
144-
$io->table(array('Namespace', 'Paths'), $this->buildTableRows($paths));
144+
$io->table(['Namespace', 'Paths'], $this->buildTableRows($paths));
145145
} else {
146-
$alternatives = array();
146+
$alternatives = [];
147147
$namespace = $this->parseTemplateName($name)[0];
148148

149149
if (FilesystemLoader::MAIN_NAMESPACE === $namespace) {
@@ -159,7 +159,7 @@ private function displayPathsText(SymfonyStyle $io, string $name)
159159
$this->error($io, $message, $alternatives);
160160

161161
if (!$alternatives && $paths = $this->getLoaderPaths()) {
162-
$io->table(array('Namespace', 'Paths'), $this->buildTableRows($paths));
162+
$io->table(['Namespace', 'Paths'], $this->buildTableRows($paths));
163163
}
164164
}
165165
}
@@ -184,9 +184,9 @@ private function displayPathsJson(SymfonyStyle $io, string $name)
184184

185185
private function displayGeneralText(SymfonyStyle $io, string $filter = null)
186186
{
187-
$types = array('functions', 'filters', 'tests', 'globals');
187+
$types = ['functions', 'filters', 'tests', 'globals'];
188188
foreach ($types as $index => $type) {
189-
$items = array();
189+
$items = [];
190190
foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) {
191191
if (!$filter || false !== strpos($name, $filter)) {
192192
$items[$name] = $name.$this->getPrettyMetadata($type, $entity);
@@ -205,7 +205,7 @@ private function displayGeneralText(SymfonyStyle $io, string $filter = null)
205205

206206
if (!$filter && $paths = $this->getLoaderPaths()) {
207207
$io->section('Loader Paths');
208-
$io->table(array('Namespace', 'Paths'), $this->buildTableRows($paths));
208+
$io->table(['Namespace', 'Paths'], $this->buildTableRows($paths));
209209
}
210210

211211
if ($wrongBundles = $this->findWrongBundleOverrides()) {
@@ -217,8 +217,8 @@ private function displayGeneralText(SymfonyStyle $io, string $filter = null)
217217

218218
private function displayGeneralJson(SymfonyStyle $io, $filter)
219219
{
220-
$types = array('functions', 'filters', 'tests', 'globals');
221-
$data = array();
220+
$types = ['functions', 'filters', 'tests', 'globals'];
221+
$data = [];
222222
foreach ($types as $type) {
223223
foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) {
224224
if (!$filter || false !== strpos($name, $filter)) {
@@ -245,15 +245,15 @@ private function getLoaderPaths(string $name = null): array
245245
{
246246
/** @var FilesystemLoader $loader */
247247
$loader = $this->twig->getLoader();
248-
$loaderPaths = array();
248+
$loaderPaths = [];
249249
$namespaces = $loader->getNamespaces();
250250
if (null !== $name) {
251251
$namespace = $this->parseTemplateName($name)[0];
252-
$namespaces = array_intersect(array($namespace), $namespaces);
252+
$namespaces = array_intersect([$namespace], $namespaces);
253253
}
254254

255255
foreach ($namespaces as $namespace) {
256-
$paths = array_map(array($this, 'getRelativePath'), $loader->getPaths($namespace));
256+
$paths = array_map([$this, 'getRelativePath'], $loader->getPaths($namespace));
257257

258258
if (FilesystemLoader::MAIN_NAMESPACE === $namespace) {
259259
$namespace = '(None)';
@@ -357,8 +357,8 @@ private function getPrettyMetadata($type, $entity)
357357

358358
private function findWrongBundleOverrides(): array
359359
{
360-
$alternatives = array();
361-
$bundleNames = array();
360+
$alternatives = [];
361+
$bundleNames = [];
362362

363363
if ($this->rootDir && $this->projectDir) {
364364
$folders = glob($this->rootDir.'/Resources/*/views', GLOB_ONLYDIR);
@@ -391,7 +391,7 @@ private function findWrongBundleOverrides(): array
391391
}
392392

393393
if ($notFoundBundles = array_diff_key($bundleNames, $this->bundlesMetadata)) {
394-
$alternatives = array();
394+
$alternatives = [];
395395
foreach ($notFoundBundles as $notFoundBundle => $path) {
396396
$alternatives[$path] = $this->findAlternatives($notFoundBundle, array_keys($this->bundlesMetadata));
397397
}
@@ -402,7 +402,7 @@ private function findWrongBundleOverrides(): array
402402

403403
private function buildWarningMessages(array $wrongBundles): array
404404
{
405-
$messages = array();
405+
$messages = [];
406406
foreach ($wrongBundles as $path => $alternatives) {
407407
$message = sprintf('Path "%s" not matching any bundle found', $path);
408408
if ($alternatives) {
@@ -421,7 +421,7 @@ private function buildWarningMessages(array $wrongBundles): array
421421
return $messages;
422422
}
423423

424-
private function error(SymfonyStyle $io, string $message, array $alternatives = array()): void
424+
private function error(SymfonyStyle $io, string $message, array $alternatives = []): void
425425
{
426426
if ($alternatives) {
427427
if (1 === \count($alternatives)) {
@@ -439,7 +439,7 @@ private function findTemplateFiles(string $name): array
439439
{
440440
/** @var FilesystemLoader $loader */
441441
$loader = $this->twig->getLoader();
442-
$files = array();
442+
$files = [];
443443
list($namespace, $shortname) = $this->parseTemplateName($name);
444444

445445
foreach ($loader->getPaths($namespace) as $path) {
@@ -470,29 +470,29 @@ private function parseTemplateName(string $name, string $default = FilesystemLoa
470470
$namespace = substr($name, 1, $pos - 1);
471471
$shortname = substr($name, $pos + 1);
472472

473-
return array($namespace, $shortname);
473+
return [$namespace, $shortname];
474474
}
475475

476-
return array($default, $name);
476+
return [$default, $name];
477477
}
478478

479479
private function buildTableRows(array $loaderPaths): array
480480
{
481-
$rows = array();
481+
$rows = [];
482482
$firstNamespace = true;
483483
$prevHasSeparator = false;
484484

485485
foreach ($loaderPaths as $namespace => $paths) {
486486
if (!$firstNamespace && !$prevHasSeparator && \count($paths) > 1) {
487-
$rows[] = array('', '');
487+
$rows[] = ['', ''];
488488
}
489489
$firstNamespace = false;
490490
foreach ($paths as $path) {
491-
$rows[] = array($namespace, $path.\DIRECTORY_SEPARATOR);
491+
$rows[] = [$namespace, $path.\DIRECTORY_SEPARATOR];
492492
$namespace = '';
493493
}
494494
if (\count($paths) > 1) {
495-
$rows[] = array('', '');
495+
$rows[] = ['', ''];
496496
$prevHasSeparator = true;
497497
} else {
498498
$prevHasSeparator = false;
@@ -507,7 +507,7 @@ private function buildTableRows(array $loaderPaths): array
507507

508508
private function findAlternatives(string $name, array $collection): array
509509
{
510-
$alternatives = array();
510+
$alternatives = [];
511511
foreach ($collection as $item) {
512512
$lev = levenshtein($name, $item);
513513
if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {

Extension/CodeExtension.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ public function __construct($fileLinkFormat, string $projectDir, string $charset
4343
*/
4444
public function getFilters()
4545
{
46-
return array(
47-
new TwigFilter('abbr_class', array($this, 'abbrClass'), array('is_safe' => array('html'))),
48-
new TwigFilter('abbr_method', array($this, 'abbrMethod'), array('is_safe' => array('html'))),
49-
new TwigFilter('format_args', array($this, 'formatArgs'), array('is_safe' => array('html'))),
50-
new TwigFilter('format_args_as_text', array($this, 'formatArgsAsText')),
51-
new TwigFilter('file_excerpt', array($this, 'fileExcerpt'), array('is_safe' => array('html'))),
52-
new TwigFilter('format_file', array($this, 'formatFile'), array('is_safe' => array('html'))),
53-
new TwigFilter('format_file_from_text', array($this, 'formatFileFromText'), array('is_safe' => array('html'))),
54-
new TwigFilter('format_log_message', array($this, 'formatLogMessage'), array('is_safe' => array('html'))),
55-
new TwigFilter('file_link', array($this, 'getFileLink')),
56-
new TwigFilter('file_relative', array($this, 'getFileRelative')),
57-
);
46+
return [
47+
new TwigFilter('abbr_class', [$this, 'abbrClass'], ['is_safe' => ['html']]),
48+
new TwigFilter('abbr_method', [$this, 'abbrMethod'], ['is_safe' => ['html']]),
49+
new TwigFilter('format_args', [$this, 'formatArgs'], ['is_safe' => ['html']]),
50+
new TwigFilter('format_args_as_text', [$this, 'formatArgsAsText']),
51+
new TwigFilter('file_excerpt', [$this, 'fileExcerpt'], ['is_safe' => ['html']]),
52+
new TwigFilter('format_file', [$this, 'formatFile'], ['is_safe' => ['html']]),
53+
new TwigFilter('format_file_from_text', [$this, 'formatFileFromText'], ['is_safe' => ['html']]),
54+
new TwigFilter('format_log_message', [$this, 'formatLogMessage'], ['is_safe' => ['html']]),
55+
new TwigFilter('file_link', [$this, 'getFileLink']),
56+
new TwigFilter('file_relative', [$this, 'getFileRelative']),
57+
];
5858
}
5959

6060
public function abbrClass($class)
@@ -88,7 +88,7 @@ public function abbrMethod($method)
8888
*/
8989
public function formatArgs($args)
9090
{
91-
$result = array();
91+
$result = [];
9292
foreach ($args as $key => $item) {
9393
if ('object' === $item[0]) {
9494
$parts = explode('\\', $item[1]);
@@ -147,7 +147,7 @@ public function fileExcerpt($file, $line, $srcContext = 3)
147147
}, $code);
148148
$content = explode('<br />', $code);
149149

150-
$lines = array();
150+
$lines = [];
151151
if (0 > $srcContext) {
152152
$srcContext = \count($content);
153153
}
@@ -205,7 +205,7 @@ public function formatFile($file, $line, $text = null)
205205
public function getFileLink($file, $line)
206206
{
207207
if ($fmt = $this->fileLinkFormat) {
208-
return \is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line);
208+
return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line);
209209
}
210210

211211
return false;
@@ -235,7 +235,7 @@ public function formatFileFromText($text)
235235
public function formatLogMessage($message, array $context)
236236
{
237237
if ($context && false !== strpos($message, '{')) {
238-
$replacements = array();
238+
$replacements = [];
239239
foreach ($context as $key => $val) {
240240
if (is_scalar($val)) {
241241
$replacements['{'.$key.'}'] = $val;

Extension/TranslationExtension.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ public function getTranslator()
6969
*/
7070
public function getFilters()
7171
{
72-
return array(
73-
new TwigFilter('trans', array($this, 'trans')),
74-
new TwigFilter('transchoice', array($this, 'transchoice'), array('deprecated' => '4.2', 'alternative' => 'trans" with parameter "%count%')),
75-
);
72+
return [
73+
new TwigFilter('trans', [$this, 'trans']),
74+
new TwigFilter('transchoice', [$this, 'transchoice'], ['deprecated' => '4.2', 'alternative' => 'trans" with parameter "%count%']),
75+
];
7676
}
7777

7878
/**
@@ -82,7 +82,7 @@ public function getFilters()
8282
*/
8383
public function getTokenParsers()
8484
{
85-
return array(
85+
return [
8686
// {% trans %}Symfony is great!{% endtrans %}
8787
new TransTokenParser(),
8888

@@ -93,23 +93,23 @@ public function getTokenParsers()
9393

9494
// {% trans_default_domain "foobar" %}
9595
new TransDefaultDomainTokenParser(),
96-
);
96+
];
9797
}
9898

9999
/**
100100
* {@inheritdoc}
101101
*/
102102
public function getNodeVisitors()
103103
{
104-
return array($this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor());
104+
return [$this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor()];
105105
}
106106

107107
public function getTranslationNodeVisitor()
108108
{
109109
return $this->translationNodeVisitor ?: $this->translationNodeVisitor = new TranslationNodeVisitor();
110110
}
111111

112-
public function trans($message, array $arguments = array(), $domain = null, $locale = null, $count = null)
112+
public function trans($message, array $arguments = [], $domain = null, $locale = null, $count = null)
113113
{
114114
if (null !== $count) {
115115
$arguments['%count%'] = $count;
@@ -124,16 +124,16 @@ public function trans($message, array $arguments = array(), $domain = null, $loc
124124
/**
125125
* @deprecated since Symfony 4.2, use the trans() method instead with a %count% parameter
126126
*/
127-
public function transchoice($message, $count, array $arguments = array(), $domain = null, $locale = null)
127+
public function transchoice($message, $count, array $arguments = [], $domain = null, $locale = null)
128128
{
129129
if (null === $this->translator) {
130-
return $this->doTrans($message, array_merge(array('%count%' => $count), $arguments), $domain, $locale);
130+
return $this->doTrans($message, array_merge(['%count%' => $count], $arguments), $domain, $locale);
131131
}
132132
if ($this->translator instanceof TranslatorInterface) {
133-
return $this->translator->trans($message, array_merge(array('%count%' => $count), $arguments), $domain, $locale);
133+
return $this->translator->trans($message, array_merge(['%count%' => $count], $arguments), $domain, $locale);
134134
}
135135

136-
return $this->translator->transChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain, $locale);
136+
return $this->translator->transChoice($message, $count, array_merge(['%count%' => $count], $arguments), $domain, $locale);
137137
}
138138

139139
/**

0 commit comments

Comments
 (0)