8000 switched array() to [] · symfony/cache@1e64ba4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1e64ba4

Browse files
committed
switched array() to []
1 parent 8605640 commit 1e64ba4

File tree

70 files changed

+434
-434
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

+434
-434
lines changed

Adapter/AbstractAdapter.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ function ($key, $value, $isHit) use ($defaultLifetime) {
5959
$getId = function ($key) { return $this->getId((string) $key); };
6060
$this->mergeByLifetime = \Closure::bind(
6161
function ($deferred, $namespace, &$expiredIds) use ($getId) {
62-
$byLifetime = array();
62+
$byLifetime = [];
6363
$now = time();
64-
$expiredIds = array();
64+
$expiredIds = [];
6565

6666
foreach ($deferred as $key => $item) {
6767
if (null === $item->expiry) {
@@ -123,10 +123,10 @@ public static function createSystemCache($namespace, $defaultLifetime, $version,
123123
$apcu->setLogger($logger);
124124
}
125125

126-
return new ChainAdapter(array($apcu, $fs));
126+
return new ChainAdapter([$apcu, $fs]);
127127
}
128128

129-
public static function createConnection($dsn, array $options = array())
129+
public static function createConnection($dsn, array $options = [])
130130
{
131131
if (!\is_string($dsn)) {
132132
throw new InvalidArgumentException(sprintf('The %s() method expect argument #1 to be string, %s given.', __METHOD__, \gettype($dsn)));
@@ -156,11 +156,11 @@ public function getItem($key)
156156
$value = null;
157157

158158
try {
159-
foreach ($this->doFetch(array($id)) as $value) {
159+
foreach ($this->doFetch([$id]) as $value) {
160160
$isHit = true;
161161
}
162162
} catch (\Exception $e) {
163-
CacheItem::log($this->logger, 'Failed to fetch key "{key}"', array('key' => $key, 'exception' => $e));
163+
CacheItem::log($this->logger, 'Failed to fetch key "{key}"', ['key' => $key, 'exception' => $e]);
164164
}
165165

166166
return $f($key, $value, $isHit);
@@ -169,21 +169,21 @@ public function getItem($key)
169169
/**
170170
* {@inheritdoc}
171171
*/
172-
public function getItems(array $keys = array())
172+
public function getItems(array $keys = [])
173173
{
174174
if ($this->deferred) {
175175
$this->commit();
176176
}
177-
$ids = array();
177+
$ids = [];
178178

179179
foreach ($keys as $key) {
180180
$ids[] = $this->getId($key);
181181
}
182182
try {
183183
$items = $this->doFetch($ids);
184184
} catch (\Exception $e) {
185-
CacheItem::log($this->logger, 'Failed to fetch requested items', array('keys' => $keys, 'exception' => $e));
186-
$items = array();
185+
CacheItem::log($this->logger, 'Failed to fetch requested items', ['keys' => $keys, 'exception' => $e]);
186+
$items = [];
187187
}
188188
$ids = array_combine($ids, $keys);
189189

@@ -224,7 +224,7 @@ public function commit()
224224
$ok = true;
225225
$byLifetime = $this->mergeByLifetime;
226226
$byLifetime = $byLifetime($this->deferred, $this->namespace, $expiredIds);
227-
$retry = $this->deferred = array();
227+
$retry = $this->deferred = [];
228228

229229
if ($expiredIds) {
230230
$this->doDelete($expiredIds);
@@ -234,15 +234,15 @@ public function commit()
234234
$e = $this->doSave($values, $lifetime);
235235
} catch (\Exception $e) {
236236
}
237-
if (true === $e || array() === $e) {
237+
if (true === $e || [] === $e) {
238238
continue;
239239
}
240240
if (\is_array($e) || 1 === \count($values)) {
241241
foreach (\is_array($e) ? $e : array_keys($values) as $id) {
242242
$ok = false;
243243
$v = $values[$id];
244244
$type = \is_object($v) ? \get_class($v) : \gettype($v);
245-
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null));
245+
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', ['key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null]);
246246
}
247247
} else {
248248
foreach ($values as $id => $v) {
@@ -256,15 +256,15 @@ public function commit()
256256
foreach ($ids as $id) {
257257
try {
258258
$v = $byLifetime[$lifetime][$id];
259-
$e = $this->doSave(array($id => $v), $lifetime);
259+
$e = $this->doSave([$id => $v], $lifetime);
260260
} catch (\Exception $e) {
261261
}
262-
if (true === $e || array() === $e) {
262+
if (true === $e || [] === $e) {
263263
continue;
264264
}
265265
$ok = false;
266266
$type = \is_object($v) ? \get_class($v) : \gettype($v);
267-
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null));
267+
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', ['key' => substr($id, \strlen($this->namespace)), 'type' => $type, 'exception' => $e instanceof \Exception ? $e : null]);
268268
}
269269
}
270270

@@ -292,7 +292,7 @@ private function generateItems($items, &$keys)
292292
yield $key => $f($key, $value, true);
293293
}
294294
} catch (\Exception $e) {
295-
CacheItem::log($this->logger, 'Failed to fetch requested items', array('keys' => array_values($keys), 'exception' => $e));
295+
CacheItem::log($this->logger, 'Failed to fetch requested items', ['keys' => array_values($keys), 'exception' => $e]);
296296
}
297297

298298
foreach ($keys as $key) {

Adapter/AdapterInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ public function getItem($key);
3333
*
3434
* @return \Traversable|CacheItem[]
3535
*/
36-
public function getItems(array $keys = array());
36+
public function getItems(array $keys = []);
3737
}

Adapter/ArrayAdapter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function getItem($key)
6666
$isHit = false;
6767
}
6868
} catch (\Exception $e) {
69-
CacheItem::log($this->logger, 'Failed to unserialize key "{key}"', array('key' => $key, 'exception' => $e));
69+
CacheItem::log($this->logger, 'Failed to unserialize key "{key}"', ['key' => $key, 'exception' => $e]);
7070
$this->values[$key] = $value = null;
7171
$isHit = false;
7272
}
@@ -78,7 +78,7 @@ public function getItem($key)
7878
/**
7979
* {@inheritdoc}
8080
*/
81-
public function getItems(array $keys = array())
81+
public function getItems(array $keys = [])
8282
{
8383
foreach ($keys as $key) {
8484
CacheItem::validateKey($key);
@@ -122,7 +122,7 @@ public function save(CacheItemInterface $item)
122122
$value = serialize($value);
123123
} catch (\Exception $e) {
124124
$type = \is_object($value) ? \get_class($value) : \gettype($value);
125-
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', array('key' => $key, 'type' => $type, 'exception' => $e));
125+
CacheItem::log($this->logger, 'Failed to save key "{key}" ({type})', ['key' => $key, 'type' => $type, 'exception' => $e]);
126126

127127
return false;
128128
}

Adapter/ChainAdapter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
class ChainAdapter implements AdapterInterface, PruneableInterface, ResettableInterface
3030
{
31-
private $adapters = array();
31+
private $adapters = [];
3232
private $adapterCount;
3333
private $syncItem;
3434

@@ -81,7 +81,7 @@ function ($sourceItem, $item) use ($defaultLifetime) {
8181
public function getItem($key)
8282
{
8383
$syncItem = $this->syncItem;
84-
$misses = array();
84+
$misses = [];
8585

8686
foreach ($this->adapters as $i => $adapter) {
8787
$item = $adapter->getItem($key);
@@ -103,15 +103,15 @@ public function getItem($key)
103103
/**
104104
* {@inheritdoc}
105105
*/
106-
public function getItems(array $keys = array())
106+
public function getItems(array $keys = [])
107107
{
108108
return $this->generateItems($this->adapters[0]->getItems($keys), 0);
109109
}
110110

111111
private function generateItems($items, $adapterIndex)
112112
{
113-
$missing = array();
114-
$misses = array();
113+
$missing = [];
114+
$misses = [];
115115
$nextAdapterIndex = $adapterIndex + 1;
116116
$nextAdapter = isset($this->adapters[$nextAdapterIndex]) ? $this->adapters[$nextAdapterIndex] : null;
117117

Adapter/NullAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public fun F41A ction getItem($key)
4949
/**
5050
* {@inheritdoc}
5151
*/
52-
public function getItems(array $keys = array())
52+
public function getItems(array $keys = [])
5353
{
5454
return $this->generateItems($keys);
5555
}

Adapter/PdoAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
4646
* @throws InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION
4747
* @throws InvalidArgumentException When namespace contains invalid characters
4848
*/
49-
public function __construct($connOrDsn, $namespace = '', $defaultLifetime = 0, array $options = array())
49+
public function __construct($connOrDsn, $namespace = '', $defaultLifetime = 0, array $options = [])
5050
{
5151
$this->init($connOrDsn, $namespace, $defaultLifetime, $options);
5252
}

Adapter/PhpArrayAdapter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function getItem($key)
120120
/**
121121
* {@inheritdoc}
122122
*/
123-
public function getItems(array $keys = array())
123+
public function getItems(array $keys = [])
124124
{
125125
foreach ($keys as $key) {
126126
if (!\is_string($key)) {
@@ -170,7 +170,7 @@ public function deleteItem($key)
170170
public function deleteItems(array $keys)
171171
{
172172
$deleted = true;
173-
$fallbackKeys = array();
173+
$fallbackKeys = [];
174174

175175
foreach ($keys as $key) {
176176
if (!\is_string($key)) {
@@ -232,7 +232,7 @@ public function commit()
232232
private function generateItems(array $keys)
233233
{
234234
$f = $this->createCacheItem;
235-
$fallbackKeys = array();
235+
$fallbackKeys = [];
236236

237237
foreach ($keys as $key) {
238238
if (isset($this->values[$key])) {
@@ -272,10 +272,10 @@ public static function throwOnRequiredClass($class)
272272
{
273273
$e = new \ReflectionException("Class $class does not exist");
274274
$trace = $e->getTrace();
275-
$autoloadFrame = array(
275+
$autoloadFrame = [
276276
'function' => 'spl_autoload_call',
277-
'args' => array($class),
278-
);
277+
'args' => [$class],
278+
];
279279
$i = 1 + array_search($autoloadFrame, $trace, true);
280280

281281
if (isset($trace[$i]['function']) && !isset($trace[$i]['class'])) {

Adapter/ProxyAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getItem($key)
7373
/**
7474
* {@inheritdoc}
7575
*/
76-
public function getItems(array $keys = array())
76+
public function getItems(array $keys = [])
7777
{
7878
if ($this->namespaceLen) {
7979
foreach ($keys as $i => $key) {

0 commit comments

Comments
 (0)
0