Skip to content

Commit fc41668

Browse files
Add return types - batch 1/n
1 parent 130d707 commit fc41668

15 files changed

+21
-21
lines changed

LockInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface LockInterface
3131
* @throws LockConflictedException If the lock is acquired by someone else in blocking mode
3232
* @throws LockAcquiringException If the lock can not be acquired
3333
*/
34-
public function acquire(bool $blocking = false);
34+
public function acquire(bool $blocking = false): bool;
3535

3636
/**
3737
* Increase the duration of an acquired lock.
@@ -48,7 +48,7 @@ public function refresh(float $ttl = null);
4848
*
4949
* @return bool
5050
*/
51-
public function isAcquired();
51+
public function isAcquired(): bool;
5252

5353
/**
5454
* Release the lock.
@@ -60,12 +60,12 @@ public function release();
6060
/**
6161
* @return bool
6262
*/
63-
public function isExpired();
63+
public function isExpired(): bool;
6464

6565
/**
6666
* Returns the remaining lifetime.
6767
*
6868
* @return float|null Remaining lifetime in seconds. Null when the lock won't expire.
6969
*/
70-
public function getRemainingLifetime();
70+
public function getRemainingLifetime(): ?float;
7171
}

PersistingStoreInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function delete(Key $key);
4040
*
4141
* @return bool
4242
*/
43-
public function exists(Key $key);
43+
public function exists(Key $key): bool;
4444

4545
/**
4646
* Extends the TTL of a resource.

SharedLockInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ interface SharedLockInterface extends LockInterface
3030
* @throws LockConflictedException If the lock is acquired by someone else in blocking mode
3131
* @throws LockAcquiringException If the lock can not be acquired
3232
*/
33-
public function acquireRead(bool $blocking = false);
33+
public function acquireRead(bool $blocking = false): bool;
3434
}

Store/CombinedStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public function delete(Key $key)
192192
/**
193193
* {@inheritdoc}
194194
*/
195-
public function exists(Key $key)
195+
public function exists(Key $key): bool
196196
{
197197
$successCount = 0;
198198
$failureCount = 0;

Store/FlockStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function delete(Key $key)
161161
/**
162162
* {@inheritdoc}
163163
*/
164-
public function exists(Key $key)
164+
public function exists(Key $key): bool
165165
{
166166
return $key->hasState(__CLASS__);
167167
}

Store/InMemoryStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function delete(Key $key)
9494
}
9595
}
9696

97-
public function exists(Key $key)
97+
public function exists(Key $key): bool
9898
{
9999
$hashKey = (string) $key;
100100
$token = $this->getUniqueToken($key);

Store/MemcachedStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function delete(Key $key)
134134
/**
135135
* {@inheritdoc}
136136
*/
137-
public function exists(Key $key)
137+
public function exists(Key $key): bool
138138
{
139139
return $this->memcached->get((string) $key) === $this->getUniqueToken($key);
140140
}

Store/PdoStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function delete(Key $key)
200200
/**
201201
* {@inheritdoc}
202202
*/
203-
public function exists(Key $key)
203+
public function exists(Key $key): bool
204204
{
205205
$sql = "SELECT 1 FROM $this->table WHERE $this->idCol = :id AND $this->tokenCol = :token AND $this->expirationCol > {$this->getCurrentTimestampStatement()}";
206206
$stmt = $this->getConnection()->prepare($sql);

Store/PostgreSqlStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function delete(Key $key)
148148
$store->delete($key);
149149
}
150150

151-
public function exists(Key $key)
151+
public function exists(Key $key): bool
152152
{
153153
$sql = "SELECT count(*) FROM pg_locks WHERE locktype='advisory' AND objid=:key AND pid=pg_backend_pid()";
154154
$stmt = $this->getConnection()->prepare($sql);

Store/RedisStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public function delete(Key $key)
218218
/**
219219
* {@inheritdoc}
220220
*/
221-
public function exists(Key $key)
221+
public function exists(Key $key): bool
222222
{
223223
$script = '
224224
local key = KEYS[1]

Store/SemaphoreStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function putOffExpiration(Key $key, float $ttl)
107107
/**
108108
* {@inheritdoc}
109109
*/
110-
public function exists(Key $key)
110+
public function exists(Key $key): bool
111111
{
112112
return $key->hasState(__CLASS__);
113113
}

Store/StoreFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class StoreFactory
2828
/**
2929
* @return PersistingStoreInterface
3030
*/
31-
public static function createStore(object|string $connection)
31+
public static function createStore(object|string $connection): PersistingStoreInterface
3232
{
3333
switch (true) {
3434
case $connection instanceof \Redis:

Strategy/ConsensusStrategy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ class ConsensusStrategy implements StrategyInterface
2121
/**
2222
* {@inheritdoc}
2323
*/
24-
public function isMet(int $numberOfSuccess, int $numberOfItems)
24+
public function isMet(int $numberOfSuccess, int $numberOfItems): bool
2525
{
2626
return $numberOfSuccess > ($numberOfItems / 2);
2727
}
2828

2929
/**
3030
* {@inheritdoc}
3131
*/
32-
public function canBeMet(int $numberOfFailure, int $numberOfItems)
32+
public function canBeMet(int $numberOfFailure, int $numberOfItems): bool
3333
{
3434
return $numberOfFailure < ($numberOfItems / 2);
3535
}

Strategy/StrategyInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface StrategyInterface
2323
*
2424
* @return bool
2525
*/
26-
public function isMet(int $numberOfSuccess, int $numberOfItems);
26+
public function isMet(int $numberOfSuccess, int $numberOfItems): bool;
2727

2828
/**
2929
* Returns whether or not the quorum *could* be met.
@@ -33,5 +33,5 @@ public function isMet(int $numberOfSuccess, int $numberOfItems);
3333
*
3434
* @return bool
3535
*/
36-
public function canBeMet(int $numberOfFailure, int $numberOfItems);
36+
public function canBeMet(int $numberOfFailure, int $numberOfItems): bool;
3737
}

Strategy/UnanimousStrategy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ class UnanimousStrategy implements StrategyInterface
2121
/**
2222
* {@inheritdoc}
2323
*/
24-
public function isMet(int $numberOfSuccess, int $numberOfItems)
24+
public function isMet(int $numberOfSuccess, int $numberOfItems): bool
2525
{
2626
return $numberOfSuccess === $numberOfItems;
2727
}
2828

2929
/**
3030
* {@inheritdoc}
3131
*/
32-
public function canBeMet(int $numberOfFailure, int $numberOfItems)
32+
public function canBeMet(int $numberOfFailure, int $numberOfItems): bool
3333
{
3434
return 0 === $numberOfFailure;
3535
}

0 commit comments

Comments
 (0)