Skip to content

Commit 689635e

Browse files
Replace more docblocks by type-hints
1 parent 468ee8e commit 689635e

File tree

6 files changed

+9
-24
lines changed

6 files changed

+9
-24
lines changed

Key.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ final class Key
2222
private $expiringTime;
2323
private $state = array();
2424

25-
/**
26-
* @param string $resource
27-
*/
2825
public function __construct(string $resource)
2926
{
3027
$this->resource = $resource;

Lock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ final class Lock implements LockInterface, LoggerAwareInterface
4141
* @param float|null $ttl Maximum expected lock duration in seconds
4242
* @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed
4343
*/
44-
public function __construct(Key $key, StoreInterface $store, $ttl = null, $autoRelease = true)
44+
public function __construct(Key $key, StoreInterface $store, float $ttl = null, bool $autoRelease = true)
4545
{
4646
$this->store = $store;
4747
$this->key = $key;
4848
$this->ttl = $ttl;
49-
$this->autoRelease = (bool) $autoRelease;
49+
$this->autoRelease = $autoRelease;
5050

5151
$this->logger = new NullLogger();
5252
}

Store/FlockStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class FlockStore implements StoreInterface
3636
*
3737
* @throws LockStorageException If the lock directory could not be created or is not writable
3838
*/
39-
public function __construct($lockPath = null)
39+
public function __construct(string $lockPath = null)
4040
{
4141
if (null === $lockPath) {
4242
$lockPath = sys_get_temp_dir();

Store/MemcachedStore.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function isSupported()
4444
* @param \Memcached $memcached
4545
* @param int $initialTtl the expiration delay of locks in seconds
4646
*/
47-
public function __construct(\Memcached $memcached, $initialTtl = 300)
47+
public function __construct(\Memcached $memcached, int $initialTtl = 300)
4848
{
4949
if (!static::isSupported()) {
5050
throw new InvalidArgumentException('Memcached extension is required');
@@ -155,12 +155,8 @@ public function exists(Key $key)
155155

156156
/**
157157
* Retrieve an unique token for the given key.
158-
*
159-
* @param Key $key
160-
*
161-
* @return string
162158
*/
163-
private function getToken(Key $key)
159+
private function getToken(Key $key): string
164160
{
165161
if (!$key->hasState(__CLASS__)) {
166162
$token = base64_encode(random_bytes(32));

Store/RedisStore.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class RedisStore implements StoreInterface
3939
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient
4040
* @param float $initialTtl the expiration delay of locks in seconds
4141
*/
42-
public function __construct($redisClient, $initialTtl = 300.0)
42+
public function __construct($redisClient, float $initialTtl = 300.0)
4343
{
4444
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\Client) {
4545
throw new InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, is_object($redisClient) ? get_class($redisClient) : gettype($redisClient)));
@@ -131,13 +131,9 @@ public function exists(Key $key)
131131
/**
132132
* Evaluates a script in the corresponding redis client.
133133
*
134-
* @param string $script
135-
* @param string $resource
136-
* @param array $args
137-
*
138134
* @return mixed
139135
*/
140-
private function evaluate($script, $resource, array $args)
136+
private function evaluate(string $script, string $resource, array $args)
141137
{
142138
if ($this->redis instanceof \Redis || $this->redis instanceof \RedisCluster) {
143139
return $this->redis->eval($script, array_merge(array($resource), $args), 1);
@@ -156,12 +152,8 @@ private function evaluate($script, $resource, array $args)
156152

157153
/**
158154
* Retrieves an unique token for the given key.
159-
*
160-
* @param Key $key
161-
*
162-
* @return string
163155
*/
164-
private function getToken(Key $key)
156+
private function getToken(Key $key): string
165157
{
166158
if (!$key->hasState(__CLASS__)) {
167159
$token = base64_encode(random_bytes(32));

Store/RetryTillSaveStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class RetryTillSaveStore implements StoreInterface, LoggerAwareInterface
3737
* @param int $retrySleep Duration in ms between 2 retry
3838
* @param int $retryCount Maximum amount of retry
3939
*/
40-
public function __construct(StoreInterface $decorated, $retrySleep = 100, $retryCount = PHP_INT_MAX)
40+
public function __construct(StoreInterface $decorated, int $retrySleep = 100, int $retryCount = PHP_INT_MAX)
4141
{
4242
$this->decorated = $decorated;
4343
$this->retrySleep = $retrySleep;

0 commit comments

Comments
 (0)