Skip to content

Commit 7da80fd

Browse files
committed
Merge branch '4.2' into short-array-master
* 4.2: fixed CS fixed CS fixed tests fixed CS fixed CS fixed CS fixed short array CS in comments fixed CS in ExpressionLanguage fixtures fixed CS in generated files fixed CS on generated container files fixed CS on Form PHP templates fixed CS on YAML fixtures fixed fixtures switched array() to []
2 parents 63fbf25 + 219758e commit 7da80fd

File tree

73 files changed

+1317
-1317
lines changed

Some content is hidden

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

73 files changed

+1317
-1317
lines changed

AppVariable.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function getDebug()
150150
* Returns some or all the existing flash messages:
151151
* * getFlashes() returns all the flash messages
152152
* * getFlashes('notice') returns a simple array with flash messages of that type
153-
* * getFlashes(array('notice', 'error')) returns a nested array of type => messages.
153+
* * getFlashes(['notice', 'error']) returns a nested array of type => messages.
154154
*
155155
* @return array
156156
*/
@@ -159,21 +159,21 @@ public function getFlashes($types = null)
159159
try {
160160
$session = $this->getSession();
161161
if (null === $session) {
162-
return array();
162+
return [];
163163
}
164164
} catch (\RuntimeException $e) {
165-
return array();
165+
return [];
166166
}
167167

