Skip to content

Commit b6cfccd

Browse files
committed
switched array() to []
1 parent c9b09fe commit b6cfccd

12 files changed

+105
-105
lines changed

Key.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class Key
2020
{
2121
private $resource;
2222
private $expiringTime;
23-
private $state = array();
23+
private $state = [];
2424

2525
/**
2626
* @param string $resource

Lock.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function acquire($blocking = false)
7676
}
7777

7878
$this->dirty = true;
79-
$this->logger->info('Successfully acquired the "{resource}" lock.', array('resource' => $this->key));
79+
$this->logger->info('Successfully acquired the "{resource}" lock.', ['resource' => $this->key]);
8080

8181
if ($this->ttl) {
8282
$this->refresh();
@@ -89,15 +89,15 @@ public function acquire($blocking = false)
8989
return true;
9090
} catch (LockConflictedException $e) {
9191
$this->dirty = false;
92-
$this->logger->notice('Failed to acquire the "{resource}" lock. Someone else already acquired the lock.', array('resource' => $this->key));
92+
$this->logger->notice('Failed to acquire the "{resource}" lock. Someone else already acquired the lock.', ['resource' => $this->key]);
9393

9494
if ($blocking) {
9595
throw $e;
9696
}
9797

9898
return false;
9999
} catch (\Exception $e) {
100-
$this->logger->notice('Failed to acquire the "{resource}" lock.', array('resource' => $this->key, 'exception' => $e));
100+
$this->logger->notice('Failed to acquire the "{resource}" lock.', ['resource' => $this->key, 'exception' => $e]);
101101
throw new LockAcquiringException(sprintf('Failed to acquire the "%s" lock.', $this->key), 0, $e);
102102
}
103103
}
@@ -120,13 +120,13 @@ public function refresh()
120120
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $this->key));
121121
}
122122

123-
$this->logger->info('Expiration defined for "{resource}" lock for "{ttl}" seconds.', array('resource' => $this->key, 'ttl' => $this->ttl));
123+
$this->logger->info('Expiration defined for "{resource}" lock for "{ttl}" seconds.', ['resource' => $this->key, 'ttl' => $this->ttl]);
124124
} catch (LockConflictedException $e) {
125125
$this->dirty = false;
126-
$this->logger->notice('Failed to define an expiration for the "{resource}" lock, someone else acquired the lock.', array('resource' => $this->key));
126+
$this->logger->notice('Failed to define an expiration for the "{resource}" lock, someone else acquired the lock.', ['resource' => $this->key]);
127127
throw $e;
128128
} catch (\Exception $e) {
129-
$this->logger->notice('Failed to define an expiration for the "{resource}" lock.', array('resource' => $this->key, 'exception' => $e));
129+
$this->logger->notice('Failed to define an expiration for the "{resource}" lock.', ['resource' => $this->key, 'exception' => $e]);
130130
throw new LockAcquiringException(sprintf('Failed to define an expiration for the "%s" lock.', $this->key), 0, $e);
131131
}
132132
}
@@ -148,7 +148,7 @@ public function release()
148148
$this->dirty = false;
149149

150150
if ($this->store->exists($this->key)) {
151-
$this->logger->notice('Failed to release the "{resource}" lock.', array('resource' => $this->key));
151+
$this->logger->notice('Failed to release the "{resource}" lock.', ['resource' => $this->key]);
152152
throw new LockReleasingException(sprintf('Failed to release the "%s" lock.', $this->key));
153153
}
154154
}

Store/CombinedStore.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function save(Key $key)
6969
$store->save($key);
7070
++$successCount;
7171
} catch (\Exception $e) {
72-
$this->logger->warning('One store failed to save the "{resource}" lock.', array('resource' => $key, 'store' => $store, 'exception' => $e));
72+
$this->logger->warning('One store failed to save the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]);
7373
++$failureCount;
7474
}
7575

@@ -82,7 +82,7 @@ public function save(Key $key)
8282
return;
8383
}
8484

85-
$this->logger->warning('Failed to store the "{resource}" lock. Quorum has not been met.', array('resource' => $key, 'success' => $successCount, 'failure' => $failureCount));
85+
$this->logger->warning('Failed to store the "{resource}" lock. Quorum has not been met.', ['resource' => $key, 'success' => $successCount, 'failure' => $failureCount]);
8686

8787
// clean up potential locks
8888
$this->delete($key);
@@ -108,15 +108,15 @@ public function putOffExpiration(Key $key, $ttl)
108108
foreach ($this->stores as $store) {
109109
try {
110110
if (0.0 >= $adjustedTtl = $expireAt - microtime(true)) {
111-
$this->logger->warning('Stores took to long to put off the expiration of the "{resource}" lock.', array('resource' => $key, 'store' => $store, 'ttl' => $ttl));
111+
$this->logger->warning('Stores took to long to put off the expiration of the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'ttl' => $ttl]);
112112
$key->reduceLifetime(0);
113113
break;
114114
}
115115

116116
$store->putOffExpiration($key, $adjustedTtl);
117117
++$successCount;
118118
} catch (\Exception $e) {
119-
$this->logger->warning('One store failed to put off the expiration of the "{resource}" lock.', array('resource' => $key, 'store' => $store, 'exception' => $e));
119+
$this->logger->warning('One store failed to put off the expiration of the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]);
120120
++$failureCount;
121121
}
122122

@@ -133,7 +133,7 @@ public function putOffExpiration(Key $key, $ttl)
133133
return;
134134
}
135135

136-
$this->logger->warning('Failed to define the expiration for the "{resource}" lock. Quorum has not been met.', array('resource' => $key, 'success' => $successCount, 'failure' => $failureCount));
136+
$this->logger->warning('Failed to define the expiration for the "{resource}" lock. Quorum has not been met.', ['resource' => $key, 'success' => $successCount, 'failure' => $failureCount]);
137137

138138
// clean up potential locks
139139
$this->delete($key);
@@ -150,7 +150,7 @@ public function delete(Key $key)
150150
try {
151151
$store->delete($key);
152152
} catch (\Exception $e) {
153-
$this->logger->notice('One store failed to delete the "{resource}" lock.', array('resource' => $key, 'store' => $store, 'exception' => $e));
153+
$this->logger->notice('One store failed to delete the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]);
154154
}
155155
}
156156
}

Store/MemcachedStore.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,15 @@ private function getValueAndCas(Key $key)
173173
if ($this->useExtendedReturn) {
174174
$extendedReturn = $this->memcached->get((string) $key, null, \Memcached::GET_EXTENDED);
175175
if (\Memcached::GET_ERROR_RETURN_VALUE === $extendedReturn) {
176-
return array($extendedReturn, 0.0);
176+
return [$extendedReturn, 0.0];
177177
}
178178

179-
return array($extendedReturn['value'], $extendedReturn['cas']);
179+
return [$extendedReturn['value'], $extendedReturn['cas']];
180180
}
181181

182182
$cas = 0.0;
183183
$value = $this->memcached->get((string) $key, null, $cas);
184184

185-
return array($value, $cas);
185+
return [$value, $cas];
186186
}
187187
}

Store/RedisStore.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function save(Key $key)
6262
';
6363

6464
$key->reduceLifetime($this->initialTtl);
65-
if (!$this->evaluate($script, (string) $key, array($this->getToken($key), (int) ceil($this->initialTtl * 1000)))) {
65+
if (!$this->evaluate($script, (string) $key, [$this->getToken($key), (int) ceil($this->initialTtl * 1000)])) {
6666
throw new LockConflictedException();
6767
}
6868

@@ -90,7 +90,7 @@ public function putOffExpiration(Key $key, $ttl)
9090
';
9191

9292
$key->reduceLifetime($ttl);
93-
if (!$this->evaluate($script, (string) $key, array($this->getToken($key), (int) ceil($ttl * 1000)))) {
93+
if (!$this->evaluate($script, (string) $key, [$this->getToken($key), (int) ceil($ttl * 1000)])) {
9494
throw new LockConflictedException();
9595
}
9696

@@ -112,7 +112,7 @@ public function delete(Key $key)
112112
end
113113
';
114114

115-
$this->evaluate($script, (string) $key, array($this->getToken($key)));
115+
$this->evaluate($script, (string) $key, [$this->getToken($key)]);
116116
}
117117

118118
/**
@@ -135,15 +135,15 @@ public function exists(Key $key)
135135
private function evaluate($script, $resource, array $args)
136136
{
137137
if ($this->redis instanceof \Redis || $this->redis instanceof \RedisCluster || $this->redis instanceof RedisProxy) {
138-
return $this->redis->eval($script, array_merge(array($resource), $args), 1);
138+
return $this->redis->eval($script, array_merge([$resource], $args), 1);
139139
}
140140

141141
if ($this->redis instanceof \RedisArray) {
142-
return $this->redis->_instance($this->redis->_target($resource))->eval($script, array_merge(array($resource), $args), 1);
142+
return $this->redis->_instance($this->redis->_target($resource))->eval($script, array_merge([$resource], $args), 1);
143143
}
144144

145145
if ($this->redis instanceof \Predis\Client) {
146-
return \call_user_func_array(array($this->redis, 'eval'), array_merge(array($script, 1, $resource), $args));
146+
return \call_user_func_array([$this->redis, 'eval'], array_merge([$script, 1, $resource], $args));
147147
}
148148

149149
throw new InvalidArgumentException(sprintf('%s() expects being initialized with a Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis)));

Store/RetryTillSaveStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function waitAndSave(Key $key)
7171
}
7272
} while (++$retry < $this->retryCount);
7373

74-
$this->logger->warning('Failed to store the "{resource}" lock. Abort after {retry} retry.', array('resource' => $key, 'retry' => $retry));
74+
$this->logger->warning('Failed to store the "{resource}" lock. Abort after {retry} retry.', ['resource' => $key, 'retry' => $retry]);
7575

7676
throw new LockConflictedException();
7777
}

Tests/LockTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function testReleaseOnDestruction()
140140

141141
$store
142142
->method('exists')
143-
->willReturnOnConsecutiveCalls(array(true, false))
143+
->willReturnOnConsecutiveCalls([true, false])
144144
;
145145
$store
146146
->expects($this->once())
@@ -159,7 +159,7 @@ public function testNoAutoReleaseWhenNotConfigured()
159159

160160
$store
161161
->method('exists')
162-
->willReturnOnConsecutiveCalls(array(true, false))
162+
->willReturnOnConsecutiveCalls([true, false])
163163
;
164164
$store
165165
->expects($this->never())
@@ -206,7 +206,7 @@ public function testReleaseThrowsAndLog()
206206

207207
$logger->expects($this->atLeastOnce())
208208
->method('notice')
209-
->with('Failed to release the "{resource}" lock.', array('resource' => $key));
209+
->with('Failed to release the "{resource}" lock.', ['resource' => $key]);
210210

211211
$store
212212
->expects($this->once())
@@ -243,12 +243,12 @@ public function testExpiration($ttls, $expected)
243243

244244
public function provideExpiredDates()
245245
{
246-
yield array(array(-0.1), true);
247-
yield array(array(0.1, -0.1), true);
248-
yield array(array(-0.1, 0.1), true);
246+
yield [[-0.1], true];
247+
yield [[0.1, -0.1], true];
248+
yield [[-0.1, 0.1], true];
249249

250-
yield array(array(), false);
251-
yield array(array(0.1), false);
252-
yield array(array(-0.1, null), false);
250+
yield [[], false];
251+
yield [[0.1], false];
252+
yield [[-0.1, null], false];
253253
}
254254
}

Tests/Store/BlockingStoreTestTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ public function testBlockingLocks()
5151
$parentPID = posix_getpid();
5252

5353
// Block SIGHUP signal
54-
pcntl_sigprocmask(SIG_BLOCK, array(SIGHUP));
54+
pcntl_sigprocmask(SIG_BLOCK, [SIGHUP]);
5555

5656
if ($childPID = pcntl_fork()) {
5757
// Wait the start of the child
58-
pcntl_sigwaitinfo(array(SIGHUP), $info);
58+
pcntl_sigwaitinfo([SIGHUP], $info);
5959

6060
try {
6161
// This call should failed given the lock should already by acquired by the child
@@ -77,14 +77,14 @@ public function testBlockingLocks()
7777
$this->assertSame(0, pcntl_wexitstatus($status1), 'The child process couldn\'t lock the resource');
7878
} else {
7979
// Block SIGHUP signal
80-
pcntl_sigprocmask(SIG_BLOCK, array(SIGHUP));
80+
pcntl_sigprocmask(SIG_BLOCK, [SIGHUP]);
8181
try {
8282
$store->save($key);
8383
// send the ready signal to the parent
8484
posix_kill($parentPID, SIGHUP);
8585

8686
// Wait for the parent to be ready
87-
pcntl_sigwaitinfo(array(SIGHUP), $info);
87+
pcntl_sigwaitinfo([SIGHUP], $info);
8888

8989
// Wait ClockDelay to let parent assert to finish
9090
usleep($clockDelay);

Tests/Store/CombinedStoreTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getStore()
4646
self::markTestSkipped($e->getMessage());
4747
}
4848

49-
return new CombinedStore(array(new RedisStore($redis)), new UnanimousStrategy());
49+
return new CombinedStore([new RedisStore($redis)], new UnanimousStrategy());
5050
}
5151

5252
/** @var \PHPUnit_Framework_MockObject_MockObject */
@@ -64,7 +64,7 @@ protected function setUp()
6464
$this->store1 = $this->getMockBuilder(StoreInterface::class)->getMock();
6565
$this->store2 = $this->getMockBuilder(StoreInterface::class)->getMock();
6666

67-
$this->store = new CombinedStore(array($this->store1, $this->store2), $this->strategy);
67+
$this->store = new CombinedStore([$this->store1, $this->store2], $this->strategy);
6868
}
6969

