Skip to content

Commit fc75eb9

Browse files
committed
[Lock] rename and deprecate Factory into LockFactory
1 parent f1dff5e commit fc75eb9

File tree

5 files changed

+64
-4
lines changed

5 files changed

+64
-4
lines changed

src/Symfony/Component/Console/Command/LockableTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
namespace Symfony\Component\Console\Command;
1313

1414
use Symfony\Component\Console\Exception\LogicException;
15-
use Symfony\Component\Lock\Factory;
1615
use Symfony\Component\Lock\Lock;
16+
use Symfony\Component\Lock\LockFactory;
1717
use Symfony\Component\Lock\Store\FlockStore;
1818
use Symfony\Component\Lock\Store\SemaphoreStore;
1919

@@ -48,7 +48,7 @@ private function lock($name = null, $blocking = false)
4848
$store = new FlockStore();
4949
}
5050

51-
$this->lock = (new Factory($store))->createLock($name ?: $this->getName());
51+
$this->lock = (new LockFactory($store))->createLock($name ?: $this->getName());
5252
if (!$this->lock->acquire($blocking)) {
5353
$this->lock = null;
5454

src/Symfony/Component/Console/Tests/Command/LockableTraitTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Console\Tester\CommandTester;
16-
use Symfony\Component\Lock\Factory;
16+
use Symfony\Component\Lock\LockFactory;
1717
use Symfony\Component\Lock\Store\FlockStore;
1818
use Symfony\Component\Lock\Store\SemaphoreStore;
1919

@@ -47,7 +47,7 @@ public function testLockReturnsFalseIfAlreadyLockedByAnotherCommand()
4747
$store = new FlockStore();
4848
}
4949

50-
$lock = (new Factory($store))->createLock($command->getName());
50+
$lock = (new LockFactory($store))->createLock($command->getName());
5151
$lock->acquire();
5252

5353
$tester = new CommandTester($command);

src/Symfony/Component/Lock/Factory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* Factory provides method to create locks.
2020
*
2121
* @author Jérémy Derussé <jeremy@derusse.com>
22+
*
23+
* @deprecated "Symfony\Component\Lock\Factory" is deprecated since Symfony 4.4 and will be removed in 5.0 use "Symfony\Component\Lock\LockFactory" instead
2224
*/
2325
class Factory implements LoggerAwareInterface
2426
{
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Lock;
13+
14+
/**
15+
* Factory provides method to create locks.
16+
*
17+
* @author Jérémy Derussé <jeremy@derusse.com>
18+
* @author Hamza Amrouche <hamza.simperfit@gmail.com>
19+
*/
20+
class LockFactory extends Factory
21+
{
22+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Lock\Tests;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Psr\Log\LoggerInterface;
16+
use Symfony\Component\Lock\LockFactory;
17+
use Symfony\Component\Lock\LockInterface;
18+
use Symfony\Component\Lock\StoreInterface;
19+
20+
/**
21+
* @author Jérémy Derussé <jeremy@derusse.com>
22+
*/
23+
class LockFactoryTest extends TestCase
24+
{
25+
public function testCreateLock()
26+
{
27+
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
28+
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
29+
$factory = new LockFactory($store);
30+
$factory->setLogger($logger);
31+
32+
$lock = $factory->createLock('foo');
33+
34+
$this->assertInstanceOf(LockInterface::class, $lock);
35+
}
36+
}

0 commit comments

Comments
 (0)