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

Commit d0ebf57

Browse files
committed
Merge branch 'feature/php-short-array-syntax'
2 parents cf352da + 26fcc32 commit d0ebf57

File tree

70 files changed

+706
-705
lines changed

Some content is hidden

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

70 files changed

+706
-705
lines changed

.php_cs

Lines changed: 1 addition & 0 deletions
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/AbstractOptions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function setFromArray($options)
7272
*/
7373
public function toArray()
7474
{
75-
$array = array();
75+
$array = [];
7676
$transform = function ($letters) {
7777
$letter = array_shift($letters);
7878
return '_' . strtolower($letter);
@@ -100,7 +100,7 @@ public function __set($key, $value)
100100
{
101101
$setter = 'set' . str_replace('_', '', $key);
102102

103-
if (is_callable(array($this, $setter))) {
103+
if (is_callable([$this, $setter])) {
104104
$this->{$setter}($value);
105105

106106
return;
@@ -128,7 +128,7 @@ public function __get($key)
128128
{
129129
$getter = 'get' . str_replace('_', '', $key);
130130

131-
if (is_callable(array($this, $getter))) {
131+
if (is_callable([$this, $getter])) {
132132
return $this->{$getter}();
133133
}
134134

src/ArrayObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ArrayObject implements IteratorAggregate, ArrayAccess, Serializable, Count
5959
* @param int $flags
6060
* @param string $iteratorClass
6161
*/
62-
public function __construct($input = array(), $flags = self::STD_PROP_LIST, $iteratorClass = 'ArrayIterator')
62+
public function __construct($input = [], $flags = self::STD_PROP_LIST, $iteratorClass = 'ArrayIterator')
6363
{
6464
$this->setFlags($flags);
6565
$this->storage = $input;

src/ArrayUtils.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public static function iteratorToArray($iterator, $recursive = true)
231231
return $iterator->toArray();
232232
}
233233

234-
$array = array();
234+
$array = [];
235235
foreach ($iterator as $key => $value) {
236236
if (is_scalar($value)) {
237237
$array[$key] = $value;
@@ -312,16 +312,16 @@ public static function filter(array $data, $callback, $flag = null)
312312
return array_filter($data, $callback, $flag);
313313
}
314314

315-
$output = array();
315+
$output = [];
316316
foreach ($data as $key => $value) {
317-
$params = array($value);
317+
$params = [$value];
318318

319319
if ($flag === static::ARRAY_FILTER_USE_BOTH) {
320320
$params[] = $key;
321321
}
322322

323323
if ($flag === static::ARRAY_FILTER_USE_KEY) {
324-
$params = array($key);
324+
$params = [$key];
325325
}
326326

327327
$response = call_user_func_array($callback, $params);

src/CallbackHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CallbackHandler
3737
* @param string|array|object|callable $callback PHP callback
3838
* @param array $metadata Callback metadata
3939
*/
40-
public function __construct($callback, array $metadata = array())
40+
public function __construct($callback, array $metadata = [])
4141
{
4242
$this->metadata = $metadata;
4343
$this->registerCallback($callback);
@@ -75,7 +75,7 @@ public function getCallback()
7575
* @param array $args Arguments to pass to callback
7676
* @return mixed
7777
*/
78-
public function call(array $args = array())
78+
public function call(array $args = [])
7979
{
8080
$callback = $this->getCallback();
8181
$argCount = count($args);
@@ -187,6 +187,6 @@ protected function validateStringCallbackFor54($callback)
187187
// returning a non boolean value may not be nice for a validate method,
188188
// but that allows the usage of a static string callback without using
189189
// the call_user_func function.
190-
return array($class, $method);
190+
return [$class, $method];
191191
}
192192
}

src/ErrorHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ abstract class ErrorHandler
2222
*
2323
* @var array
2424
*/
25-
protected static $stack = array();
25+
protected static $stack = [];
2626

2727
/**
2828
* Check if this error handler is active
@@ -52,7 +52,7 @@ public static function getNestedLevel()
5252
public static function start($errorLevel = \E_WARNING)
5353
{
5454
if (!static::$stack) {
55-
set_error_handler(array(get_called_class(), 'addError'), $errorLevel);
55+
set_error_handler([get_called_class(), 'addError'], $errorLevel);
5656
}
5757

5858
static::$stack[] = null;
@@ -95,7 +95,7 @@ public static function clean()
9595
restore_error_handler();
9696
}
9797

98-
static::$stack = array();
98+
static::$stack = [];
9999
}
100100

101101
/**

src/Glob.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ public static function glob($pattern, $flags = 0, $forceFallback = false)
5656
protected static function systemGlob($pattern, $flags)
5757
{
5858
if ($flags) {
59-
$flagMap = array(
59+
$flagMap = [
6060
self::GLOB_MARK => GLOB_MARK,
6161
self::GLOB_NOSORT => GLOB_NOSORT,
6262
self::GLOB_NOCHECK => GLOB_NOCHECK,
6363
self::GLOB_NOESCAPE => GLOB_NOESCAPE,
6464
self::GLOB_BRACE => GLOB_BRACE,
6565
self::GLOB_ONLYDIR => GLOB_ONLYDIR,
6666
self::GLOB_ERR => GLOB_ERR,
67-
);
67+
];
6868

6969
$globFlags = 0;
7070

@@ -102,7 +102,7 @@ protected static function fallbackGlob($pattern, $flags)
102102

103103
$flags &= ~self::GLOB_BRACE;
104104
$length = strlen($pattern);
105-
$paths = array();
105+
$paths = [];
106106

107107
if ($flags & self::GLOB_NOESCAPE) {
108108
$begin = strpos($pattern, '{');

src/Hydrator/Aggregate/AggregateHydrator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function hydrate(array $data, $object)
6666
*/
6767
public function setEventManager(EventManagerInterface $eventManager)
6868
{
69-
$eventManager->setIdentifiers(array(__CLASS__, get_class($this)));
69+
$eventManager->setIdentifiers([__CLASS__, get_class($this)]);
7070

7171
$this->eventManager = $eventManager;
7272
}

src/Hydrator/Aggregate/ExtractEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ExtractEvent extends Event
3232
/**
3333
* @var array
3434
*/
35-
protected $extractedData = array();
35+
protected $extractedData = [];
3636

3737
/**
3838
* @param object $target

src/Hydrator/Aggregate/HydratorListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public function __construct(HydratorInterface $hydrator)
3838
*/
3939
public function attach(EventManagerInterface $events, $priority = 1)
4040
{
41-
$this->listeners[] = $events->attach(HydrateEvent::EVENT_HYDRATE, array($this, 'onHydrate'), $priority);
42-
$this->listeners[] = $events->attach(ExtractEvent::EVENT_EXTRACT, array($this, 'onExtract'), $priority);
41+
$this->listeners[] = $events->attach(HydrateEvent::EVENT_HYDRATE, [$this, 'onHydrate'], $priority);
42+
$this->listeners[] = $events->attach(ExtractEvent::EVENT_EXTRACT, [$this, 'onExtract'], $priority);
4343
}
4444

4545
/**

0 commit comments

Comments
 (0)