8000 Add the void return type in Lock interfaces · symfony/symfony@c7eab24 · GitHub
[go: up one dir, main page]

Skip to content

Commit c7eab24

Browse files
committed
Add the void return type in Lock interfaces
1 parent 24b1b02 commit c7eab24

File tree

7 files changed

+105
-19
lines changed

7 files changed

+105
-19
lines changed

.github/expected-missing-return-types.diff

Lines changed: 86 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7102,94 +7102,94 @@ index 9d7012de35..545339d4ef 100644
71027102
{
71037103
unset($this->parameters[$key]);
71047104
diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php
7105-
index a6650c49a3..2d5eb50ab4 100644
7105+
index cf7e56f13e..e07d5fab79 100644
71067106
--- a/src/Symfony/Component/HttpFoundation/Request.php
71077107
+++ b/src/Symfony/Component/HttpFoundation/Request.php
7108-
@@ -267,5 +267,5 @@ class Request
7108+
@@ -269,5 +269,5 @@ class Request
71097109
* @return void
71107110
*/
71117111
- public function initialize(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
71127112
+ public function initialize(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null): void
71137113
{
71147114
$this->request = new InputBag($request);
7115-
@@ -427,5 +427,5 @@ class Request
7115+
@@ -429,5 +429,5 @@ class Request
71167116
* @return void
71177117
*/
71187118
- public static function setFactory(?callable $callable)
71197119
+ public static function setFactory(?callable $callable): void
71207120
{
71217121
self::$requestFactory = $callable;
7122-
@@ -533,5 +533,5 @@ class Request
7122+
@@ -535,5 +535,5 @@ class Request
71237123
* @return void
71247124
*/
71257125
- public function overrideGlobals()
71267126
+ public function overrideGlobals(): void
71277127
{
71287128
$this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), '', '&')));
7129-
@@ -575,5 +575,5 @@ class Request
7129+
@@ -577,5 +577,5 @@ class Request
71307130
* @return void
71317131
*/
71327132
- public static function setTrustedProxies(array $proxies, int $trustedHeaderSet)
71337133
+ public static function setTrustedProxies(array $proxies, int $trustedHeaderSet): void
71347134
{
71357135
self::$trustedProxies = array_reduce($proxies, function ($proxies, $proxy) {
7136-
@@ -618,5 +618,5 @@ class Request
7136+
@@ -620,5 +620,5 @@ class Request
71377137
* @return void
71387138
*/
71397139
- public static function setTrustedHosts(array $hostPatterns)
71407140
+ public static function setTrustedHosts(array $hostPatterns): void
71417141
{
71427142
self::$trustedHostPatterns = array_map(fn ($hostPattern) => sprintf('{%s}i', $hostPattern), $hostPatterns);
7143-
@@ -666,5 +666,5 @@ class Request
7143+
@@ -668,5 +668,5 @@ class Request
71447144
* @return void
71457145
*/
71467146
- public static function enableHttpMethodParameterOverride()
71477147
+ public static function enableHttpMethodParameterOverride(): void
71487148
{
71497149
self::$httpMethodParameterOverride = true;
7150-
@@ -753,5 +753,5 @@ class Request
7150+
@@ -755,5 +755,5 @@ class Request
71517151
* @return void
71527152
*/
71537153
- public function setSession(SessionInterface $session)
71547154
+ public function setSession(SessionInterface $session): void
71557155
{
71567156
$this->session = $session;
7157-
@@ -1176,5 +1176,5 @@ class Request
7157+
@@ -1178,5 +1178,5 @@ class Request
71587158
* @return void
71597159
*/
71607160
- public function setMethod(string $method)
71617161
+ public function setMethod(string $method): void
71627162
{
71637163
$this->method = null;
7164-
@@ -1299,5 +1299,5 @@ class Request
7164+
@@ -1301,5 +1301,5 @@ class Request
71657165
* @return void
71667166
*/
71677167
- public function setFormat(?string $format, string|array $mimeTypes)
71687168
+ public function setFormat(?string $format, string|array $mimeTypes): void
71697169
{
71707170
if (null === static::$formats) {
7171-
@@ -1331,5 +1331,5 @@ class Request
7171+
@@ -1333,5 +1333,5 @@ class Request
71727172
* @return void
71737173
*/
71747174
- public function setRequestFormat(?string $format)
71757175
+ public function setRequestFormat(?string $format): void
71767176
{
71777177
$this->format = $format;
7178-
@@ -1363,5 +1363,5 @@ class Request
7178+
@@ -1365,5 +1365,5 @@ class Request
71797179
* @return void
71807180
*/
71817181
- public function setDefaultLocale(string $locale)
71827182
+ public function setDefaultLocale(string $locale): void
71837183
{
71847184
$this->defaultLocale = $locale;
7185-
@@ -1385,5 +1385,5 @@ class Request
7185+
@@ -1387,5 +1387,5 @@ class Request
71867186
* @return void
71877187
*/
71887188
- public function setLocale(string $locale)
71897189
+ public function setLocale(string $locale): void
71907190
{
71917191
$this->setPhpDefaultLocale($this->locale = $locale);
7192-
@@ -1900,5 +1900,5 @@ class Request
7192+
@@ -1904,5 +1904,5 @@ class Request
71937193
* @return void
71947194
*/
71957195
- protected static function initializeFormats()
@@ -9050,6 +9050,26 @@ index 7e535ebde1..ebb3df9b2b 100644
90509050
+ public function onCheckPassport(CheckPassportEvent $event): void
90519051
{
90529052
$passport = $event->getPassport();
9053+
diff --git a/src/Symfony/Component/Lock/BlockingSharedLockStoreInterface.php b/src/Symfony/Component/Lock/BlockingSharedLockStoreInterface.php
9054+
index 6929206c42..f2494e1061 100644
9055+
--- a/src/Symfony/Component/Lock/BlockingSharedLockStoreInterface.php
9056+
+++ b/src/Symfony/Component/Lock/BlockingSharedLockStoreInterface.php
9057+
@@ -26,4 +26,4 @@ interface BlockingSharedLockStoreInterface extends SharedLockStoreInterface
9058+
* @throws LockConflictedException
9059+
*/
9060+
- public function waitAndSaveRead(Key $key);
9061+
+ public function waitAndSaveRead(Key $key): void;
9062+
}
9063+
diff --git a/src/Symfony/Component/Lock/BlockingStoreInterface.php b/src/Symfony/Component/Lock/BlockingStoreInterface.php
9064+
index 8a84272a8b..e22fac0538 100644
9065+
--- a/src/Symfony/Component/Lock/BlockingStoreInterface.php
9066+
+++ b/src/Symfony/Component/Lock/BlockingStoreInterface.php
9067+
@@ -26,4 +26,4 @@ interface BlockingStoreInterface extends PersistingStoreInterface
9068+
* @throws LockConflictedException
9069+
*/
9070+
- public function waitAndSave(Key $key);
9071+
+ public function waitAndSave(Key $key): void;
9072+
}
90539073
diff --git a/src/Symfony/Component/Lock/LockFactory.php b/src/Symfony/Component/Lock/LockFactory.php
90549074
index 125b6eae50..ac327e8981 100644
90559075
--- a/src/Symfony/Component/Lock/LockFactory.php
@@ -9068,6 +9088,58 @@ index 125b6eae50..ac327e8981 100644
90689088
+ public function createLockFromKey(Key $key, ?float $ttl = 300.0, bool $autoRelease = true): SharedLockInterface
90699089
{
90709090
$lock = new Lock($key, $this->store, $ttl, $autoRelease);
9091+
diff --git a/src/Symfony/Component/Lock/LockInterface.php b/src/Symfony/Component/Lock/LockInterface.php
9092+
index 8ff806497c..991252e453 100644
9093+
--- a/src/Symfony/Component/Lock/LockInterface.php
9094+
+++ b/src/Symfony/Component/Lock/LockInterface.php
9095+
@@ -42,5 +42,5 @@ interface LockInterface
9096+
* @throws LockAcquiringException If the lock cannot be refreshed
9097+
*/
9098+
- public function refresh(float $ttl = null);
9099+
+ public function refresh(float $ttl = null): void;
9100+
9101+
/**
9102+
@@ -56,5 +56,5 @@ interface LockInterface
9103+
* @throws LockReleasingException If the lock cannot be released
9104+
*/
9105+
- public function release();
9106+
+ public function release(): void;
9107+
9108+
public function isExpired(): bool;
9109+
diff --git a/src/Symfony/Component/Lock/PersistingStoreInterface.php b/src/Symfony/Component/Lock/PersistingStoreInterface.php
9110+
index 10af48c5e6..392446a56a 100644
9111+
--- a/src/Symfony/Component/Lock/PersistingStoreInterface.php
9112+
+++ b/src/Symfony/Component/Lock/PersistingStoreInterface.php
9113+
@@ -29,5 +29,5 @@ interface PersistingStoreInterface
9114+
* @throws LockConflictedException
9115+
*/
9116+
- public function save(Key $key);
9117+
+ public function save(Key $key): void;
9118+
9119+
/**
9120+
@@ -38,5 +38,5 @@ interface PersistingStoreInterface
9121+
* @throws LockReleasingException
9122+
*/
9123+
- public function delete(Key $key);
9124+
+ public function delete(Key $key): void;
9125+
9126+
/**
9127+
@@ -54,4 +54,4 @@ interface PersistingStoreInterface
9128+
* @throws LockConflictedException
9129+
*/
9130+
- public function putOffExpiration(Key $key, float $ttl);
9131+
+ public function putOffExpiration(Key $key, float $ttl): void;
9132+
}
9133+
diff --git a/src/Symfony/Component/Lock/SharedLockStoreInterface.php b/src/Symfony/Component/Lock/SharedLockStoreInterface.php
9134+
index 8246152493..1814a18bca 100644
9135+
--- a/src/Symfony/Component/Lock/SharedLockStoreInterface.php
9136+
+++ b/src/Symfony/Component/Lock/SharedLockStoreInterface.php
9137+
@@ -26,4 +26,4 @@ interface SharedLockStoreInterface extends PersistingStoreInterface
9138+
* @throws LockConflictedException
9139+
*/
9140+
- public function saveRead(Key $key);
9141+
+ public function saveRead(Key $key): void;
9142+
}
90719143
diff --git a/src/Symfony/Component/Lock/Store/CombinedStore.php b/src/Symfony/Component/Lock/Store/CombinedStore.php
90729144
index 9087874c29..5cfd87c4ad 100644
90739145
--- a/src/Symfony/Component/Lock/Store/CombinedStore.php

src/Symfony/Component/Lock/BlockingSharedLockStoreInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ interface BlockingSharedLockStoreInterface extends SharedLockStoreInterface
2121
/**
2222
* Waits until a key becomes free for reading, then stores the resource.
2323
*
24+
* @return void
25+
*
2426
* @throws LockConflictedException
2527
*/
2628
public function waitAndSaveRead(Key $key);

src/Symfony/Component/Lock/BlockingStoreInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ interface BlockingStoreInterface extends PersistingStoreInterface
2121
/**
2222
* Waits until a key becomes free, then stores the resource.
2323
*
24+
* @return void
25+
*
2426
* @throws LockConflictedException
2527
*/
2628
public function waitAndSave(Key $key);

src/Symfony/Component/Lock/LockInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public function acquire(bool $blocking = false): bool;
3636
*
3737
* @param float|null $ttl Maximum expected lock duration in seconds
3838
*
39+
* @return void
40+
*
3941
* @throws LockConflictedException If the lock is acquired by someone else
4042
* @throws LockAcquiringException If the lock cannot be refreshed
4143
*/
@@ -49,6 +51,8 @@ public function isAcquired(): bool;
4951
/**
5052
* Release the lock.
5153
*
54+
* @return void
55+
*
5256
* @throws LockReleasingException If the lock cannot be released
5357
*/
5458
public function release();

src/Symfony/Component/Lock/PersistingStoreInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ interface PersistingStoreInterface
2323
/**
2424
* Stores the resource if it's not locked by someone else.
2525
*
26+
* @return void
27+
*
2628
* @throws LockAcquiringException
2729
* @throws LockConflictedException
2830
*/
@@ -31,6 +33,8 @@ public function save(Key $key);
3133
/**
3234
* Removes a resource from the storage.
3335
*
36+
* @return void
37+
*
34< F438 /code>38
* @throws LockReleasingException
3539
*/
3640
public function delete(Key $key);
@@ -45,6 +49,8 @@ public function exists(Key $key): bool;
4549
*
4650
* @param float $ttl amount of seconds to keep the lock in the store
4751
*
52+
* @return void
53+
*
4854
* @throws LockConflictedException
4955
*/
5056
public function putOffExpiration(Key $key, float $ttl);

src/Symfony/Component/Lock/SharedLockStoreInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ interface SharedLockStoreInterface extends PersistingStoreInterface
2121
/**
2222
* Stores the resource if it's not locked for reading by someone else.
2323
*
24+
* @return void
25+
*
2426
* @throws LockConflictedException
2527
*/
2628
public function saveRead(Key $key);

src/Symfony/Component/Lock/Tests/LockTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,16 +472,14 @@ public function testAcquireReadTwiceWithExpiration()
472472
private $keys = [];
473473
private $initialTtl = 30;
474474

475-
public function save(Key $key)
475+
public function save(Key $key): void
476476
{
477477
$key->reduceLifetime($this->initialTtl);
478478
$this->keys[spl_object_hash($key)] = $key;
479479
$this->checkNotExpired($key);
480-
481-
return true;
482480
}
483481

484-
public function delete(Key $key)
482+
public function delete(Key $key): void
485483
{
486484
unset($this->keys[spl_object_hash($key)]);
487485
}
@@ -491,7 +489,7 @@ public function exists(Key $key): bool
491489
return isset($this->keys[spl_object_hash($key)]);
492490
}
493491

494-
public function putOffExpiration(Key $key, $ttl)
492+
public function putOffExpiration(Key $key, $ttl): void
495493
{
496494
$key->reduceLifetime($ttl);
497495
$this->checkNotExpired($key);

0 commit comments

Comments
 (0)
0