Skip to content

Commit 0ca6798

Browse files
committed
Merge branch '4.1' into 4.2
* 4.1: 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 6c69cfc + 7e37483 commit 0ca6798

File tree

62 files changed

+1035
-1035
lines changed

Some content is hidden

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

62 files changed

+1035
-1035
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/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
/**

Extension/CsrfExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class CsrfExtension extends AbstractExtension
2525
*/
2626
public function getFunctions(): array
2727
{
28-
return array(
29-
new TwigFunction('csrf_token', array(CsrfRuntime::class, 'getCsrfToken')),
30-
);
28+
return [
29+
new TwigFunction('csrf_token', [CsrfRuntime::class, 'getCsrfToken']),
30+
];
3131
}
3232
}

Extension/DumpExtension.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ public function __construct(ClonerInterface $cloner, HtmlDumper $dumper = null)
3737

3838
public function getFunctions()
3939
{
40-
return array(
41-
new TwigFunction('dump', array($this, 'dump'), array('is_safe' => array('html'), 'needs_context' => true, 'needs_environment' => true)),
42-
);
40+
return [
41+
new TwigFunction('dump', [$this, 'dump'], ['is_safe' => ['html'], 'needs_context' => true, 'needs_environment' => true]),
42+
];
4343
}
4444

4545
public function getTokenParsers()
4646
{
47-
return array(new DumpTokenParser());
47+
return [new DumpTokenParser()];
4848
}
4949

5050
public function getName()
@@ -59,14 +59,14 @@ public function dump(Environment $env, $context)
5959
}
6060

6161
if (2 === \func_num_args()) {
62-
$vars = array();
62+
$vars = [];
6363
foreach ($context as $key => $value) {
6464
if (!$value instanceof Template) {
6565
$vars[$key] = $value;
6666
}
6767
}
6868

69-
$vars = array($vars);
69+
$vars = [$vars];
7070
} else {
7171
$vars = \func_get_args();
7272
unset($vars[0], $vars[1]);

Extension/ExpressionExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class ExpressionExtension extends AbstractExtension
2727
*/
2828
public function getFunctions()
2929
{
30-
return array(
31-
new TwigFunction('expression', array($this, 'createExpression')),
32-
);
30+
return [
31+
new TwigFunction('expression', [$this, 'createExpression']),
32+
];
3333
}
3434

3535
public function createExpression($expression)

Extension/FormExtension.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,51 +32,51 @@ class FormExtension extends AbstractExtension
3232
*/
3333
public function getTokenParsers()
3434
{
35-
return array(
35+
return [
3636
// {% form_theme form "SomeBundle::widgets.twig" %}
3737
new FormThemeTokenParser(),
38-
);
38+
];
3939
}
4040

4141
/**
4242
* {@inheritdoc}
4343
*/
4444
public function getFunctions()
4545
{
46-
return array(
47-
new TwigFunction('form_widget', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),
48-
new TwigFunction('form_errors', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),
49-
new TwigFunction('form_label', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),
50-
new TwigFunction('form_help', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),
51-
new TwigFunction('form_row', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),
52-
new TwigFunction('form_rest', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),
53-
new TwigFunction('form', null, array('node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => array('html'))),
54-
new TwigFunction('form_start', null, array('node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => array('html'))),
55-
new TwigFunction('form_end', null, array('node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => array('html'))),
56-
new TwigFunction('csrf_token', array('Symfony\Component\Form\FormRenderer', 'renderCsrfToken')),
57-
);
46+
return [
47+
new TwigFunction('form_widget', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
48+
new TwigFunction('form_errors', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
49+
new TwigFunction('form_label', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
50+
new TwigFunction('form_help', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
51+
new TwigFunction('form_row', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
52+
new TwigFunction('form_rest', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
53+
new TwigFunction('form', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
54+
new TwigFunction('form_start', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
55+
new TwigFunction('form_end', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
56+
new TwigFunction('csrf_token', ['Symfony\Component\Form\FormRenderer', 'renderCsrfToken']),
57+
];
5858
}
5959

6060
/**
6161
* {@inheritdoc}
6262
*/
6363
public function getFilters()
6464
{
65-
return array(
66-
new TwigFilter('humanize', array('Symfony\Component\Form\FormRenderer', 'humanize')),
67-
new TwigFilter('form_encode_currency', array('Symfony\Component\Form\FormRenderer', 'encodeCurrency'), array('is_safe' => array('html'), 'needs_environment' => true)),
68-
);
65+
return [
66+
new TwigFilter('humanize', ['Symfony\Component\Form\FormRenderer', 'humanize']),
67+
new TwigFilter('form_encode_currency', ['Symfony\Component\Form\FormRenderer', 'encodeCurrency'], ['is_safe' => ['html'], 'needs_environment' => true]),
68+
];
6969
}
7070

7171
/**
7272
* {@inheritdoc}
7373
*/
7474
public function getTests()
7575
{
76-
return array(
76+
return [
7777
new TwigTest('selectedchoice', 'Symfony\Bridge\Twig\Extension\twig_is_selected_choice'),
7878
new TwigTest('rootform', 'Symfony\Bridge\Twig\Extension\twig_is_root_form'),
79-
);
79+
];
8080
}
8181

8282
/**

Extension/HttpFoundationExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public function __construct(RequestStack $requestStack, RequestContext $requestC
3838
*/
3939
public function getFunctions()
4040
{
41-
return array(
42-
new TwigFunction('absolute_url', array($this, 'generateAbsoluteUrl')),
43-
new TwigFunction('relative_path', array($this, 'generateRelativePath')),
44-
);
41+
return [
42+
new TwigFunction('absolute_url', [$this, 'generateAbsoluteUrl']),
43+
new TwigFunction('relative_path', [$this, 'generateRelativePath']),
44+
];
4545
}
4646

4747
/**

0 commit comments

Comments
 (0)