minor #32492 [Lock] feature: lock split interface fix post-merge review (Simperfit)

This PR was squashed before being merged into the 4.4 branch (closes #32492).

Discussion
----------

[Lock] feature: lock split interface fix post-merge review

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yesish <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | none   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | none <!-- required for new features -->

<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against branch 4.4.
 - Legacy code removals go to the master branch.
-->

see https://github.com/symfony/symfony/pull/32198#pullrequestreview-259854210

Commits
-------

8173c475f3 [Lock] feature: lock split interface fix post-merge review
This commit is contained in:
Nicolas Grekas 2019-07-18 15:47:02 +02:00
commit e80d4057f9
19 changed files with 66 additions and 106 deletions

View File

@ -105,7 +105,7 @@ Lock
---- ----
* Deprecated `Symfony\Component\Lock\StoreInterface` in favor of `Symfony\Component\Lock\BlockingStoreInterface` and * Deprecated `Symfony\Component\Lock\StoreInterface` in favor of `Symfony\Component\Lock\BlockingStoreInterface` and
`Symfony\Component\Lock\PersistStoreInterface`. `Symfony\Component\Lock\PersistingStoreInterface`.
* `Factory` is deprecated, use `LockFactory` instead * `Factory` is deprecated, use `LockFactory` instead
Messenger Messenger

View File

@ -311,7 +311,7 @@ Lock
---- ----
* Removed `Symfony\Component\Lock\StoreInterface` in favor of `Symfony\Component\Lock\BlockingStoreInterface` and * Removed `Symfony\Component\Lock\StoreInterface` in favor of `Symfony\Component\Lock\BlockingStoreInterface` and
`Symfony\Component\Lock\PersistStoreInterface`. `Symfony\Component\Lock\PersistingStoreInterface`.
* Removed `Factory`, use `LockFactory` instead * Removed `Factory`, use `LockFactory` instead
Messenger Messenger

View File

@ -73,7 +73,7 @@ use Symfony\Component\Lock\Factory;
use Symfony\Component\Lock\Lock; use Symfony\Component\Lock\Lock;
use Symfony\Component\Lock\LockFactory; use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\LockInterface; use Symfony\Component\Lock\LockInterface;
use Symfony\Component\Lock\PersistStoreInterface; use Symfony\Component\Lock\PersistingStoreInterface;
use Symfony\Component\Lock\Store\FlockStore; use Symfony\Component\Lock\Store\FlockStore;
use Symfony\Component\Lock\Store\StoreFactory; use Symfony\Component\Lock\Store\StoreFactory;
use Symfony\Component\Lock\StoreInterface; use Symfony\Component\Lock\StoreInterface;
@ -1606,7 +1606,7 @@ class FrameworkExtension extends Extension
$container->setDefinition($connectionDefinitionId, $connectionDefinition); $container->setDefinition($connectionDefinitionId, $connectionDefinition);
} }
$storeDefinition = new Definition(PersistStoreInterface::class); $storeDefinition = new Definition(PersistingStoreInterface::class);
$storeDefinition->setPublic(false); $storeDefinition->setPublic(false);
$storeDefinition->setFactory([StoreFactory::class, 'createStore']); $storeDefinition->setFactory([StoreFactory::class, 'createStore']);
$storeDefinition->setArguments([new Reference($connectionDefinitionId)]); $storeDefinition->setArguments([new Reference($connectionDefinitionId)]);
@ -1649,13 +1649,13 @@ class FrameworkExtension extends Extension
$container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory', false)); $container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory', false));
$container->setAlias('lock', new Alias('lock.'.$resourceName, false)); $container->setAlias('lock', new Alias('lock.'.$resourceName, false));
$container->setAlias(StoreInterface::class, new Alias('lock.store', false)); $container->setAlias(StoreInterface::class, new Alias('lock.store', false));
$container->setAlias(PersistStoreInterface::class, new Alias('lock.store', false)); $container->setAlias(PersistingStoreInterface::class, new Alias('lock.store', false));
$container->setAlias(Factory::class, new Alias('lock.factory', false)); $container->setAlias(Factory::class, new Alias('lock.factory', false));
$container->setAlias(LockFactory::class, new Alias('lock.factory', false)); $container->setAlias(LockFactory::class, new Alias('lock.factory', false));
$container->setAlias(LockInterface::class, new Alias('lock', false)); $container->setAlias(LockInterface::class, new Alias('lock', false));
} else { } else {
$container->registerAliasForArgument('lock.'.$resourceName.'.store', StoreInterface::class, $resourceName.'.lock.store'); $container->registerAliasForArgument('lock.'.$resourceName.'.store', StoreInterface::class, $resourceName.'.lock.store');
$container->registerAliasForArgument('lock.'.$resourceName.'.store', PersistStoreInterface::class, $resourceName.'.lock.store'); $container->registerAliasForArgument('lock.'.$resourceName.'.store', PersistingStoreInterface::class, $resourceName.'.lock.store');
$container->registerAliasForArgument('lock.'.$resourceName.'.factory', Factory::class, $resourceName.'.lock.factory'); $container->registerAliasForArgument('lock.'.$resourceName.'.factory', Factory::class, $resourceName.'.lock.factory');
$container->registerAliasForArgument('lock.'.$resourceName.'.factory', LockFactory::class, $resourceName.'.lock.factory'); $container->registerAliasForArgument('lock.'.$resourceName.'.factory', LockFactory::class, $resourceName.'.lock.factory');
$container->registerAliasForArgument('lock.'.$resourceName, LockInterface::class, $resourceName.'.lock'); $container->registerAliasForArgument('lock.'.$resourceName, LockInterface::class, $resourceName.'.lock');

View File

@ -12,7 +12,6 @@
namespace Symfony\Component\Lock; namespace Symfony\Component\Lock;
use Symfony\Component\Lock\Exception\LockConflictedException; use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Exception\NotSupportedException;
/** /**
* @author Hamza Amrouche <hamza.simperfit@gmail.com> * @author Hamza Amrouche <hamza.simperfit@gmail.com>
@ -22,15 +21,7 @@ interface BlockingStoreInterface
/** /**
* Waits until a key becomes free, then stores the resource. * Waits until a key becomes free, then stores the resource.
* *
* If the store does not support this feature it should throw a NotSupportedException.
*
* @throws LockConflictedException * @throws LockConflictedException
* @throws NotSupportedException
*/ */
public function waitAndSave(Key $key); public function waitAndSave(Key $key);
/**
* Checks if the store can wait until a key becomes free before storing the resource.
*/
public function supportsWaitAndSave(): bool;
} }

