Skip to content

Commit 31c48df

Browse files
committed
switched array() to []
1 parent a067eda commit 31c48df

File tree

72 files changed

+1191
-1191
lines changed

Some content is hidden

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

72 files changed

+1191
-1191
lines changed

AppVariable.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

Command/DebugCommand.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ protected function getTwigEnvironment()
7272
protected function configure()
7373
{
7474
$this
75-
->setDefinition(array(
75+
->setDefinition([
7676
new InputArgument('filter', InputArgument::OPTIONAL, 'Show details for all entries matching this filter'),
7777
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (text or json)', 'text'),
78-
))
78+
])
7979
->setDescription('Shows a list of twig functions, filters, globals and tests')
8080
->setHelp(<<<'EOF'
8181
The <info>%command.name%</info> command outputs a list of twig functions,
@@ -114,10 +114,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
114114
throw new \RuntimeException('The Twig environment needs to be set.');
115115
}
116116

117-
$types = array('functions', 'filters', 'tests', 'globals');
117+
$types = ['functions', 'filters', 'tests', 'globals'];
118118

119119
if ('json' === $input->getOption('format')) {
120-
$data = array();
120+
$data = [];
121121
foreach ($types as $type) {
122122
foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) {
123123
$data[$type][$name] = $this->getMetadata($type, $entity);
@@ -133,7 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
133133
$filter = $input->getArgument('filter');
134134

135135
foreach ($types as $index => $type) {
136-
$items = array();
136+
$items = [];
137137
foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) {
138138
if (!$filter || false !== strpos($name, $filter)) {
139139
$items[$name] = $name.$this->getPrettyMetadata($type, $entity);
@@ -150,20 +150,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
150150
$io->listing($items);
151151
}
152152

153-
$rows = array();
153+
$rows = [];
154154
$firstNamespace = true;
155155
$prevHasSeparator = false;
156156
foreach ($this->getLoaderPaths() as $namespace => $paths) {
157157
if (!$firstNamespace && !$prevHasSeparator && \count($paths) > 1) {
158-
$rows[] = array('', '');
158+
$rows[] = ['', ''];
159159
}
160160
$firstNamespace = false;
161161
foreach ($paths as $path) {
162-
$rows[] = array($namespace, $path.\DIRECTORY_SEPARATOR);
162+
$rows[] = [$namespace, $path.\DIRECTORY_SEPARATOR];
163163
$namespace = '';
164164
}
165165
if (\count($paths) > 1) {
166-
$rows[] = array('', '');
166+
$rows[] = ['', ''];
167167
$prevHasSeparator = true;
168168
} else {
169169
$prevHasSeparator = false;
@@ -173,18 +173,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
173173
array_pop($rows);
174174
}
175175
$io->section('Loader Paths');
176-
$io->table(array('Namespace', 'Paths'), $rows);
176+
$io->table(['Namespace', 'Paths'], $rows);
177177

178178
return 0;
179179
}
180180

181181
private function getLoaderPaths()
182182
{
183183
if (!($loader = $this->twig->getLoader()) instanceof FilesystemLoader) {
184-
return array();
184+
return [];
185185
}
186186

187-
$loaderPaths = array();
187+
$loaderPaths = [];
188188
foreach ($loader->getNamespaces() as $namespace) {
189189
$paths = array_map(function ($path) {
190190
if (null !== $this->projectDir && 0 === strpos($path, $this->projectDir)) {

Command/LintCommand.php

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

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

135135
$filesInfo = $this->getFilesInfo($filenames);
@@ -139,7 +139,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
139139

140140
private function getFilesInfo(array $filenames)
141141
{
142-
$filesInfo = array();
142+
$filesInfo = [];
143143
foreach ($filenames as $filename) {
144144
foreach ($this->findFiles($filename) as $file) {
145145
$filesInfo[] = $this->validate(file_get_contents($file), $file);
@@ -152,7 +152,7 @@ private function getFilesInfo(array $filenames)
152152
protected function findFiles($filename)
153153
{
154154
if (is_file($filename)) {
155-
return array($filename);
155+
return [$filename];
156156
} elseif (is_dir($filename)) {
157157
return Finder::create()->files()->in($filename)->name('*.twig');
158158
}
@@ -164,18 +164,18 @@ private function validate($template, $file)
164164
{
165165
$realLoader = $this->twig->getLoader();
166166
try {
167-
$temporaryLoader = new ArrayLoader(array((string) $file => $template));
167+
$temporaryLoader = new ArrayLoader([(string) $file => $template]);
168168
$this->twig->setLoader($temporaryLoader);
169169
$nodeTree = $this->twig->parse($this->twig->tokenize(new Source($template, (string) $file)));
170170
$this->twig->compile($nodeTree);
171171
$this->twig->setLoader($realLoader);
172172
} catch (Error $e) {
173173
$this->twig->setLoader($realLoader);
174174

175-
return array('template' => $template, 'file' => $file, 'line' => $e->getTemplateLine(), 'valid' => false, 'exception' => $e);
175+
return ['template' => $template, 'file' => $file, 'line' => $e->getTemplateLine(), 'valid' => false, 'exception' => $e];
176176
}
177177

178-
return array('template' => $template, 'file' => $file, 'valid' => true);
178+
return ['template' => $template, 'file' => $file, 'valid' => true];
179179
}
180180

181181
private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, $files)
@@ -261,7 +261,7 @@ private function getContext($template, $line, $context = 3)
261261
$position = max(0, $line - $context);
262262
$max = min(\count($lines), $line - 1 + $context);
263263

264-
$result = array();
264+
$result = [];
265265
while ($position < $max) {
266266
$result[$position + 1] = $lines[$position];
267267
++$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,15 +122,15 @@ 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
}
@@ -139,7 +139,7 @@ public function getProfile()
139139
{
140140
if (null === $this->profile) {
141141
if (\PHP_VERSION_ID >= 70000) {
142-
$this->profile = unserialize($this->data['profile'], array('allowed_classes' => array('Twig_Profiler_Profile', 'Twig\Profiler\Profile')));
142+
$this->profile = unserialize($this->data['profile'], ['allowed_classes' => ['Twig_Profiler_Profile', 'Twig\Profiler\Profile']]);
143143
} else {
144144
$this->profile = unserialize($this->data['profile']);
145145
}
@@ -159,13 +159,13 @@ private function getComputedData($index)
159159

160160
private function computeData(Profile $profile)
161161
{
162-
$data = array(
162+
$data = [
163163
'template_count' => 0,
164164
'block_count' => 0,
165165
'macro_count' => 0,
166-
);
166+
];
167167

168-
$templates = array();
168+
$templates = [];
169169
foreach ($profile as $p) {
170170
$d = $this->computeData($p);
171171

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, $rootDir, $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)

0 commit comments

Comments
 (0)