Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7af9daa

Browse filesBrowse files
committed
feature: lock split interface fix post-merge review
1 parent 2e5a8c8 commit 7af9daa
Copy full SHA for 7af9daa

13 files changed

+51
-50
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
use Symfony\Component\Lock\Factory;
7373
use Symfony\Component\Lock\Lock;
7474
use Symfony\Component\Lock\LockInterface;
75-
use Symfony\Component\Lock\PersistStoreInterface;
75+
use Symfony\Component\Lock\PersistingStoreInterface;
7676
use Symfony\Component\Lock\Store\FlockStore;
7777
use Symfony\Component\Lock\Store\StoreFactory;
7878
use Symfony\Component\Lock\StoreInterface;
@@ -1642,12 +1642,12 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont
16421642
$container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory', false));
16431643
$container->setAlias('lock', new Alias('lock.'.$resourceName, false));
16441644
$container->setAlias(StoreInterface::class, new Alias('lock.store', false));
1645-
$container->setAlias(PersistStoreInterface::class, new Alias('lock.store', false));
1645+
$container->setAlias(PersistingStoreInterface::class, new Alias('lock.store', false));
16461646
$container->setAlias(Factory::class, new Alias('lock.factory', false));
16471647
$container->setAlias(LockInterface::class, new Alias('lock', false));
16481648
} else {
16491649
$container->registerAliasForArgument('lock.'.$resourceName.'.store', StoreInterface::class, $resourceName.'.lock.store');
1650-
$container->registerAliasForArgument('lock.'.$resourceName.'.store', PersistStoreInterface::class, $resourceName.'.lock.store');
1650+
$container->registerAliasForArgument('lock.'.$resourceName.'.store', PersistingStoreInterface::class, $resourceName.'.lock.store');
16511651
$container->registerAliasForArgument('lock.'.$resourceName.'.factory', Factory::class, $resourceName.'.lock.factory');
16521652
$container->registerAliasForArgument('lock.'.$resourceName, LockInterface::class, $resourceName.'.lock');
16531653
}

‎src/Symfony/Component/Lock/BlockingStoreInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/BlockingStoreInterface.php
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Lock;
1313

1414
use Symfony\Component\Lock\Exception\LockConflictedException;
15-
use Symfony\Component\Lock\Exception\NotSupportedException;
1615

1716
/**
1817
* @author Hamza Amrouche <hamza.simperfit@gmail.com>
@@ -22,10 +21,7 @@ interface BlockingStoreInterface
2221
/**
2322
* Waits until a key becomes free, then stores the resource.
2423
*
25-
* If the store does not support this feature it should throw a NotSupportedException.
26-
*
2724
* @throws LockConflictedException
28-
* @throws NotSupportedException
2925
*/
3026
public function waitAndSave(Key $key);
3127

‎src/Symfony/Component/Lock/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CHANGELOG
55
-----
66

77
* added InvalidTtlException
8-
* deprecated `Symfony\Component\Lock\StoreInterface` in favor of `Symfony\Component\Lock\BlockingStoreInterface` and `Symfony\Component\Lock\PersistStoreInterface`
8+
* deprecated `StoreInterface` in favor of `BlockingStoreInterface` and `PersistingStoreInterface`
99

1010
4.2.0
1111
-----

‎src/Symfony/Component/Lock/Lock.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Lock.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ final class Lock implements LockInterface, LoggerAwareInterface
3737
private $dirty = false;
3838