View File

@ -5,7 +5,7 @@ CHANGELOG
----- -----
* added InvalidTtlException * added InvalidTtlException
* deprecated `Symfony\Component\Lock\StoreInterface` in favor of `Symfony\Component\Lock\BlockingStoreInterface` and `Symfony\Component\Lock\PersistStoreInterface` * deprecated `StoreInterface` in favor of `BlockingStoreInterface` and `PersistingStoreInterface`
4.2.0 4.2.0
----- -----

View File

@ -37,12 +37,12 @@ final class Lock implements LockInterface, LoggerAwareInterface
private $dirty = false; private $dirty = false;
/** /**
* @param Key $key Resource to lock * @param Key $key Resource to lock
* @param PersistStoreInterface $store Store used to handle lock persistence * @param PersistingStoreInterface $store Store used to handle lock persistence
* @param float|null $ttl Maximum expected lock duration in seconds * @param float|null $ttl Maximum expected lock duration in seconds
* @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed * @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed
*/ */
public function __construct(Key $key, PersistStoreInterface $store, float $ttl = null, bool $autoRelease = true) public function __construct(Key $key, PersistingStoreInterface $store, float $ttl = null, bool $autoRelease = true)
{ {
$this->store = $store; $this->store = $store;
$this->key = $key; $this->key = $key;
@ -71,7 +71,7 @@ final class Lock implements LockInterface, LoggerAwareInterface
{ {
try { try {
if ($blocking) { if ($blocking) {
if (!$this->store instanceof StoreInterface && !($this->store instanceof BlockingStoreInterface && $this->store->supportsWaitAndSave())) { if (!$this->store instanceof StoreInterface && !$this->store instanceof BlockingStoreInterface) {
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this->store))); throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this->store)));
} }
$this->store->waitAndSave($this->key); $this->store->waitAndSave($this->key);

View File

@ -18,7 +18,7 @@ use Symfony\Component\Lock\Exception\LockReleasingException;
/** /**
* @author Jérémy Derussé <jeremy@derusse.com> * @author Jérémy Derussé <jeremy@derusse.com>
*/ */
interface PersistStoreInterface interface PersistingStoreInterface
{ {
/** /**
* Stores the resource if it's not locked by someone else. * Stores the resource if it's not locked by someone else.

View File

@ -18,7 +18,7 @@ use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Exception\LockConflictedException; use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Exception\NotSupportedException; use Symfony\Component\Lock\Exception\NotSupportedException;
use Symfony\Component\Lock\Key; use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\PersistStoreInterface; use Symfony\Component\Lock\PersistingStoreInterface;
use Symfony\Component\Lock\StoreInterface; use Symfony\Component\Lock\StoreInterface;
use Symfony\Component\Lock\Strategy\StrategyInterface; use Symfony\Component\Lock\Strategy\StrategyInterface;
@ -32,22 +32,22 @@ class CombinedStore implements StoreInterface, LoggerAwareInterface
use LoggerAwareTrait; use LoggerAwareTrait;
use ExpiringStoreTrait; use ExpiringStoreTrait;
/** @var PersistStoreInterface[] */ /** @var PersistingStoreInterface[] */
private $stores; private $stores;
/** @var StrategyInterface */ /** @var StrategyInterface */
private $strategy; private $strategy;
/** /**
* @param PersistStoreInterface[] $stores The list of synchronized stores * @param PersistingStoreInterface[] $stores The list of synchronized stores
* @param StrategyInterface $strategy * @param StrategyInterface $strategy
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function __construct(array $stores, StrategyInterface $strategy) public function __construct(array $stores, StrategyInterface $strategy)
{ {
foreach ($stores as $store) { foreach ($stores as $store) {
if (!$store instanceof PersistStoreInterface) { if (!$store instanceof PersistingStoreInterface) {
throw new InvalidArgumentException(sprintf('The store must implement "%s". Got "%s".', PersistStoreInterface::class, \get_class($store))); throw new InvalidArgumentException(sprintf('The store must implement "%s". Got "%s".', PersistingStoreInterface::class, \get_class($store)));
} }
} }
@ -95,6 +95,8 @@ class CombinedStore implements StoreInterface, LoggerAwareInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @deprecated since Symfony 4.4.
*/ */
public function waitAndSave(Key $key) public function waitAndSave(Key $key)
{ {
@ -186,12 +188,4 @@ class CombinedStore implements StoreInterface, LoggerAwareInterface
return false; return false;
} }
/**
* {@inheritdoc}
*/
public function supportsWaitAndSave(): bool
{
return false;
}
} }

View File

@ -65,14 +65,6 @@ class FlockStore implements StoreInterface, BlockingStoreInterface
$this->lock($key, true); $this->lock($key, true);
} }
/**
* {@inheritdoc}
*/
public function supportsWaitAndSave(): bool
{
return true;
}
private function lock(Key $key, $blocking) private function lock(Key $key, $blocking)
{ {
// The lock is maybe already acquired. // The lock is maybe already acquired.

View File

@ -71,10 +71,12 @@ class MemcachedStore implements StoreInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @deprecated since Symfony 4.4.
*/ */
public function waitAndSave(Key $key) public function waitAndSave(Key $key)
{ {
@trigger_error(sprintf('%s() is deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', __METHOD__)); @trigger_error(sprintf('%s() is deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', __METHOD__), E_USER_DEPRECATED);
throw new InvalidArgumentException(sprintf('The store "%s" does not supports blocking locks.', \get_class($this))); throw new InvalidArgumentException(sprintf('The store "%s" does not supports blocking locks.', \get_class($this)));
} }

View File

@ -74,6 +74,8 @@ class RedisStore implements StoreInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @deprecated since Symfony 4.4.
*/ */
public function waitAndSave(Key $key) public function waitAndSave(Key $key)
{ {

View File

@ -17,7 +17,7 @@ use Psr\Log\NullLogger;
use Symfony\Component\Lock\BlockingStoreInterface; use Symfony\Component\Lock\BlockingStoreInterface;
use Symfony\Component\Lock\Exception\LockConflictedException; use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Key; use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\PersistStoreInterface; use Symfony\Component\Lock\PersistingStoreInterface;
use Symfony\Component\Lock\StoreInterface; use Symfony\Component\Lock\StoreInterface;
/** /**
@ -26,7 +26,7 @@ use Symfony\Component\Lock\StoreInterface;
* *
* @author Jérémy Derussé <jeremy@derusse.com> * @author Jérémy Derussé <jeremy@derusse.com>
*/ */
class RetryTillSaveStore implements PersistStoreInterface, BlockingStoreInterface, StoreInterface, LoggerAwareInterface class RetryTillSaveStore implements PersistingStoreInterface, BlockingStoreInterface, StoreInterface, LoggerAwareInterface
{ {
use LoggerAwareTrait; use LoggerAwareTrait;
@ -35,11 +35,11 @@ class RetryTillSaveStore implements PersistStoreInterface, BlockingStoreInterfac
private $retryCount; private $retryCount;
/** /**
* @param PersistStoreInterface $decorated The decorated StoreInterface * @param PersistingStoreInterface $decorated The decorated StoreInterface
* @param int $retrySleep Duration in ms between 2 retry * @param int $retrySleep Duration in ms between 2 retry
* @param int $retryCount Maximum amount of retry * @param int $retryCount Maximum amount of retry
*/ */
public function __construct(PersistStoreInterface $decorated, int $retrySleep = 100, int $retryCount = PHP_INT_MAX) public function __construct(PersistingStoreInterface $decorated, int $retrySleep = 100, int $retryCount = PHP_INT_MAX)
{ {
$this->decorated = $decorated; $this->decorated = $decorated;
$this->retrySleep = $retrySleep; $this->retrySleep = $retrySleep;
@ -101,12 +101,4 @@ class RetryTillSaveStore implements PersistStoreInterface, BlockingStoreInterfac
{ {
return $this->decorated->exists($key); return $this->decorated->exists($key);
} }
/**
* {@inheritdoc}
*/
public function supportsWaitAndSave(): bool
{
return true;
}
} }

View File

@ -113,12 +113,4 @@ class SemaphoreStore implements StoreInterface, BlockingStoreInterface
{ {
return $key->hasState(__CLASS__); return $key->hasState(__CLASS__);
} }
/**
* {@inheritdoc}
*/
public function supportsWaitAndSave(): bool
{
return true;
}
} }

View File

@ -84,6 +84,8 @@ class ZookeeperStore implements StoreInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @deprecated since Symfony 4.4.
*/ */
public function waitAndSave(Key $key) public function waitAndSave(Key $key)
{ {

View File

@ -19,9 +19,9 @@ use Symfony\Component\Lock\Exception\NotSupportedException;
* *
* @author Jérémy Derussé <jeremy@derusse.com> * @author Jérémy Derussé <jeremy@derusse.com>
* *
* @deprecated "Symfony\Component\Lock\StoreInterface" is deprecated since Symfony 4.4 and has been split into "Symfony\Component\Lock\PersistStoreInterface", "Symfony\Component\Lock\BlockingStoreInterface".' * @deprecated since Symfony 4.4, use PersistingStoreInterface and BlockingStoreInterface instead
*/ */
interface StoreInterface extends PersistStoreInterface interface StoreInterface extends PersistingStoreInterface
{ {
/** /**
* Waits until a key becomes free, then stores the resource. * Waits until a key becomes free, then stores the resource.

View File

@ -17,7 +17,7 @@ use Symfony\Component\Lock\BlockingStoreInterface;
use Symfony\Component\Lock\Exception\LockConflictedException; use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Key; use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\Lock; use Symfony\Component\Lock\Lock;
use Symfony\Component\Lock\PersistStoreInterface; use Symfony\Component\Lock\PersistingStoreInterface;
/** /**
* @author Jérémy Derussé <jeremy@derusse.com> * @author Jérémy Derussé <jeremy@derusse.com>
@ -27,7 +27,7 @@ class LockTest extends TestCase
public function testAcquireNoBlocking() public function testAcquireNoBlocking()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store); $lock = new Lock($key, $store);
$store $store
@ -40,7 +40,7 @@ class LockTest extends TestCase
public function testAcquireNoBlockingStoreInterface() public function testAcquireNoBlockingStoreInterface()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store); $lock = new Lock($key, $store);
$store $store
@ -52,13 +52,11 @@ class LockTest extends TestCase
/** /**
* @group legacy * @group legacy
*
* @deprecated
*/ */
public function testPassingOldStoreInterface() public function testPassingOldStoreInterface()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store); $lock = new Lock($key, $store);
$store $store
@ -71,7 +69,7 @@ class LockTest extends TestCase
public function testAcquireReturnsFalse() public function testAcquireReturnsFalse()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store); $lock = new Lock($key, $store);
$store $store
@ -85,7 +83,7 @@ class LockTest extends TestCase
public function testAcquireReturnsFalseStoreInterface() public function testAcquireReturnsFalseStoreInterface()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store); $lock = new Lock($key, $store);
$store $store
@ -99,13 +97,8 @@ class LockTest extends TestCase
public function testAcquireBlocking() public function testAcquireBlocking()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder([PersistStoreInterface::class, BlockingStoreInterface::class])->getMock(); $store = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock();
$lock = new Lock($key, $store); $lock = new Lock($key, $store);
$store
->expects($this->once())
->method('supportsWaitAndSave')
->with()
->willReturn(true);
$store $store
->expects($this->never()) ->expects($this->never())
@ -120,7 +113,7 @@ class LockTest extends TestCase
public function testAcquireSetsTtl() public function testAcquireSetsTtl()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10); $lock = new Lock($key, $store, 10);
$store $store
@ -137,7 +130,7 @@ class LockTest extends TestCase
public function testRefresh() public function testRefresh()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10); $lock = new Lock($key, $store, 10);
$store $store
@ -151,7 +144,7 @@ class LockTest extends TestCase
public function testRefreshCustom() public function testRefreshCustom()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10); $lock = new Lock($key, $store, 10);
$store $store
@ -165,7 +158,7 @@ class LockTest extends TestCase
public function testIsAquired() public function testIsAquired()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10); $lock = new Lock($key, $store, 10);
$store $store
@ -180,7 +173,7 @@ class LockTest extends TestCase
public function testRelease() public function testRelease()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10); $lock = new Lock($key, $store, 10);
$store $store
@ -200,7 +193,7 @@ class LockTest extends TestCase
public function testReleaseStoreInterface() public function testReleaseStoreInterface()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10); $lock = new Lock($key, $store, 10);
$store $store
@ -220,7 +213,7 @@ class LockTest extends TestCase
public function testReleaseOnDestruction() public function testReleaseOnDestruction()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder([PersistStoreInterface::class, BlockingStoreInterface::class])->getMock(); $store = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock();
$lock = new Lock($key, $store, 10); $lock = new Lock($key, $store, 10);
$store $store
@ -239,7 +232,7 @@ class LockTest extends TestCase
public function testNoAutoReleaseWhenNotConfigured() public function testNoAutoReleaseWhenNotConfigured()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder([PersistStoreInterface::class, BlockingStoreInterface::class])->getMock(); $store = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock();
$lock = new Lock($key, $store, 10, false); $lock = new Lock($key, $store, 10, false);
$store $store
@ -261,7 +254,7 @@ class LockTest extends TestCase
public function testReleaseThrowsExceptionWhenDeletionFail() public function testReleaseThrowsExceptionWhenDeletionFail()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10); $lock = new Lock($key, $store, 10);
$store $store
@ -284,7 +277,7 @@ class LockTest extends TestCase
public function testReleaseThrowsExceptionIfNotWellDeleted() public function testReleaseThrowsExceptionIfNotWellDeleted()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10); $lock = new Lock($key, $store, 10);
$store $store
@ -307,7 +300,7 @@ class LockTest extends TestCase
public function testReleaseThrowsAndLog() public function testReleaseThrowsAndLog()
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
$lock = new Lock($key, $store, 10, true); $lock = new Lock($key, $store, 10, true);
$lock->setLogger($logger); $lock->setLogger($logger);
@ -336,7 +329,7 @@ class LockTest extends TestCase
public function testExpiration($ttls, $expected) public function testExpiration($ttls, $expected)
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10); $lock = new Lock($key, $store, 10);
foreach ($ttls as $ttl) { foreach ($ttls as $ttl) {
@ -355,7 +348,7 @@ class LockTest extends TestCase
public function testExpirationStoreInterface($ttls, $expected) public function testExpirationStoreInterface($ttls, $expected)
{ {
$key = new Key(uniqid(__METHOD__, true)); $key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10); $lock = new Lock($key, $store, 10);
foreach ($ttls as $ttl) { foreach ($ttls as $ttl) {

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\Lock\Tests\Store;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\Lock\Exception\LockConflictedException; use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Key; use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\PersistStoreInterface; use Symfony\Component\Lock\PersistingStoreInterface;
/** /**
* @author Jérémy Derussé <jeremy@derusse.com> * @author Jérémy Derussé <jeremy@derusse.com>
@ -22,7 +22,7 @@ use Symfony\Component\Lock\PersistStoreInterface;
abstract class AbstractStoreTest extends TestCase abstract class AbstractStoreTest extends TestCase
{ {
/** /**
* @return PersistStoreInterface * @return PersistingStoreInterface
*/ */
abstract protected function getStore(); abstract protected function getStore();

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\Lock\Tests\Store;
use Symfony\Component\Lock\Exception\LockConflictedException; use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Exception\NotSupportedException; use Symfony\Component\Lock\Exception\NotSupportedException;
use Symfony\Component\Lock\Key; use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\PersistStoreInterface; use Symfony\Component\Lock\PersistingStoreInterface;
/** /**
* @author Jérémy Derussé <jeremy@derusse.com> * @author Jérémy Derussé <jeremy@derusse.com>
@ -24,7 +24,7 @@ trait BlockingStoreTestTrait
/** /**
* @see AbstractStoreTest::getStore() * @see AbstractStoreTest::getStore()
* *
* @return PersistStoreInterface * @return PersistingStoreInterface
*/ */
abstract protected function getStore(); abstract protected function getStore();

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\Lock\Tests\Store;
use Symfony\Component\Lock\BlockingStoreInterface; use Symfony\Component\Lock\BlockingStoreInterface;
use Symfony\Component\Lock\Exception\LockConflictedException; use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Key; use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\PersistStoreInterface; use Symfony\Component\Lock\PersistingStoreInterface;
use Symfony\Component\Lock\Store\CombinedStore; use Symfony\Component\Lock\Store\CombinedStore;
use Symfony\Component\Lock\Store\RedisStore; use Symfony\Component\Lock\Store\RedisStore;
use Symfony\Component\Lock\Strategy\StrategyInterface; use Symfony\Component\Lock\Strategy\StrategyInterface;
@ -62,8 +62,8 @@ class CombinedStoreTest extends AbstractStoreTest
protected function setUp() protected function setUp()
{ {
$this->strategy = $this->getMockBuilder(StrategyInterface::class)->getMock(); $this->strategy = $this->getMockBuilder(StrategyInterface::class)->getMock();
$this->store1 = $this->getMockBuilder([PersistStoreInterface::class, BlockingStoreInterface::class])->getMock(); $this->store1 = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock();
$this->store2 = $this->getMockBuilder([PersistStoreInterface::class, BlockingStoreInterface::class])->getMock(); $this->store2 = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock();
$this->store = new CombinedStore([$this->store1, $this->store2], $this->strategy); $this->store = new CombinedStore([$this->store1, $this->store2], $this->strategy);
} }
@ -267,8 +267,8 @@ class CombinedStoreTest extends AbstractStoreTest
public function testPutOffExpirationIgnoreNonExpiringStorage() public function testPutOffExpirationIgnoreNonExpiringStorage()
{ {
$store1 = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store1 = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$store2 = $this->getMockBuilder(PersistStoreInterface::class)->getMock(); $store2 = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$store = new CombinedStore([$store1, $store2], $this->strategy); $store = new CombinedStore([$store1, $store2], $this->strategy);