From 8d5d8a75bff56f77f672158f4bbd3b642c3b6b9f Mon Sep 17 00:00:00 2001 From: Amrouche Hamza Date: Wed, 7 Aug 2019 07:37:35 +0200 Subject: [PATCH] [Lock] add type-hint whenever possible --- src/Symfony/Component/Lock/Lock.php | 2 +- src/Symfony/Component/Lock/PersistingStoreInterface.php | 2 +- src/Symfony/Component/Lock/Store/CombinedStore.php | 2 +- src/Symfony/Component/Lock/Store/FlockStore.php | 2 +- src/Symfony/Component/Lock/Store/MemcachedStore.php | 2 +- src/Symfony/Component/Lock/Store/PdoStore.php | 2 +- src/Symfony/Component/Lock/Store/RedisStore.php | 2 +- src/Symfony/Component/Lock/Store/RetryTillSaveStore.php | 2 +- src/Symfony/Component/Lock/Store/SemaphoreStore.php | 2 +- src/Symfony/Component/Lock/Store/ZookeeperStore.php | 2 +- src/Symfony/Component/Lock/Strategy/ConsensusStrategy.php | 4 ++-- src/Symfony/Component/Lock/Strategy/StrategyInterface.php | 4 ++-- src/Symfony/Component/Lock/Strategy/UnanimousStrategy.php | 4 ++-- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Component/Lock/Lock.php b/src/Symfony/Component/Lock/Lock.php index f7da528d1c77..e9eee18e3797 100644 --- a/src/Symfony/Component/Lock/Lock.php +++ b/src/Symfony/Component/Lock/Lock.php @@ -114,7 +114,7 @@ public function acquire($blocking = false): ?bool /** * {@inheritdoc} */ - public function refresh($ttl = null) + public function refresh(float $ttl = null) { if (null === $ttl) { $ttl = $this->ttl; diff --git a/src/Symfony/Component/Lock/PersistingStoreInterface.php b/src/Symfony/Component/Lock/PersistingStoreInterface.php index f3095db0c006..03309a90b566 100644 --- a/src/Symfony/Component/Lock/PersistingStoreInterface.php +++ b/src/Symfony/Component/Lock/PersistingStoreInterface.php @@ -49,5 +49,5 @@ public function exists(Key $key); * * @throws LockConflictedException */ - public function putOffExpiration(Key $key, $ttl); + public function putOffExpiration(Key $key, float $ttl); } diff --git a/src/Symfony/Component/Lock/Store/CombinedStore.php b/src/Symfony/Component/Lock/Store/CombinedStore.php index 49d40566a485..4dee0fa26911 100644 --- a/src/Symfony/Component/Lock/Store/CombinedStore.php +++ b/src/Symfony/Component/Lock/Store/CombinedStore.php @@ -106,7 +106,7 @@ public function waitAndSave(Key $key) /** * {@inheritdoc} */ - public function putOffExpiration(Key $key, $ttl) + public function putOffExpiration(Key $key, float $ttl) { $successCount = 0; $failureCount = 0; diff --git a/src/Symfony/Component/Lock/Store/FlockStore.php b/src/Symfony/Component/Lock/Store/FlockStore.php index d1c303c534e8..b2a8bc20d502 100644 --- a/src/Symfony/Component/Lock/Store/FlockStore.php +++ b/src/Symfony/Component/Lock/Store/FlockStore.php @@ -106,7 +106,7 @@ private function lock(Key $key, bool $blocking) /** * {@inheritdoc} */ - public function putOffExpiration(Key $key, $ttl) + public function putOffExpiration(Key $key, float $ttl) { // do nothing, the flock locks forever. } diff --git a/src/Symfony/Component/Lock/Store/MemcachedStore.php b/src/Symfony/Component/Lock/Store/MemcachedStore.php index d16ca154509e..505e6fa5ea5c 100644 --- a/src/Symfony/Component/Lock/Store/MemcachedStore.php +++ b/src/Symfony/Component/Lock/Store/MemcachedStore.php @@ -83,7 +83,7 @@ public function waitAndSave(Key $key) /** * {@inheritdoc} */ - public function putOffExpiration(Key $key, $ttl) + public function putOffExpiration(Key $key, float $ttl) { if ($ttl < 1) { throw new InvalidTtlException(sprintf('%s() expects a TTL greater or equals to 1 second. Got %s.', __METHOD__, $ttl)); diff --git a/src/Symfony/Component/Lock/Store/PdoStore.php b/src/Symfony/Component/Lock/Store/PdoStore.php index a35e142061c3..bf2d6bc6ff48 100644 --- a/src/Symfony/Component/Lock/Store/PdoStore.php +++ b/src/Symfony/Component/Lock/Store/PdoStore.php @@ -152,7 +152,7 @@ public function waitAndSave(Key $key) /** * {@inheritdoc} */ - public function putOffExpiration(Key $key, $ttl) + public function putOffExpiration(Key $key, float $ttl) { if ($ttl < 1) { throw new InvalidTtlException(sprintf('%s() expects a TTL greater or equals to 1 second. Got %s.', __METHOD__, $ttl)); diff --git a/src/Symfony/Component/Lock/Store/RedisStore.php b/src/Symfony/Component/Lock/Store/RedisStore.php index c1aecbfcd2dc..79403a138b38 100644 --- a/src/Symfony/Component/Lock/Store/RedisStore.php +++ b/src/Symfony/Component/Lock/Store/RedisStore.php @@ -86,7 +86,7 @@ public function waitAndSave(Key $key) /** * {@inheritdoc} */ - public function putOffExpiration(Key $key, $ttl) + public function putOffExpiration(Key $key, float $ttl) { $script = ' if redis.call("GET", KEYS[1]) == ARGV[1] then diff --git a/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php b/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php index 18890536f057..79e28ce74538 100644 --- a/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php +++ b/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php @@ -80,7 +80,7 @@ public function waitAndSave(Key $key) /** * {@inheritdoc} */ - public function putOffExpiration(Key $key, $ttl) + public function putOffExpiration(Key $key, float $ttl) { $this->decorated->putOffExpiration($key, $ttl); } diff --git a/src/Symfony/Component/Lock/Store/SemaphoreStore.php b/src/Symfony/Component/Lock/Store/SemaphoreStore.php index 829da3bfc661..328380280b3b 100644 --- a/src/Symfony/Component/Lock/Store/SemaphoreStore.php +++ b/src/Symfony/Component/Lock/Store/SemaphoreStore.php @@ -100,7 +100,7 @@ public function delete(Key $key) /** * {@inheritdoc} */ - public function putOffExpiration(Key $key, $ttl) + public function putOffExpiration(Key $key, float $ttl) { // do nothing, the semaphore locks forever. } diff --git a/src/Symfony/Component/Lock/Store/ZookeeperStore.php b/src/Symfony/Component/Lock/Store/ZookeeperStore.php index 681416c905af..0db550c46976 100644 --- a/src/Symfony/Component/Lock/Store/ZookeeperStore.php +++ b/src/Symfony/Component/Lock/Store/ZookeeperStore.php @@ -96,7 +96,7 @@ public function waitAndSave(Key $key) /** * {@inheritdoc} */ - public function putOffExpiration(Key $key, $ttl) + public function putOffExpiration(Key $key, float $ttl) { // do nothing, zookeeper locks forever. } diff --git a/src/Symfony/Component/Lock/Strategy/ConsensusStrategy.php b/src/Symfony/Component/Lock/Strategy/ConsensusStrategy.php index 047820a409f1..1338b10dd63f 100644 --- a/src/Symfony/Component/Lock/Strategy/ConsensusStrategy.php +++ b/src/Symfony/Component/Lock/Strategy/ConsensusStrategy.php @@ -21,7 +21,7 @@ class ConsensusStrategy implements StrategyInterface /** * {@inheritdoc} */ - public function isMet($numberOfSuccess, $numberOfItems) + public function isMet(int $numberOfSuccess, int $numberOfItems) { return $numberOfSuccess > ($numberOfItems / 2); } @@ -29,7 +29,7 @@ public function isMet($numberOfSuccess, $numberOfItems) /** * {@inheritdoc} */ - public function canBeMet($numberOfFailure, $numberOfItems) + public function canBeMet(int $numberOfFailure, int $numberOfItems) { return $numberOfFailure < ($numberOfItems / 2); } diff --git a/src/Symfony/Component/Lock/Strategy/StrategyInterface.php b/src/Symfony/Component/Lock/Strategy/StrategyInterface.php index beaa7280a2d4..0b8aa3b30f00 100644 --- a/src/Symfony/Component/Lock/Strategy/StrategyInterface.php +++ b/src/Symfony/Component/Lock/Strategy/StrategyInterface.php @@ -26,7 +26,7 @@ interface StrategyInterface * * @return bool */ - public function isMet($numberOfSuccess, $numberOfItems); + public function isMet(int $numberOfSuccess, int $numberOfItems); /** * Returns whether or not the quorum *could* be met. @@ -39,5 +39,5 @@ public function isMet($numberOfSuccess, $numberOfItems); * * @return bool */ - public function canBeMet($numberOfFailure, $numberOfItems); + public function canBeMet(int $numberOfFailure, int $numberOfItems); } diff --git a/src/Symfony/Component/Lock/Strategy/UnanimousStrategy.php b/src/Symfony/Component/Lock/Strategy/UnanimousStrategy.php index 27404f3e9f05..63f9d1b4a1b2 100644 --- a/src/Symfony/Component/Lock/Strategy/UnanimousStrategy.php +++ b/src/Symfony/Component/Lock/Strategy/UnanimousStrategy.php @@ -21,7 +21,7 @@ class UnanimousStrategy implements StrategyInterface /** * {@inheritdoc} */ - public function isMet($numberOfSuccess, $numberOfItems) + public function isMet(int $numberOfSuccess, int $numberOfItems) { return $numberOfSuccess === $numberOfItems; } @@ -29,7 +29,7 @@ public function isMet($numberOfSuccess, $numberOfItems) /** * {@inheritdoc} */ - public function canBeMet($numberOfFailure, $numberOfItems) + public function canBeMet(int $numberOfFailure, int $numberOfItems) { return 0 === $numberOfFailure; }