From fc75eb9bef8375fd0825f229046d987636d1aa07 Mon Sep 17 00:00:00 2001 From: Amrouche Hamza Date: Tue, 9 Jul 2019 07:37:24 +0200 Subject: [PATCH] [Lock] rename and deprecate Factory into LockFactory --- .../Console/Command/LockableTrait.php | 4 +-- .../Tests/Command/LockableTraitTest.php | 4 +-- src/Symfony/Component/Lock/Factory.php | 2 ++ src/Symfony/Component/Lock/LockFactory.php | 22 ++++++++++++ .../Component/Lock/Tests/LockFactoryTest.php | 36 +++++++++++++++++++ 5 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 src/Symfony/Component/Lock/LockFactory.php create mode 100644 src/Symfony/Component/Lock/Tests/LockFactoryTest.php diff --git a/src/Symfony/Component/Console/Command/LockableTrait.php b/src/Symfony/Component/Console/Command/LockableTrait.php index f4ebe45bf37c7..f3bc9959452ae 100644 --- a/src/Symfony/Component/Console/Command/LockableTrait.php +++ b/src/Symfony/Component/Console/Command/LockableTrait.php @@ -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 @@ private function lock($name = null, $blocking = false) $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; diff --git a/src/Symfony/Component/Console/Tests/Command/LockableTraitTest.php b/src/Symfony/Component/Console/Tests/Command/LockableTraitTest.php index 94b0819bbf420..76dc0443ec8f0 100644 --- a/src/Symfony/Component/Console/Tests/Command/LockableTraitTest.php +++ b/src/Symfony/Component/Console/Tests/Command/LockableTraitTest.php @@ -13,7 +13,7 @@ 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 @@ public function testLockReturnsFalseIfAlreadyLockedByAnotherCommand() $store = new FlockStore(); } - $lock = (new Factory($store))->createLock($command->getName()); + $lock = (new LockFactory($store))->createLock($command->getName()); $lock->acquire(); $tester = new CommandTester($command); diff --git a/src/Symfony/Component/Lock/Factory.php b/src/Symfony/Component/Lock/Factory.php index f35ad6d8ef2e0..2bc7d9304bd7f 100644 --- a/src/Symfony/Component/Lock/Factory.php +++ b/src/Symfony/Component/Lock/Factory.php @@ -19,6 +19,8 @@ * Factory provides method to create locks. * * @author Jérémy Derussé + * + * @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 { diff --git a/src/Symfony/Component/Lock/LockFactory.php b/src/Symfony/Component/Lock/LockFactory.php new file mode 100644 index 0000000000000..f054b532b5504 --- /dev/null +++ b/src/Symfony/Component/Lock/LockFactory.php @@ -0,0 +1,22 @@ + + * + * 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é + * @author Hamza Amrouche + */ +class LockFactory extends Factory +{ +} diff --git a/src/Symfony/Component/Lock/Tests/LockFactoryTest.php b/src/Symfony/Component/Lock/Tests/LockFactoryTest.php new file mode 100644 index 0000000000000..0ec4fd3976a4f --- /dev/null +++ b/src/Symfony/Component/Lock/Tests/LockFactoryTest.php @@ -0,0 +1,36 @@ + + * + * 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é + */ +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); + } +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy