Skip to content

Commit 7335e77

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

File tree

5 files changed

+65
-2
lines changed

5 files changed

+65
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Console\Exception\LogicException;
1515
use Symfony\Component\Lock\Factory;
1616
use Symfony\Component\Lock\Lock;
17+
use Symfony\Component\Lock\LockFactory;
1718
use Symfony\Component\Lock\Store\FlockStore;
1819
use Symfony\Component\Lock\Store\SemaphoreStore;
1920

@@ -48,7 +49,7 @@ private function lock($name = null, $blocking = false)
4849
$store = new FlockStore();
4950
}
5051

51-
$this->lock = (new Factory($store))->createLock($name ?: $this->getName());
52+
$this->lock = (new LockFactory($store))->createLock($name ?: $this->getName());
5253
if (!$this->lock->acquire($blocking)) {
5354
$this->lock = null;
5455

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Console\Tester\CommandTester;
1616
use Symfony\Component\Lock\Factory;
17+
use Symfony\Component\Lock\Lock;
18+
use Symfony\Component\Lock\LockFactory;
1719
use Symfony\Component\Lock\Store\FlockStore;
1820
use Symfony\Component\Lock\Store\SemaphoreStore;
1921

@@ -47,7 +49,7 @@ public function testLockReturnsFalseIfAlreadyLockedByAnotherCommand()
4749
$store = new FlockStore();
4850
}
4951

50-
$lock = (new Factory($store))->createLock($command->getName());
52+
$lock = (new LockFactory($store))->createLock($command->getName());
5153
$lock->acquire();
5254

5355
$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)
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