8000 [Lock] Add the void return type in Lock interfaces by stof · Pull Request #50090 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Lock] Add the void return type in Lock interfaces #50090

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

Merged
merged 1 commit into from
Apr 21, 2023
Merged
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.
Loading
Diff view
Diff view
100 changes: 86 additions & 14 deletions .github/expected-missing-return-types.diff
10000
Original file line number Diff line number Diff line change
Expand Up @@ -7102,94 +7102,94 @@ index 9d7012de35..545339d4ef 100644
{
unset($this->parameters[$key]);
diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php
index a6650c49a3..2d5eb50ab4 100644
index cf7e56f13e..e07d5fab79 100644
--- a/src/Symfony/Component/HttpFoundation/Request.php
+++ b/src/Symfony/Component/HttpFoundation/Request.php
@@ -267,5 +267,5 @@ class Request
@@ -269,5 +269,5 @@ class Request
* @return void
*/
- public function initialize(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
+ public function initialize(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null): void
{
$this->request = new InputBag($request);
@@ -427,5 +427,5 @@ class Request
@@ -429,5 +429,5 @@ class Request
* @return void
*/
- public static function setFactory(?callable $callable)
+ public static function setFactory(?callable $callable): void
{
self::$requestFactory = $callable;
@@ -533,5 +533,5 @@ class Request
@@ -535,5 +535,5 @@ class Request
* @return void
*/
- public function overrideGlobals()
+ public function overrideGlobals(): void
{
$this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), '', '&')));
@@ -575,5 +575,5 @@ class Request
@@ -577,5 +577,5 @@ class Request
* @return void
*/
- public static function setTrustedProxies(array $proxies, int $trustedHeaderSet)
+ public static function setTrustedProxies(array $proxies, int $trustedHeaderSet): void
{
self::$trustedProxies = array_reduce($proxies, function ($proxies, $proxy) {
@@ -618,5 +618,5 @@ class Request
@@ -620,5 +620,5 @@ class Request
* @return void
*/
- public static function setTrustedHosts(array $hostPatterns)
+ public static function setTrustedHosts(array $hostPatterns): void
{
self::$trustedHostPatterns = array_map(fn ($hostPattern) => sprintf('{%s}i', $hostPattern), $hostPatterns);
@@ -666,5 +666,5 @@ class Request
@@ -668,5 +668,5 @@ class Request
* @return void
*/
- public static function enableHttpMethodParameterOverride()
+ public static function enableHttpMethodParameterOverride(): void
{
self::$httpMethodParameterOverride = true;
@@ -753,5 +753,5 @@ class Request
@@ -755,5 +755,5 @@ class Request
* @return void
*/
- public function setSession(SessionInterface $session)
+ public function setSession(SessionInterface $session): void
{
$this->session = $session;
@@ -1176,5 +1176,5 @@ class Request
@@ -1178,5 +1178,5 @@ class Request
* @return void
*/
- public function setMethod(string $method)
+ public function setMethod(string $method): void
{
$this->method = null;
@@ -1299,5 +1299,5 @@ class Request
@@ -1301,5 +1301,5 @@ class Request
* @return void
*/
- public function setFormat(?string $format, string|array $mimeTypes)
+ public function setFormat(?string $format, string|array $mimeTypes): void
{
if (null === static::$formats) {
@@ -1331,5 +1331,5 @@ class Request
@@ -1333,5 +1333,5 @@ class Request
* @return void
*/
- public function setRequestFormat(?string $format)
+ public function setRequestFormat(?string $format): void
{
$this->format = $format;
@@ -1363,5 +1363,5 @@ class Request
@@ -1365,5 +1365,5 @@ class Request
* @return void
*/
- public function setDefaultLocale(string $locale)
+ public function setDefaultLocale(string $locale): void
{
$this->defaultLocale = $locale;
@@ -1385,5 +1385,5 @@ class Request
@@ -1387,5 +1387,5 @@ class Request
* @return void
*/
- public function setLocale(string $locale)
+ public function setLocale(string $locale): void
{
$this->setPhpDefaultLocale($this->locale = $locale);
@@ -1900,5 +1900,5 @@ class Request
@@ -1904,5 +1904,5 @@ class Request
* @return void
*/
- protected static function initializeFormats()
Expand Down Expand Up @@ -9050,6 +9050,26 @@ index 7e535ebde1..ebb3df9b2b 100644
+ public function onCheckPassport(CheckPassportEvent $event): void
{
$passport = $event->getPassport();
diff --git a/src/Symfony/Component/Lock/BlockingSharedLockStoreInterface.php b/src/Symfony/Component/Lock/BlockingSharedLockStoreInterface.php
index 6929206c42..f2494e1061 100644
--- a/src/Symfony/Component/Lock/BlockingSharedLockStoreInterface.php
+++ b/src/Symfony/Component/Lock/BlockingSharedLockStoreInterface.php
@@ -26,4 +26,4 @@ interface BlockingSharedLockStoreInterface extends SharedLockStoreInterface
* @throws LockConflictedException
*/
- public function waitAndSaveRead(Key $key);
+ public function waitAndSaveRead(Key $key): void;
}
diff --git a/src/Symfony/Component/Lock/BlockingStoreInterface.php b/src/Symfony/Component/Lock/BlockingStoreInterface.php
index 8a84272a8b..e22fac0538 100644
--- a/src/Symfony/Component/Lock/BlockingStoreInterface.php
+++ b/src/Symfony/Component/Lock/BlockingStoreInterface.php
@@ -26,4 +26,4 @@ interface BlockingStoreInterface extends PersistingStoreInterface
* @throws LockConflictedException
*/
- public function waitAndSave(Key $key);
+ public function waitAndSave(Key $key): void;
}
diff --git a/src/Symfony/Component/Lock/LockFactory.php b/src/Symfony/Component/Lock/LockFactory.php
index 125b6eae50..ac327e8981 100644
--- a/src/Symfony/Component/Lock/LockFactory.php
Expand All @@ -9068,6 +9088,58 @@ index 125b6eae50..ac327e8981 100644
+ public function createLockFromKey(Key $key, ?float $ttl = 300.0, bool $autoRelease = true): SharedLockInterface
{
$lock = new Lock($key, $this->store, $ttl, $autoRelease);
diff --git a/src/Symfony/Component/Lock/LockInterface.php b/src/Symfony/Component/Lock/LockInterface.php
index 8ff806497c..991252e453 100644
--- a/src/Symfony/Component/Lock/LockInterface.php
+++ b/src/Symfony/Component/Lock/LockInterface.php
@@ -42,5 +42,5 @@ interface LockInterface
* @throws LockAcquiringException If the lock cannot be refreshed
*/
- public function refresh(float $ttl = null);
+ public function refresh(float $ttl = null): void;

/**
@@ -56,5 +56,5 @@ interface LockInterface
* @throws LockReleasingException If the lock cannot be released
*/
- public function release();
+ public function release(): void;

public function isExpired(): bool;
diff --git a/src/Symfony/Component/Lock/PersistingStoreInterface.php b/src/Symfony/Component/Lock/PersistingStoreInterface.php
index 10af48c5e6..392446a56a 100644
--- a/src/Symfony/Component/Lock/PersistingStoreInterface.php
+++ b/src/Symfony/Component/Lock/PersistingStoreInterface.php
@@ -29,5 +29,5 @@ interface PersistingStoreInterface
* @throws LockConflictedException
*/
- public function save(Key $key);
+ public function save(Key $key): void;

/**
@@ -38,5 +38,5 @@ interface PersistingStoreInterface
* @throws LockReleasingException
*/
- public function delete(Key $key);
+ public function delete(Key $key): void;

/**
@@ -54,4 +54,4 @@ interface PersistingStoreInterface
* @throws LockConflictedException
*/
- public function putOffExpiration(Key $key, float $ttl);
+ public function putOffExpiration(Key $key, float $ttl): void;
}
diff --git a/src/Symfony/Component/Lock/SharedLockStoreInterface.php b/src/Symfony/Component/Lock/SharedLockStoreInterface.php
index 8246152493..1814a18bca 100644
--- a/src/Symfony/Component/Lock/SharedLockStoreInterface.php
+++ b/src/Symfony/Component/Lock/SharedLockStoreInterface.php
@@ -26,4 +26,4 @@ interface SharedLockStoreInterface extends PersistingStoreInterface
* @throws LockConflictedException
*/
- public function saveRead(Key $key);
+ public function saveRead(Key $key): void;
}
diff --git a/src/Symfony/Component/Lock/Store/CombinedStore.php b/src/Symfony/Component/Lock/Store/CombinedStore.php
index 9087874c29..5cfd87c4ad 100644
--- a/src/Symfony/Component/Lock/Store/CombinedStore.php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ interface BlockingSharedLockStoreInterface extends SharedLockStoreInterface
/**
* Waits until a key becomes free for reading, then stores the resource.
*
* @return void
*
* @throws LockConflictedException
*/
public function waitAndSaveRead(Key $key);
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Lock/BlockingStoreInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ interface BlockingStoreInterface extends PersistingStoreInterface
/**
* Waits until a key becomes free, then stores the resource.
*
* @return void
*
* @throws LockConflictedException
*/
public function waitAndSave(Key $key);
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Lock/LockInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function acquire(bool $blocking = false): bool;
*
* @param float|null $ttl Maximum expected lock duration in seconds
*
* @return void
*
* @throws LockConflictedException If the lock is acquired by someone else
* @throws LockAcquiringException If the lock cannot be refreshed
*/
Expand All @@ -49,6 +51,8 @@ public function isAcquired(): bool;
/**
* Release the lock.
*
* @return void
*
* @throws LockReleasingException If the lock cannot be released
*/
public function release();
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/Lock/PersistingStoreInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ interface PersistingStoreInterface
/**
* Stores the resource if it's not locked by someone else.
*
* @return void
*
* @throws LockAcquiringException
* @throws LockConflictedException
*/
Expand All @@ -31,6 +33,8 @@ public function save(Key $key);
/**
* Removes a resource from the storage.
*
* @return void
*
* @throws LockReleasingException
*/
public function delete(Key $key);
Expand All @@ -45,6 +49,8 @@ public function exists(Key $key): bool;
*
* @param float $ttl amount of seconds to keep the lock in the store
*
* @return void
*
* @throws LockConflictedException
*/
public function putOffExpiration(Key $key, float $ttl);
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Lock/SharedLockStoreInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ interface SharedLockStoreInterface extends PersistingStoreInterface
/**
* Stores the resource if it's not locked for reading by someone else.
*
* @return void
*
* @throws LockConflictedException
*/
public function saveRead(Key $key);
Expand Down
8 changes: 3 additions & 5 deletions src/Symfony/Component/Lock/Tests/LockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,16 +472,14 @@ public function testAcquireReadTwiceWithExpiration()
private $keys = [];
private $initialTtl = 30;

public function save(Key $key)
public function save(Key $key): void
{
$key->reduceLifetime($this->initialTtl);
$this->keys[spl_object_hash($key)] = $key;
$this->checkNotExpired($key);

return true;
}

public function delete(Key $key)
public function delete(Key $key): void
{
unset($this->keys[spl_object_hash($key)]);
}
Expand All @@ -491,7 +489,7 @@ public function exists(Key $key): bool
return isset($this->keys[spl_object_hash($key)]);
}

public function putOffExpiration(Key $key, $ttl)
public function putOffExpiration(Key $key, $ttl): void
{
$key->reduceLifetime($ttl);
$this->checkNotExpired($key);
Expand Down
0