Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit ef3d64b

Browse files
committed
[cs] Use PHP short array syntax
Since PHP 5.4 arrays can be defined with brackets ([]) instead the function
1 parent 932c794 commit ef3d64b

File tree

97 files changed

+1248
-1247
lines changed

Some content is hidden

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

97 files changed

+1248
-1247
lines changed

.php_cs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ $config->fixers(
3232
'object_operator',
3333
'php_closing_tag',
3434
'remove_lines_between_uses',
35+
'short_array_syntax',
3536
'short_tag',
3637
'standardize_not_equal',
3738
'trailing_spaces',

src/Helper/Cycle.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Cycle extends AbstractHelper implements Iterator
2828
*
2929
* @var array
3030
*/
31-
protected $data = array(self::DEFAULT_NAME=>array());
31+
protected $data = [self::DEFAULT_NAME=>[]];
3232

3333
/**
3434
* Actual name of cycle
@@ -42,7 +42,7 @@ class Cycle extends AbstractHelper implements Iterator
4242
*
4343
* @var array
4444
*/
45-
protected $pointers = array(self::DEFAULT_NAME =>-1);
45+
protected $pointers = [self::DEFAULT_NAME =>-1];
4646

4747
/**
4848
* Add elements to alternate
@@ -51,7 +51,7 @@ class Cycle extends AbstractHelper implements Iterator
5151
* @param string $name
5252
* @return Cycle
5353
*/
54-
public function __invoke(array $data = array(), $name = self::DEFAULT_NAME)
54+
public function __invoke(array $data = [], $name = self::DEFAULT_NAME)
5555
{
5656
if (!empty($data)) {
5757
$this->data[$name] = $data;
@@ -107,7 +107,7 @@ public function setName($name = self::DEFAULT_NAME)
107107
$this->name = $name;
108108

109109
if (!isset($this->data[$this->name])) {
110-
$this->data[$this->name] = array();
110+
$this->data[$this->name] = [];
111111
}
112112

113113
if (!isset($this->pointers[$this->name])) {

src/Helper/Doctype.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ public function __toString()
131131
*/
132132
protected static function registerDefaultDoctypes()
133133
{
134-
static::$registeredDoctypes = new ArrayObject(array(
135-
'doctypes' => array(
134+
static::$registeredDoctypes = new ArrayObject([
135+
'doctypes' => [
136136
self::XHTML11 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
137137
self::XHTML1_STRICT => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
138138
self::XHTML1_TRANSITIONAL => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
@@ -145,8 +145,8 @@ protected static function registerDefaultDoctypes()
145145
self::HTML4_LOOSE => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
146146
self::HTML4_FRAMESET => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
147147
self::HTML5 => '<!DOCTYPE html>',
148-
),
149-
));
148+
],
149+
]);
150150
}
151151

152152
/**

src/Helper/FlashMessenger.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ class FlashMessenger extends AbstractTranslatorHelper implements ServiceLocatorA
2424
*
2525
* @var array
2626
*/
27-
protected $classMessages = array(
27+
protected $classMessages = [
2828
PluginFlashMessenger::NAMESPACE_INFO => 'info',
2929
PluginFlashMessenger::NAMESPACE_ERROR => 'error',
3030
PluginFlashMessenger::NAMESPACE_SUCCESS => 'success',
3131
PluginFlashMessenger::NAMESPACE_DEFAULT => 'default',
3232
PluginFlashMessenger::NAMESPACE_WARNING => 'warning',
33-
);
33+
];
3434

3535
/**
3636
* Templates for the open/close/separators for message tags
@@ -95,7 +95,7 @@ public function __invoke($namespace = null)
9595
public function __call($method, $argv)
9696
{
9797
$flashMessenger = $this->getPluginFlashMessenger();
98-
return call_user_func_array(array($flashMessenger, $method), $argv);
98+
return call_user_func_array([$flashMessenger, $method], $argv);
9999
}
100100

101101
/**
@@ -106,7 +106,7 @@ public function __call($method, $argv)
106106
* @param null|bool $autoEscape
107107
* @return string
108108
*/
109-
public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = array(), $autoEscape = null)
109+
public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = [], $autoEscape = null)
110110
{
111111
$flashMessenger = $this->getPluginFlashMessenger();
112112
$messages = $flashMessenger->getMessagesFromNamespace($namespace);
@@ -121,7 +121,7 @@ public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, arr
121121
* @param bool|null $autoEscape
122122
* @return string
123123
*/
124-
public function renderCurrent($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = array(), $autoEscape = null)
124+
public function renderCurrent($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = [], $autoEscape = null)
125125
{
126126
$flashMessenger = $this->getPluginFlashMessenger();
127127
$messages = $flashMessenger->getCurrentMessagesFromNamespace($namespace);
@@ -139,8 +139,8 @@ public function renderCurrent($namespace = PluginFlashMessenger::NAMESPACE_DEFAU
139139
*/
140140
protected function renderMessages(
141141
$namespace = PluginFlashMessenger::NAMESPACE_DEFAULT,
142-
array $messages = array(),
143-
array $classes = array(),
142+
array $messages = [],
143+
array $classes = [],
144144
$autoEscape = null
145145
) {
146146
// Prepare classes for opening tag
@@ -150,7 +150,7 @@ protected function renderMessages(
150150
} else {
151151
$classes = $this->classMessages[PluginFlashMessenger::NAMESPACE_DEFAULT];
152152
}
153-
$classes = array($classes);
153+
$classes = [$classes];
154154
}
155155

156156
if (null === $autoEscape) {
@@ -159,7 +159,7 @@ protected function renderMessages(
159159

160160
// Flatten message array
161161
$escapeHtml = $this->getEscapeHtmlHelper();
162-
$messagesToPrint = array();
162+
$messagesToPrint = [];
163163
$translator = $this->getTranslator();
164164
$translatorTextDomain = $this->getTranslatorTextDomain();
165165
array_walk_recursive(

src/Helper/Gravatar.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ class Gravatar extends AbstractHtmlElement
6868
*
6969
* @var array
7070
*/
71-
protected $options = array(
71+
protected $options = [
7272
'img_size' => 80,
7373
'default_img' => self::DEFAULT_MM,
7474
'rating' => self::RATING_G,
7575
'secure' => null,
76-
);
76+
];
7777

7878
/**
7979
* Returns an avatar from gravatar's service.
@@ -91,7 +91,7 @@ class Gravatar extends AbstractHtmlElement
9191
* @param array $attribs Attributes for image tag (title, alt etc.)
9292
* @return Gravatar
9393
*/
94-
public function __invoke($email = "", $options = array(), $attribs = array())
94+
public function __invoke($email = "", $options = [], $attribs = [])
9595
{
9696
if (!empty($email)) {
9797
$this->setEmail($email);

src/Helper/HeadLink.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class HeadLink extends Placeholder\Container\AbstractStandalone
3535
*
3636
* @var string[]
3737
*/
38-
protected $itemKeys = array(
38+
protected $itemKeys = [
3939
'charset',
4040
'href',
4141
'hreflang',
@@ -47,7 +47,7 @@ class HeadLink extends Placeholder\Container\AbstractStandalone
4747
'type',
4848
'title',
4949
'extras'
50-
);
50+
];
5151

5252
/**
5353
* Registry key for placeholder
@@ -80,7 +80,7 @@ public function __construct()
8080
*/
8181
public function headLink(array $attributes = null, $placement = Placeholder\Container\AbstractContainer::APPEND)
8282
{
83-
return call_user_func_array(array($this, '__invoke'), func_get_args());
83+
return call_user_func_array([$this, '__invoke'], func_get_args());
8484
}
8585

8686
/**
@@ -340,7 +340,7 @@ public function toString($indent = null)
340340
? $this->getWhitespace($indent)
341341
: $this->getIndent();
342342

343-
$items = array();
343+
$items = [];
344344
$this->getContainer()->ksort();
345345
foreach ($this as $item) {
346346
$items[] = $this->itemToString($item);

src/Helper/HeadMeta.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ class HeadMeta extends Placeholder\Container\AbstractStandalone
3939
*
4040
* @var array
4141
*/
42-
protected $typeKeys = array('name', 'http-equiv', 'charset', 'property', 'itemprop');
42+
protected $typeKeys = ['name', 'http-equiv', 'charset', 'property', 'itemprop'];
4343

4444
/**
4545
* Required attributes for meta tag
4646
*
4747
* @var array
4848
*/
49-
protected $requiredKeys = array('content');
49+
protected $requiredKeys = ['content'];
5050

5151
/**
5252
* Allowed modifier keys
5353
*
5454
* @var array
5555
*/
56-
protected $modifierKeys = array('lang', 'scheme');
56+
protected $modifierKeys = ['lang', 'scheme'];
5757

5858
/**
5959
* Registry key for placeholder
@@ -89,7 +89,7 @@ public function __invoke(
8989
$content = null,
9090
$keyValue = null,
9191
$keyType = 'name',
92-
$modifiers = array(),
92+
$modifiers = [],
9393
$placement = Placeholder\Container\AbstractContainer::APPEND
9494
) {
9595
if ((null !== $content) && (null !== $keyValue)) {
@@ -140,7 +140,7 @@ public function __call($method, $args)
140140
}
141141

142142
if (3 > $argc) {
143-
$args[] = array();
143+
$args[] = [];
144144
}
145145

146146
$item = $this->createData($type, $args[0], $args[1], $args[2]);
@@ -169,7 +169,7 @@ public function toString($indent = null)
169169
? $this->getWhitespace($indent)
170170
: $this->getIndent();
171171

172-
$items = array();
172+
$items = [];
173173
$this->getContainer()->ksort();
174174

175175
try {
@@ -453,7 +453,7 @@ public function setCharset($charset)
453453
$item->type = 'charset';
454454
$item->charset = $charset;
455455
$item->content = null;
456-
$item->modifiers = array();
456+
$item->modifiers = [];
457457
$this->set($item);
458458

459459
return $this;

src/Helper/HeadScript.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,20 @@ class HeadScript extends Placeholder\Container\AbstractStandalone
8383
*
8484
* @var array
8585
*/
86-
protected $optionalAttributes = array(
86+
protected $optionalAttributes = [
8787
'charset',
8888
'crossorigin',
8989
'defer',
9090
'language',
9191
'src',
92-
);
92+
];
9393

9494
/**
9595
* Required attributes for script tag
9696
*
9797
* @var string
9898
*/
99-
protected $requiredAttributes = array('type');
99+
protected $requiredAttributes = ['type'];
100100

101101
/**
102102
* Whether or not to format scripts using CDATA; used only if doctype
@@ -135,7 +135,7 @@ public function __invoke(
135135
$mode = self::FILE,
136136
$spec = null,
137137
$placement = 'APPEND',
138-
array $attrs = array(),
138+
array $attrs = [],
139139
$type = 'text/javascript'
140140
) {
141141
if ((null !== $spec) && is_string($spec)) {
@@ -178,7 +178,7 @@ public function __call($method, $args)
178178
$action = $matches['action'];
179179
$mode = strtolower($matches['mode']);
180180
$type = 'text/javascript';
181-
$attrs = array();
181+
$attrs = [];
182182

183183
if ('offsetSet' == $action) {
184184
$index = array_shift($args);
@@ -249,7 +249,7 @@ public function toString($indent = null)
249249
$escapeStart = ($useCdata) ? '//<![CDATA[' : '//<!--';
250250
$escapeEnd = ($useCdata) ? '//]]>' : '//-->';
251251

252-
$items = array();
252+
$items = [];
253253
$this->getContainer()->ksort();
254254
foreach ($this as $item) {
255255
if (!$this->isValid($item)) {
@@ -274,7 +274,7 @@ public function toString($indent = null)
274274
public function captureStart(
275275
$captureType = Placeholder\Container\AbstractContainer::APPEND,
276276
$type = 'text/javascript',
277-
$attrs = array()
277+
$attrs = []
278278
) {
279279
if ($this->captureLock) {
280280
throw new Exception\RuntimeException('Cannot nest headScript captures');
@@ -387,7 +387,7 @@ public function itemToString($item, $indent, $escapeStart, $escapeEnd)
387387
if (!empty($item->attributes)) {
388388
foreach ($item->attributes as $key => $value) {
389389
if ((!$this->arbitraryAttributesAllowed() && !in_array($key, $this->optionalAttributes))
390-
|| in_array($key, array('conditional', 'noescape'))) {
390+
|| in_array($key, ['conditional', 'noescape'])) {
391391
continue;
392392
}
393393
if ('defer' == $key) {

src/Helper/HeadStyle.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ class HeadStyle extends Placeholder\Container\AbstractStandalone
3636
*
3737
* @var array
3838
*/
39-
protected $optionalAttributes = array('lang', 'title', 'media', 'dir');
39+
protected $optionalAttributes = ['lang', 'title', 'media', 'dir'];
4040

4141
/**
4242
* Allowed media types
4343
*
4444
* @var array
4545
*/
46-
protected $mediaTypes = array(
46+
protected $mediaTypes = [
4747
'all', 'aural', 'braille', 'handheld', 'print',
4848
'projection', 'screen', 'tty', 'tv'
49-
);
49+
];
5050

5151
/**
5252
* Capture type and/or attributes (used for hinting during capture)
@@ -91,7 +91,7 @@ public function __construct()
9191
* @param string|array $attributes Optional attributes to utilize
9292
* @return HeadStyle
9393
*/
94-
public function __invoke($content = null, $placement = 'APPEND', $attributes = array())
94+
public function __invoke($content = null, $placement = 'APPEND', $attributes = [])
9595
{
9696
if ((null !== $content) && is_string($content)) {
9797
switch (strtoupper($placement)) {
@@ -142,7 +142,7 @@ public function __call($method, $args)
142142
}
143143

144144
$content = $args[0];
145-
$attrs = array();
145+
$attrs = [];
146146
if (isset($args[1])) {
147147
$attrs = (array) $args[1];
148148
}
@@ -173,7 +173,7 @@ public function toString($indent = null)
173173
? $this->getWhitespace($indent)
174174
: $this->getIndent();
175175

176-
$items = array();
176+
$items = [];
177177
$this->getContainer()->ksort();
178178
foreach ($this as $item) {
179179
if (!$this->isValid($item)) {

src/Helper/HeadTitle.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function toString($indent = null)
107107
*/
108108
public function renderTitle()
109109
{
110-
$items = array();
110+
$items = [];
111111

112112
if (null !== ($translator = $this->getTranslator())) {
113113
foreach ($this as $item) {
@@ -148,11 +148,11 @@ public function renderTitle()
148148
*/
149149
public function setDefaultAttachOrder($setType)
150150
{
151-
if (!in_array($setType, array(
151+
if (!in_array($setType, [
152152
Placeholder\Container\AbstractContainer::APPEND,
153153
Placeholder\Container\AbstractContainer::SET,
154154
Placeholder\Container\AbstractContainer::PREPEND
155-
))) {
155+
])) {
156156
throw new Exception\DomainException(
157157
"You must use a valid attach order: 'PREPEND', 'APPEND' or 'SET'"
158158
);

0 commit comments

Comments
 (0)