[Lock] rename and deprecate Factory into LockFactory

This commit is contained in:
Amrouche Hamza 2019-07-09 07:37:24 +02:00
parent f1dff5e269
commit fc75eb9bef
No known key found for this signature in database
GPG Key ID: E45A3DA456145BC1
5 changed files with 64 additions and 4 deletions

View File

@ -12,8 +12,8 @@
namespace Symfony\Component\Console\Command;
use Symfony\Component\Console\Exception\LogicException;
use Symfony\Component\Lock\Factory;
use Symfony\Component\Lock\Lock;
use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\Store\FlockStore;
use Symfony\Component\Lock\Store\SemaphoreStore;
@ -48,7 +48,7 @@ trait LockableTrait
$store = new FlockStore();
}
$this->lock = (new Factory($store))->createLock($name ?: $this->getName());
$this->lock = (new LockFactory($store))->createLock($name ?: $this->getName());
if (!$this->lock->acquire($blocking)) {
$this->lock = null;

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\Console\Tests\Command;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Lock\Factory;
use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\Store\FlockStore;
use Symfony\Component\Lock\Store\SemaphoreStore;
@ -47,7 +47,7 @@ class LockableTraitTest extends TestCase
$store = new FlockStore();
}
$lock = (new Factory($store))->createLock($command->getName());
$lock = (new LockFactory($store))->createLock($command->getName());
$lock->acquire();
$tester = new CommandTester($command);

View File

@ -19,6 +19,8 @@ use Psr\Log\NullLogger;
* Factory provides method to create locks.
*
* @author Jérémy Derussé <jeremy@derusse.com>
*
* @deprecated "Symfony\Component\Lock\Factory" is deprecated since Symfony 4.4 and will be removed in 5.0 use "Symfony\Component\Lock\LockFactory" instead
*/
class Factory implements LoggerAwareInterface
{

View File

@ -0,0 +1,22 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Lock;
/**
* Factory provides method to create locks.
*
* @author Jérémy Derussé <jeremy@derusse.com>
* @author Hamza Amrouche <hamza.simperfit@gmail.com>
*/
class LockFactory extends Factory
{
}

View File

@ -0,0 +1,36 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Lock\Tests;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\LockInterface;
use Symfony\Component\Lock\StoreInterface;
/**
* @author Jérémy Derussé <jeremy@derusse.com>
*/
class LockFactoryTest extends TestCase
{
public function testCreateLock()
{
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
$factory = new LockFactory($store);
$factory->setLogger($logger);
$lock = $factory->createLock('foo');
$this->assertInstanceOf(LockInterface::class, $lock);
}
}