7070
/**
@@ -269,7 +269,7 @@ public function testPutOffExpirationIgnoreNonExpiringStorage()
269269
$store1 = $this->getMockBuilder(StoreInterface::class)->getMock();
270270
$store2 = $this->getMockBuilder(StoreInterface::class)->getMock();
271271

272-
$store = new CombinedStore(array($store1, $store2), $this->strategy);
272+
$store = new CombinedStore([$store1, $store2], $this->strategy);
273273

274274
$key = new Key(uniqid(__METHOD__, true));
275275
$ttl = random_int(1, 10);

Tests/Store/RedisArrayStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static function setupBeforeClass()
3131

3232
protected function getRedisConnection()
3333
{
34-
$redis = new \RedisArray(array(getenv('REDIS_HOST')));
34+
$redis = new \RedisArray([getenv('REDIS_HOST')]);
3535

3636
return $redis;
3737
}

Tests/Strategy/ConsensusStrategyTest.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,45 +30,45 @@ protected function setUp()
3030
public function provideMetResults()
3131
{
3232
// success, failure, total, isMet
33-
yield array(3, 0, 3, true);
34-
yield array(2, 1, 3, true);
35-
yield array(2, 0, 3, true);
36-
yield array(1, 2, 3, false);
37-
yield array(1, 1, 3, false);
38-
yield array(1, 0, 3, false);
39-
yield array(0, 3, 3, false);
40-
yield array(0, 2, 3, false);
41-
yield array(0, 1, 3, false);
42-
yield array(0, 0, 3, false);
33+
yield [3, 0, 3, true];
34+
yield [2, 1, 3, true];
35+
yield [2, 0, 3, true];
36+
yield [1, 2, 3, false];
37+
yield [1, 1, 3, false];
38+
yield [1, 0, 3, false];
39+
yield [0, 3, 3, false];
40+
yield [0, 2, 3, false];
41+
yield [0, 1, 3, false];
42+
yield [0, 0, 3, false];
4343

44-
yield array(2, 0, 2, true);
45-
yield array(1, 1, 2, false);
46-
yield array(1, 0, 2, false);
47-
yield array(0, 2, 2, false);
48-
yield array(0, 1, 2, false);
49-
yield array(0, 0, 2, false);
44+
yield [2, 0, 2, true];
45+
yield [1, 1, 2, false];
46+
yield [1, 0, 2, false];
47+
yield [0, 2, 2, false];
48+
yield [0, 1, 2, false];
49+
yield [0, 0, 2, false];
5050
}
5151

5252
public function provideIndeterminate()
5353
{
5454
// success, failure, total, canBeMet
55-
yield array(3, 0, 3, true);
56-
yield array(2, 1, 3, true);
57-
yield array(2, 0, 3, true);
58-
yield array(1, 2, 3, false);
59-
yield array(1, 1, 3, true);
60-
yield array(1, 0, 3, true);
61-
yield array(0, 3, 3, false);
62-
yield array(0, 2, 3, false);
63-
yield array(0, 1, 3, true);
64-
yield array(0, 0, 3, true);
55+
yield [3, 0, 3, true];
56+
yield [2, 1, 3, true];
57+
yield [2, 0, 3, true];
58+
yield [1, 2, 3, false];
59+
yield [1, 1, 3, true];
60+
yield [1, 0, 3, true];
61+
yield [0, 3, 3, false];
62+
yield [0, 2, 3, false];
63+
yield [0, 1, 3, true];
64+
yield [0, 0, 3, true];
6565

66-
yield array(2, 0, 2, true);
67-
yield array(1, 1, 2, false);
68-
yield array(1, 0, 2, true);
69-
yield array(0, 2, 2, false);
70-
yield array(0, 1, 2, false);
71-
yield array(0, 0, 2, true);
66+
yield [2, 0, 2, true];
67+
yield [1, 1, 2, false];
68+
yield [1, 0, 2, true];
69+
yield [0, 2, 2, false];
70+
yield [0, 1, 2, false];
71+
yield [0, 0, 2, true];
7272
}
7373

7474
/**

0 commit comments

Comments
 (0)