Skip to content

Commit 4078686

Browse files
committed
feature #32446 [Lock] rename and deprecate Factory into LockFactory (Simperfit)
This PR was merged into the 4.4 branch. Discussion ---------- [Lock] rename and deprecate Factory into LockFactory | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | yes<!-- 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 <!-- 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. --> As highlighted in #32198 (review) we need to rename the factory to LockFactory for consistency and readability. Commits ------- fc75eb9 [Lock] rename and deprecate Factory into LockFactory
2 parents de710f6 + fc75eb9 commit 4078686

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