Skip to content

Commit 3609dc8

Browse files
committed
Merge branch '3.4' into 4.1
* 3.4: 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 9fe424c + 1b8a0b7 commit 3609dc8

File tree

63 files changed

+1020
-1020
lines changed

Some content is hidden

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

63 files changed

+1020
-1020
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
@@ -38,7 +38,7 @@ CHANGELOG
3838
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
3939

4040
// ...
41-
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'));
41+
$rendererEngine = new TwigRendererEngine(['form_div_layout.html.twig']);
4242
$rendererEngine->setEnvironment($twig);
4343
$twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager)));
4444
```
@@ -47,13 +47,13 @@ CHANGELOG
4747

4848
```php
4949
// ...
50-
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig);
50+
$rendererEngine = new TwigRendererEngine(['form_div_layout.html.twig'], $twig);
5151
// require Twig 1.30+
52-
$twig->addRuntimeLoader(new \Twig\RuntimeLoader\FactoryRuntimeLoader(array(
52+
$twig->addRuntimeLoader(new \Twig\RuntimeLoader\FactoryRuntimeLoader([
5353
TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) {
5454
return new TwigRenderer($rendererEngine, $csrfTokenManager);
5555
},
56-
)));
56+
]));
5757
$twig->addExtension(new FormExtension());
5858
```
5959
* 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;

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/CodeExtension.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ public function __construct($fileLinkFormat, string $rootDir, 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-
);
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+
];
5757
}
5858

5959
public function abbrClass($class)
@@ -87,7 +87,7 @@ public function abbrMethod($method)
8787
*/
8888
public function formatArgs($args)
8989
{
90-
$result = array();
90+
$result = [];
9191
foreach ($args as $key => $item) {
9292
if ('object' === $item[0]) {
9393
$parts = explode('\\', $item[1]);
@@ -146,7 +146,7 @@ public function fileExcerpt($file, $line, $srcContext = 3)
146146
}, $code);
147147
$content = explode('<br />', $code);
148148

149-
$lines = array();
149+
$lines = [];
150150
if (0 > $srcContext) {
151151
$srcContext = \count($content);
152152
}
@@ -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;
@@ -224,7 +224,7 @@ public function formatFileFromText($text)
224224
public function formatLogMessage($message, array $context)
225225
{
226226
if ($context && false !== strpos($message, '{')) {
227-
$replacements = array();
227+
$replacements = [];
228228
foreach ($context as $key => $val) {
229229
if (is_scalar($val)) {
230230
$replacements['{'.$key.'}'] = $val;

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

Extension/HttpKernelExtension.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ class HttpKernelExtension extends AbstractExtension
2424
{
2525
public function getFunctions()
2626
{
27-
return array(
28-
new TwigFunction('render', array(HttpKernelRuntime::class, 'renderFragment'), array('is_safe' => array('html'))),
29-
new TwigFunction('render_*', array(HttpKernelRuntime::class, 'renderFragmentStrategy'), array('is_safe' => array('html'))),
27+
return [
28+
new TwigFunction('render', [HttpKernelRuntime::class, 'renderFragment'], ['is_safe' => ['html']]),
29+
new TwigFunction('render_*', [HttpKernelRuntime::class, 'renderFragmentStrategy'], ['is_safe' => ['html']]),
3030
new TwigFunction('controller', static::class.'::controller'),
31-
);
31+
];
3232
}
3333

34-
public static function controller($controller, $attributes = array(), $query = array())
34+
public static function controller($controller, $attributes = [], $query = [])
3535
{
3636
return new ControllerReference($controller, $attributes, $query);
3737
}

Extension/HttpKernelRuntime.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(FragmentHandler $handler)
3838
*
3939
* @see FragmentHandler::render()
4040
*/
41-
public function renderFragment($uri, $options = array())
41+
public function renderFragment($uri, $options = [])
4242
{
4343
$strategy = isset($options['strategy']) ? $options['strategy'] : 'inline';
4444
unset($options['strategy']);
@@ -57,7 +57,7 @@ public function renderFragment($uri, $options = array())
5757
*
5858
* @see FragmentHandler::render()
5959
*/
60-
public function renderFragmentStrategy($strategy, $uri, $options = array())
60+
public function renderFragmentStrategy($strategy, $uri, $options = [])
6161
{
6262
return $this->handler->render($uri, $strategy, $options);
6363
}

0 commit comments

Comments
 (0)