3939
/**
40-
* @param Key $key Resource to lock
41-
* @param PersistStoreInterface $store Store used to handle lock persistence
42-
* @param float|null $ttl Maximum expected lock duration in seconds
43-
* @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed
40+
* @param Key $key Resource to lock
41+
* @param PersistingStoreInterface $store Store used to handle lock persistence
42+
* @param float|null $ttl Maximum expected lock duration in seconds
43+
* @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed
4444
*/
45-
public function __construct(Key $key, PersistStoreInterface $store, float $ttl = null, bool $autoRelease = true)
45+
public function __construct(Key $key, PersistingStoreInterface $store, float $ttl = null, bool $autoRelease = true)
4646
{
4747
$this->store = $store;
4848
$this->key = $key;

‎src/Symfony/Component/Lock/PersistStoreInterface.php renamed to ‎src/Symfony/Component/Lock/PersistingStoreInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/PersistingStoreInterface.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* @author Jérémy Derussé <jeremy@derusse.com>
2020
*/
21-
interface PersistStoreInterface
21+
interface PersistingStoreInterface
2222
{
2323
/**
2424
* Stores the resource if it's not locked by someone else.

‎src/Symfony/Component/Lock/Store/CombinedStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/CombinedStore.php
+9-7Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\Component\Lock\Exception\LockConflictedException;
1919
use Symfony\Component\Lock\Exception\NotSupportedException;
2020
use Symfony\Component\Lock\Key;
21-
use Symfony\Component\Lock\PersistStoreInterface;
21+
use Symfony\Component\Lock\PersistingStoreInterface;
2222
use Symfony\Component\Lock\StoreInterface;
2323
use Symfony\Component\Lock\Strategy\StrategyInterface;
2424

@@ -32,22 +32,22 @@ class CombinedStore implements StoreInterface, LoggerAwareInterface
3232
use LoggerAwareTrait;
3333
use ExpiringStoreTrait;
3434

35-
/** @var PersistStoreInterface[] */
35+
/** @var PersistingStoreInterface[] */
3636
private $stores;
3737
/** @var StrategyInterface */
3838
private $strategy;
3939

4040
/**
41-
* @param PersistStoreInterface[] $stores The list of synchronized stores
42-
* @param StrategyInterface $strategy
41+
* @param PersistingStoreInterface[] $stores The list of synchronized stores
42+
* @param StrategyInterface $strategy
4343
*
4444
* @throws InvalidArgumentException
4545
*/
4646
public function __construct(array $stores, StrategyInterface $strategy)
4747
{
4848
foreach ($stores as $store) {
49-
if (!$store instanceof PersistStoreInterface) {
50-
throw new InvalidArgumentException(sprintf('The store must implement "%s". Got "%s".', PersistStoreInterface::class, \get_class($store)));
49+
if (!$store instanceof PersistingStoreInterface) {
50+
throw new InvalidArgumentException(sprintf('The store must implement "%s". Got "%s".', PersistingStoreInterface::class, \get_class($store)));
5151
}
5252
}
5353

@@ -95,10 +95,12 @@ public function save(Key $key)
9595

9696
/**
9797
* {@inheritdoc}
98+
*
99+
* @deprecated since Symfony 4.4 and will be removed in 5.0.
98100
*/
99101
public function waitAndSave(Key $key)
100102
{
101-
@trigger_error(sprintf('%s::%s has been deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', \get_class($this), __METHOD__), E_USER_DEPRECATED);
103+
@trigger_error(sprintf('%s() has been deprecated since Symfony 4.4 and will be removed in 5.0.', __METHOD__), E_USER_DEPRECATED);
102104
throw new NotSupportedException(sprintf('The store "%s" does not supports blocking locks.', \get_class($this)));
103105
}
104106

‎src/Symfony/Component/Lock/Store/MemcachedStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/MemcachedStore.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ public function save(Key $key)
7171

7272
/**
7373
* {@inheritdoc}
74+
*
75+
* @deprecated since Symfony 4.4 and will be removed in 5.0.
7476
*/
7577
public function waitAndSave(Key $key)
7678
{
77-
@trigger_error(sprintf('%s has been deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', __METHOD__));
79+
@trigger_error(sprintf('%s() has been deprecated since Symfony 4.4 and will be removed in 5.0.', __METHOD__));
7880
throw new InvalidArgumentException(sprintf('The store "%s" does not supports blocking locks.', \get_class($this)));
7981
}
8082

‎src/Symfony/Component/Lock/Store/RedisStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/RedisStore.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ public function save(Key $key)
7474

7575
/**
7676
* {@inheritdoc}
77+
*
78+
* @deprecated since Symfony 4.4 and will be removed in 5.0.
7779
*/
7880
public function waitAndSave(Key $key)
7981
{
80-
@trigger_error(sprintf('%s::%s has been deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', \get_class($this), __METHOD__), E_USER_DEPRECATED);
82+
@trigger_error(sprintf('%s() has been deprecated since Symfony 4.4 and will be removed in 5.0.', __METHOD__), E_USER_DEPRECATED);
8183
throw new InvalidArgumentException(sprintf('The store "%s" does not supports blocking locks.', \get_class($this)));
8284
}
8385

‎src/Symfony/Component/Lock/Store/RetryTillSaveStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/RetryTillSaveStore.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Symfony\Component\Lock\BlockingStoreInterface;
1818
use Symfony\Component\Lock\Exception\LockConflictedException;
1919
use Symfony\Component\Lock\Key;
20-
use Symfony\Component\Lock\PersistStoreInterface;
20+
use Symfony\Component\Lock\PersistingStoreInterface;
2121
use Symfony\Component\Lock\StoreInterface;
2222

2323
/**
@@ -26,7 +26,7 @@
2626
*
2727
* @author Jérémy Derussé <jeremy@derusse.com>
2828
*/
29-
class RetryTillSaveStore implements PersistStoreInterface, BlockingStoreInterface, StoreInterface, LoggerAwareInterface
29+
class RetryTillSaveStore implements PersistingStoreInterface, BlockingStoreInterface, StoreInterface, LoggerAwareInterface
3030
{
3131
use LoggerAwareTrait;
3232

@@ -35,11 +35,11 @@ class RetryTillSaveStore implements PersistStoreInterface, BlockingStoreInterfac
3535
private $retryCount;
3636

3737
/**
38-
* @param PersistStoreInterface $decorated The decorated StoreInterface
39-
* @param int $retrySleep Duration in ms between 2 retry
40-
* @param int $retryCount Maximum amount of retry
38+
* @param PersistingStoreInterface $decorated The decorated StoreInterface
39+
* @param int $retrySleep Duration in ms between 2 retry
40+
* @param int $retryCount Maximum amount of retry
4141
*/
42-
public function __construct(PersistStoreInterface $decorated, int $retrySleep = 100, int $retryCount = PHP_INT_MAX)
42+
public function __construct(PersistingStoreInterface $decorated, int $retrySleep = 100, int $retryCount = PHP_INT_MAX)
4343
{
4444
$this->decorated = $decorated;
4545
$this->retrySleep = $retrySleep;

‎src/Symfony/Component/Lock/Store/ZookeeperStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/ZookeeperStore.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ public function exists(Key $key): bool
8484

8585
/**
8686
* {@inheritdoc}
87+
*
88+
* @deprecated since Symfony 4.4 and will be removed in 5.0.
8789
*/
8890
public function waitAndSave(Key $key)
8991
{
90-
@trigger_error(sprintf('%s::%s has been deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', \get_class($this), __METHOD__), E_USER_DEPRECATED);
92+
@trigger_error(sprintf('%s() has been deprecated since Symfony 4.4 and will be removed in 5.0.', __METHOD__), E_USER_DEPRECATED);
9193
throw new NotSupportedException();
9294
}
9395

‎src/Symfony/Component/Lock/StoreInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/StoreInterface.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
*
2020
* @author Jérémy Derussé <jeremy@derusse.com>
2121
*
22-
* @deprecated "Symfony\Component\Lock\StoreInterface" is deprecated since Symfony 4.4 and has been split into "Symfony\Component\Lock\PersistStoreInterface", "Symfony\Component\Lock\BlockingStoreInterface".'
22+
* @deprecated "Symfony\Component\Lock\StoreInterface" is deprecated since Symfony 4.4 and has been split into "Symfony\Component\Lock\PersistingStoreInterface", "Symfony\Component\Lock\BlockingStoreInterface".'
2323
*/
24-
interface StoreInterface extends PersistStoreInterface
24+
interface StoreInterface extends PersistingStoreInterface
2525
{
2626
/**
2727
* Waits until a key becomes free, then stores the resource.

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Tests/LockTest.php
+12-15Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Symfony\Component\Lock\Exception\LockConflictedException;
1818
use Symfony\Component\Lock\Key;
1919
use Symfony\Component\Lock\Lock;
20-
use Symfony\Component\Lock\PersistStoreInterface;
20+
use Symfony\Component\Lock\PersistingStoreInterface;
2121
use Symfony\Component\Lock\StoreInterface;
2222

2323
/**
@@ -28,7 +28,7 @@ class LockTest extends TestCase
2828
public function testAcquireNoBlocking()
2929
{
3030
$key = new Key(uniqid(__METHOD__, true));
31-
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
31+
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
3232
$lock = new Lock($key, $store);
3333

3434
$store
@@ -53,8 +53,6 @@ public function testAcquireNoBlockingStoreInterface()
5353

5454
/**
5555
* @group legacy
56-
*
57-
* @deprecated
5856
*/
5957
public function testPassingOldStoreInterface()
6058
{
@@ -72,7 +70,7 @@ public function testPassingOldStoreInterface()
7270
public function testAcquireReturnsFalse()
7371
{
7472
$key = new Key(uniqid(__METHOD__, true));
75-
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
73+
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
7674
$lock = new Lock($key, $store);
7775

7876
$store
@@ -100,12 +98,11 @@ public function testAcquireReturnsFalseStoreInterface()
10098
public function testAcquireBlocking()
10199
{
102100
$key = new Key(uniqid(__METHOD__, true));
103-
$store = $this->getMockBuilder([PersistStoreInterface::class, BlockingStoreInterface::class])->getMock();
101+
$store = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock();
104102
$lock = new Lock($key, $store);
105103
$store
106104
->expects($this->once())
107105
->method('supportsWaitAndSave')
108-
->with()
109106
->willReturn(true);
110107

111108
$store
@@ -166,7 +163,7 @@ public function testRefreshCustom()
166163
public function testIsAquired()
167164
{
168165
$key = new Key(uniqid(__METHOD__, true));
169-
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
166+
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
170167
$lock = new Lock($key, $store, 10);
171168

172169
$store
@@ -181,7 +178,7 @@ public function testIsAquired()
181178
public function testRelease()
182179
{
183180
$key = new Key(uniqid(__METHOD__, true));
184-
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
181+
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
185182
$lock = new Lock($key, $store, 10);
186183

187184
$store
@@ -221,7 +218,7 @@ public function testReleaseStoreInterface()
221218
public function testReleaseOnDestruction()
222219
{
223220
$key = new Key(uniqid(__METHOD__, true));
224-
$store = $this->getMockBuilder([PersistStoreInterface::class, BlockingStoreInterface::class])->getMock();
221+
$store = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock();
225222
$lock = new Lock($key, $store, 10);
226223

227224
$store
@@ -240,7 +237,7 @@ public function testReleaseOnDestruction()
240237
public function testNoAutoReleaseWhenNotConfigured()
241238
{
242239
$key = new Key(uniqid(__METHOD__, true));
243-
$store = $this->getMockBuilder([PersistStoreInterface::class, BlockingStoreInterface::class])->getMock();
240+
$store = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock();
244241
$lock = new Lock($key, $store, 10, false);
245242

246243
$store
@@ -262,7 +259,7 @@ public function testNoAutoReleaseWhenNotConfigured()
262259
public function testReleaseThrowsExceptionWhenDeletionFail()
263260
{
264261
$key = new Key(uniqid(__METHOD__, true));
265-
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
262+
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
266263
$lock = new Lock($key, $store, 10);
267264

268265
$store
@@ -285,7 +282,7 @@ public function testReleaseThrowsExceptionWhenDeletionFail()
285282
public function testReleaseThrowsExceptionIfNotWellDeleted()
286283
{
287284
$key = new Key(uniqid(__METHOD__, true));
288-
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
285+
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
289286
$lock = new Lock($key, $store, 10);
290287

291288
$store
@@ -308,7 +305,7 @@ public function testReleaseThrowsExceptionIfNotWellDeleted()
308305
public function testReleaseThrowsAndLog()
309306
{
310307
$key = new Key(uniqid(__METHOD__, true));
311-
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
308+
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
312309
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
313310
$lock = new Lock($key, $store, 10, true);
314311
$lock->setLogger($logger);
@@ -337,7 +334,7 @@ public function testReleaseThrowsAndLog()
337334
public function testExpiration($ttls, $expected)
338335
{
339336
$key = new Key(uniqid(__METHOD__, true));
340-
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
337+
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
341338
$lock = new Lock($key, $store, 10);
342339

343340
foreach ($ttls as $ttl) {

‎src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Lock\BlockingStoreInterface;
1515
use Symfony\Component\Lock\Exception\LockConflictedException;
1616
use Symfony\Component\Lock\Key;
17-
use Symfony\Component\Lock\PersistStoreInterface;
17+
use Symfony\Component\Lock\PersistingStoreInterface;
1818
use Symfony\Component\Lock\Store\CombinedStore;
1919
use Symfony\Component\Lock\Store\RedisStore;
2020
use Symfony\Component\Lock\StoreInterface;
@@ -63,8 +63,8 @@ public function getStore()
6363
protected function setUp()
6464
{
6565
$this->strategy = $this->getMockBuilder(StrategyInterface::class)->getMock();
66-
$this->store1 = $this->getMockBuilder([PersistStoreInterface::class, BlockingStoreInterface::class])->getMock();
67-
$this->store2 = $this->getMockBuilder([PersistStoreInterface::class, BlockingStoreInterface::class])->getMock();
66+
$this->store1 = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock();
67+
$this->store2 = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock();
6868

6969
$this->store = new CombinedStore([$this->store1, $this->store2], $this->strategy);
7070
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.