Skip to content

Commit 1b205bd

Browse files
wouterjnicolas-grekas
authored andcommitted
Add void return types
1 parent d6d67c8 commit 1b205bd

16 files changed

+158
-11
lines changed

Key.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ public function markUnserializable(): void
6060
$this->serializable = false;
6161
}
6262

63-
public function resetLifetime()
63+
public function resetLifetime(): void
6464
{
6565
$this->expiringTime = null;
6666
}
6767

6868
/**
6969
* @param float $ttl the expiration delay of locks in seconds
7070
*/
71-
public function reduceLifetime(float $ttl)
71+
public function reduceLifetime(float $ttl): void
7272
{
7373
$newTime = microtime(true) + $ttl;
7474

Lock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function acquireRead(bool $blocking = false): bool
182182
}
183183
}
184184

185-
public function refresh(float $ttl = null)
185+
public function refresh(float $ttl = null): void
186186
{
187187
if (!$ttl ??= $this->ttl) {
188188
throw new InvalidArgumentException('You have to define an expiration duration.');
@@ -218,7 +218,7 @@ public function isAcquired(): bool
218218
return $this->dirty = $this->store->exists($this->key);
219219
}
220220

221-
public function release()
221+
public function release(): void
222222
{
223223
try {
224224
try {

NoLock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function acquire(bool $blocking = false): bool
2626
return true;
2727
}
2828

29-
public function refresh(float $ttl = null)
29+
public function refresh(float $ttl = null): void
3030
{
3131
}
3232

@@ -35,7 +35,7 @@ public function isAcquired(): bool
3535
return true;
3636
}
3737

38-
public function release()
38+
public function release(): void
3939
{
4040
}
4141

Store/CombinedStore.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public function __construct(array $stores, StrategyInterface $strategy)
5353
$this->logger = new NullLogger();
5454
}
5555

56+
/**
57+
* @return void
58+
*/
5659
public function save(Key $key)
5760
{
5861
$successCount = 0;
@@ -87,6 +90,9 @@ public function save(Key $key)
8790
throw new LockConflictedException();
8891
}
8992

93+
/**
94+
* @return void
95+
*/
9096
public function saveRead(Key $key)
9197
{
9298
$successCount = 0;
@@ -125,6 +131,9 @@ public function saveRead(Key $key)
125131
throw new LockConflictedException();
126132
}
127133

134+
/**
135+
* @return void
136+
*/
128137
public function putOffExpiration(Key $key, float $ttl)
129138
{
130139
$successCount = 0;
@@ -166,6 +175,9 @@ public function putOffExpiration(Key $key, float $ttl)
166175
throw new LockConflictedException();
167176
}
168177

178+
/**
179+
* @return void
180+
*/
169181
public function delete(Key $key)
170182
{
171183
foreach ($this->stores as $store) {

Store/DoctrineDbalPostgreSqlStore.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public function __construct(#[\SensitiveParameter] Connection|string $connOrUrl)
5353
}
5454
}
5555

56+
/**
57+
* @return void
58+
*/
5659
public function save(Key $key)
5760
{
5861
// prevent concurrency within the same connection
@@ -85,6 +88,9 @@ public function save(Key $key)
8588
throw new LockConflictedException();
8689
}
8790

91+
/**
92+
* @return void
93+
*/
8894
public function saveRead(Key $key)
8995
{
9096
// prevent concurrency within the same connection
@@ -117,6 +123,9 @@ public function saveRead(Key $key)
117123
throw new LockConflictedException();
118124
}
119125

126+
/**
127+
* @return void
128+
*/
120129
public function putOffExpiration(Key $key, float $ttl)
121130
{
122131
// postgresql locks forever.
@@ -126,6 +135,9 @@ public function putOffExpiration(Key $key, float $ttl)
126135
}
127136
}
128137

138+
/**
139+
* @return void
140+
*/
129141
public function delete(Key $key)
130142
{
131143
// Prevent deleting locks own by an other key in the same connection
@@ -163,6 +175,9 @@ public function exists(Key $key): bool
163175
return false;
164176
}
165177

178+
/**
179+
* @return void
180+
*/
166181
public function waitAndSave(Key $key)
167182
{
168183
// prevent concurrency within the same connection
@@ -186,6 +201,9 @@ public function waitAndSave(Key $key)
186201
$this->unlockShared($key);
187202
}
188203

204+
/**
205+
* @return void
206+
*/
189207
public function waitAndSaveRead(Key $key)
190208
{
191209
// prevent concurrency within the same connection

Store/DoctrineDbalStore.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public function __construct(Connection|string $connOrUrl, array $options = [], f
7272
}
7373
}
7474

75+
/**
76+
* @return void
77+
*/
7578
public function save(Key $key)
7679
{
7780
$key->reduceLifetime($this->initialTtl);
@@ -111,6 +114,9 @@ public function save(Key $key)
111114
$this->checkNotExpired($key);
112115
}
113116

117+
/**
118+
* @return void
119+
*/
114120
public function putOffExpiration(Key $key, $ttl)
115121
{
116122
if ($ttl < 1) {
@@ -142,6 +148,9 @@ public function putOffExpiration(Key $key, $ttl)
142148
$this->checkNotExpired($key);
143149
}
144150

151+
/**
152+
* @return void
153+
*/
145154
public function delete(Key $key)
146155
{
147156
$this->conn->delete($this->table, [

Store/ExpiringStoreTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
trait ExpiringStoreTrait
1818
{
19-
private function checkNotExpired(Key $key)
19+
private function checkNotExpired(Key $key): void
2020
{
2121
if ($key->isExpired()) {
2222
try {

Store/FlockStore.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,39 @@ public function __construct(string $lockPath = null)
5050
$this->lockPath = $lockPath;
5151
}
5252

53+
/**
54+
* @return void
55+
*/
5356
public function save(Key $key)
5457
{
5558
$this->lock($key, false, false);
5659
}
5760

61+
/**
62+
* @return void
63+
*/
5864
public function saveRead(Key $key)
5965
{
6066
$this->lock($key, true, false);
6167
}
6268

69+
/**
70+
* @return void
71+
*/
6372
public function waitAndSave(Key $key)
6473
{
6574
$this->lock($key, false, true);
6675
}
6776

77+
/**
78+
* @return void
79+
*/
6880
public function waitAndSaveRead(Key $key)
6981
{
7082
$this->lock($key, true, true);
7183
}
7284

73-
private function lock(Key $key, bool $read, bool $blocking)
85+
private function lock(Key $key, bool $read, bool $blocking): void
7486
{
7587
$handle = null;
7688
// The lock is maybe already acquired.
@@ -120,11 +132,17 @@ private function lock(Key $key, bool $read, bool $blocking)
120132
$key->markUnserializable();
121133
}
122134

135+
/**
136+
* @return void
137+
*/
123138
public function putOffExpiration(Key $key, float $ttl)
124139
{
125140
// do nothing, the flock locks forever.
126141
}
127142

143+
/**
144+
* @return void
145+
*/
128146
public function delete(Key $key)
129147
{
130148
// The lock is maybe not acquired.

Store/InMemoryStore.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class InMemoryStore implements SharedLockStoreInterface
2626
private array $locks = [];
2727
private array $readLocks = [];
2828

29+
/**
30+
* @return void
31+
*/
2932
public function save(Key $key)
3033
{
3134
$hashKey = (string) $key;
@@ -54,6 +57,9 @@ public function save(Key $key)
5457
$this->locks[$hashKey] = $token;
5558
}
5659

60+
/**
61+
* @return void
62+
*/
5763
public function saveRead(Key $key)
5864
{
5965
$hashKey = (string) $key;
@@ -78,11 +84,17 @@ public function saveRead(Key $key)
7884
$this->readLocks[$hashKey][$token] = true;
7985
}
8086

87+
/**
88+
* @return void
89+
*/
8190
public function putOffExpiration(Key $key, float $ttl)
8291
{
8392
// do nothing, memory locks forever.
8493
}
8594

95+
/**
96+
* @return void
97+
*/
8698
public function delete(Key $key)
8799
{
88100
$hashKey = (string) $key;

Store/MemcachedStore.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public function __construct(\Memcached $memcached, int $initialTtl = 300)
5555
$this->initialTtl = $initialTtl;
5656
}
5757

58+
/**
59+
* @return void
60+
*/
5861
public function save(Key $key)
5962
{
6063
$token = $this->getUniqueToken($key);
@@ -67,6 +70,9 @@ public function save(Key $key)
6770
$this->checkNotExpired($key);
6871
}
6972

73+
/**
74+
* @return void
75+
*/
7076
public function putOffExpiration(Key $key, float $ttl)
7177
{
7278
if ($ttl < 1) {
@@ -103,6 +109,9 @@ public function putOffExpiration(Key $key, float $ttl)
103109
$this->checkNotExpired($key);
104110
}
105111

112+
/**
113+
* @return void
114+
*/
106115
public function delete(Key $key)
107116
{
108117
$token = $this->getUniqueToken($key);

Store/MongoDbStore.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ private function skimUri(string $uri): string
190190
* @throws UnsupportedException if options are not supported by the selected server
191191
* @throws MongoInvalidArgumentException for parameter/option parsing errors
192192
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
193+
*
194+
* @return void
193195
*/
194196
public function createTtlIndex(int $expireAfterSeconds = 0)
195197
{
@@ -205,6 +207,8 @@ public function createTtlIndex(int $expireAfterSeconds = 0)
205207

206208
/**
207209
* @throws LockExpiredException when save is called on an expired lock
210+
*
211+
* @return void
208212
*/
209213
public function save(Key $key)
210214
{
@@ -229,6 +233,8 @@ public function save(Key $key)
229233
/**
230234
* @throws LockStorageException
231235
* @throws LockExpiredException
236+
*
237+
* @return void
232238
*/
233239
public function putOffExpiration(Key $key, float $ttl)
234240
{
@@ -246,6 +252,9 @@ public function putOffExpiration(Key $key, float $ttl)
246252
$this->checkNotExpired($key);
247253
}
248254

255+
/**
256+
* @return void
257+
*/
249258
public function delete(Key $key)
250259
{
251260
$this->getCollection()->deleteOne([ // filter
@@ -272,7 +281,7 @@ public function exists(Key $key): bool
272281
*
273282
* @param float $ttl Expiry in seconds from now
274283
*/
275-
private function upsert(Key $key, float $ttl)
284+
private function upsert(Key $key, float $ttl): void
276285
{
277286
$now = microtime(true);
278287
$token = $this->getUniqueToken($key);

Store/PdoStore.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ public function __construct(#[\SensitiveParameter] \PDO|string $connOrDsn, #[\Se
8383
$this->connectionOptions = $options['db_connection_options'] ?? $this->connectionOptions;
8484
}
8585

86+
/**
87+
* @return void
88+
*/
8689
public function save(Key $key)
8790
{
8891
$key->reduceLifetime($this->initialTtl);
@@ -112,6 +115,9 @@ public function save(Key $key)
112115
$this->checkNotExpired($key);
113116
}
114117

118+
/**
119+
* @return void
120+
*/
115121
public function putOffExpiration(Key $key, float $ttl)
116122
{
117123
if ($ttl < 1) {
@@ -137,6 +143,9 @@ public function putOffExpiration(Key $key, float $ttl)
137143
$this->checkNotExpired($key);
138144
}
139145

146+
/**
147+
* @return void
148+
*/
140149
public function delete(Key $key)
141150
{
142151
$sql = "DELETE FROM $this->table WHERE $this->idCol = :id AND $this->tokenCol = :token";

0 commit comments

Comments
 (0)