168-
if (null === $types || '' === $types || array() === $types) {
168+
if (null === $types || '' === $types || [] === $types) {
169169
return $session->getFlashBag()->all();
170170
}
171171

172172
if (\is_string($types)) {
173173
return $session->getFlashBag()->get($types);
174174
}
175175

176-
$result = array();
176+
$result = [];
177177
foreach ($types as $type) {
178178
$result[$type] = $session->getFlashBag()->get($type);
179179
}

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ CHANGELOG
4545
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
4646

4747
// ...
48-
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'));
48+
$rendererEngine = new TwigRendererEngine(['form_div_layout.html.twig']);
4949
$rendererEngine->setEnvironment($twig);
5050
$twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager)));
5151
```
@@ -54,13 +54,13 @@ CHANGELOG
5454

5555
```php
5656
// ...
57-
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig);
57+
$rendererEngine = new TwigRendererEngine(['form_div_layout.html.twig'], $twig);
5858
// require Twig 1.30+
59-
$twig->addRuntimeLoader(new \Twig\RuntimeLoader\FactoryRuntimeLoader(array(
59+
$twig->addRuntimeLoader(new \Twig\RuntimeLoader\FactoryRuntimeLoader([
6060
TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) {
6161
return new TwigRenderer($rendererEngine, $csrfTokenManager);
6262
},
63-
)));
63+
]));
6464
$twig->addExtension(new FormExtension());
6565
```
6666
* Deprecated the `TwigRendererEngineInterface` interface.

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)) {

Command/LintCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8787
$template .= fread(STDIN, 1024);
8888
}
8989

90-
return $this->display($input, $output, $io, array($this->validate($template, uniqid('sf_', true))));
90+
return $this->display($input, $output, $io, [$this->validate($template, uniqid('sf_', true))]);
9191
}
9292

9393
$filesInfo = $this->getFilesInfo($filenames);
@@ -97,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9797

9898
private function getFilesInfo(array $filenames)
9999
{
100-
$filesInfo = array();
100+
$filesInfo = [];
101101
foreach ($filenames as $filename) {
102102
foreach ($this->findFiles($filename) as $file) {
103103
$filesInfo[] = $this->validate(file_get_contents($file), $file);
@@ -110,7 +110,7 @@ private function getFilesInfo(array $filenames)
110110
protected function findFiles($filename)
111111
{
112112
if (is_file($filename)) {
113-
return array($filename);
113+
return [$filename];
114114
} elseif (is_dir($filename)) {
115115
return Finder::create()->files()->in($filename)->name('*.twig');
116116
}
@@ -122,18 +122,18 @@ private function validate($template, $file)
122122
{
123123
$realLoader = $this->twig->getLoader();
124124
try {
125-
$temporaryLoader = new ArrayLoader(array((string) $file => $template));
125+
$temporaryLoader = new ArrayLoader([(string) $file => $template]);
126126
$this->twig->setLoader($temporaryLoader);
127127
$nodeTree = $this->twig->parse($this->twig->tokenize(new Source($template, (string) $file)));
128128
$this->twig->compile($nodeTree);
129129
$this->twig->setLoader($realLoader);
130130
} catch (Error $e) {
131131
$this->twig->setLoader($realLoader);
132132

133-
return array('template' => $template, 'file' => $file, 'line' => $e->getTemplateLine(), 'valid' => false, 'exception' => $e);
133+
return ['template' => $template, 'file' => $file, 'line' => $e->getTemplateLine(), 'valid' => false, 'exception' => $e];
134134
}
135135

136-
return array('template' => $template, 'file' => $file, 'valid' => true);
136+
return ['template' => $template, 'file' => $file, 'valid' => true];
137137
}
138138

139139
private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, $files)
@@ -219,7 +219,7 @@ private function getContext($template, $line, $context = 3)
219219
$position = max(0, $line - $context);
220220
$max = min(\count($lines), $line - 1 + $context);
221221

222-
$result = array();
222+
$result = [];
223223
while ($position < $max) {
224224
$result[$position + 1] = $lines[$position];
225225
++$position;

DataCollector/TwigDataCollector.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function reset()
5151
{
5252
$this->profile->reset();
5353
$this->computed = null;
54-
$this->data = array();
54+
$this->data = [];
5555
}
5656

5757
/**
@@ -60,7 +60,7 @@ public function reset()
6060
public function lateCollect()
6161
{
6262
$this->data['profile'] = serialize($this->profile);
63-
$this->data['template_paths'] = array();
63+
$this->data['template_paths'] = [];
6464

6565
if (null === $this->twig) {
6666
return;
@@ -122,23 +122,23 @@ public function getHtmlCallGraph()
122122
$dump = $dumper->dump($this->getProfile());
123123

124124
// needed to remove the hardcoded CSS styles
125-
$dump = str_replace(array(
125+
$dump = str_replace([
126126
'<span style="background-color: #ffd">',
127127
'<span style="color: #d44">',
128128
'<span style="background-color: #dfd">',
129-
), array(
129+
], [
130130
'<span class="status-warning">',
131131
'<span class="status-error">',
132132
'<span class="status-success">',
133-
), $dump);
133+
], $dump);
134134

135135
return new Markup($dump, 'UTF-8');
136136
}
137137

138138
public function getProfile()
139139
{
140140
if (null === $this->profile) {
141-
$this->profile = unserialize($this->data['profile'], array('allowed_classes' => array('Twig_Profiler_Profile', 'Twig\Profiler\Profile')));
141+
$this->profile = unserialize($this->data['profile'], ['allowed_classes' => ['Twig_Profiler_Profile', 'Twig\Profiler\Profile']]);
142142
}
143143

144144
return $this->profile;
@@ -155,13 +155,13 @@ private function getComputedData($index)
155155

156156
private function computeData(Profile $profile)
157157
{
158-
$data = array(
158+
$data = [
159159
'template_count' => 0,
160160
'block_count' => 0,
161161
'macro_count' => 0,
162-
);
162+
];
163163

164-
$templates = array();
164+
$templates = [];
165165
foreach ($profile as $p) {
166166
$d = $this->computeData($p);
167167

Extension/AssetExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public function __construct(Packages $packages)
3434
*/
3535
public function getFunctions()
3636
{
37-
return array(
38-
new TwigFunction('asset', array($this, 'getAssetUrl')),
39-
new TwigFunction('asset_version', array($this, 'getAssetVersion')),
40-
);
37+
return [
38+
new TwigFunction('asset', [$this, 'getAssetUrl']),
39+
new TwigFunction('asset_version', [$this, 'getAssetVersion']),
40+
];
4141
}
4242

4343
/**

0 commit comments

Comments
 (0)