8000 [Lock] add type-hint whenever possible by Simperfit · Pull Request #33004 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Lock] add type-hint whenever possible #33004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files. 8000
Loading
Diff view
Diff view
[Lock] add type-hint whenever possible
  • Loading branch information
Simperfit committed Aug 7, 2019
commit 8d5d8a75bff56f77f672158f4bbd3b642c3b6b9f
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Lock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/PersistingStoreInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ public function exists(Key $key);
*
* @throws LockConflictedException
*/
public function putOffExpiration(Key $key, $ttl);
public function putOffExpiration(Key $key, float $ttl);
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Store/CombinedStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Store/FlockStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Store/MemcachedStore.php
8000
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Store/PdoStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Store/RedisStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Store/RetryTillSaveStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Store/SemaphoreStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Store/ZookeeperStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Lock/Strategy/ConsensusStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class ConsensusStrategy implements StrategyInterface
/**
* {@inheritdoc}
*/
public function isMet($numberOfSuccess, $numberOfItems)
public function isMet(int $numberOfSuccess, int $numberOfItems)
{
return $numberOfSuccess > ($numberOfItems / 2);
}

/**
* {@inheritdoc}
*/
public function canBeMet($numberOfFailure, $numberOfItems)
public function canBeMet(int $numberOfFailure, int $numberOfItems)
{
return $numberOfFailure < ($numberOfItems / 2);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Lock/Strategy/StrategyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -39,5 +39,5 @@ public function isMet($numberOfSuccess, $numberOfItems);
*
* @return bool
*/
public function canBeMet($numberOfFailure, $numberOfItems);
public function canBeMet(int $numberOfFailure, int $numberOfItems);
}
4 changes: 2 additions & 2 deletions src/Symfony/Component/Lock/Strategy/UnanimousStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class UnanimousStrategy implements StrategyInterface
/**
* {@inheritdoc}
*/
public function isMet($numberOfSuccess, $numberOfItems)
public function isMet(int $numberOfSuccess, int $numberOfItems)
{
return $numberOfSuccess === $numberOfItems;
}

/**
* {@inheritdoc}
*/
public function canBeMet($numberOfFailure, $numberOfItems)
public function canBeMet(int $numberOfFailure, int $numberOfItems)
{
return 0 === $numberOfFailure;
}
Expand Down
0