Skip to content

Commit fd3bc8c

Browse files
committed
Use more use statements rather than fully qualified names
1 parent 6d59f58 commit fd3bc8c

File tree

7 files changed

+62
-47
lines changed

7 files changed

+62
-47
lines changed

src/ExtraPackage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ protected function extractAliases(array $requires, array $aliases)
686686
'alias_normalized' => $this->versionParser->normalize($match[2], $reqVersion),
687687
);
688688
} elseif (strpos($reqVersion, ' as ') !== false) {
689-
throw new \UnexpectedValueException(
689+
throw new UnexpectedValueException(
690690
'Invalid alias definition in "'.$reqName.'": "'.$reqVersion.'". '
691691
. 'Aliases should be in the form "exact-version as other-exact-version".'
692692
);

src/MissingFileException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010

1111
namespace Wikimedia\Composer\Merge\V2;
1212

13+
use RuntimeException;
14+
1315
/**
1416
* @author Bryan Davis <[email protected]>
1517
*/
16-
class MissingFileException extends \RuntimeException
18+
class MissingFileException extends RuntimeException
1719
{
1820
}

src/MultiConstraint.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Composer\Semver\Constraint\ConstraintInterface;
1515
use Composer\Semver\Constraint\EmptyConstraint;
1616
use Composer\Semver\Constraint\MultiConstraint as SemverMultiConstraint;
17+
use function count;
1718

1819
/**
1920
* Adapted from Composer's v2 MultiConstraint::create for Composer v1
@@ -35,20 +36,20 @@ class MultiConstraint extends SemverMultiConstraint
3536
*/
3637
public static function create(array $constraints, $conjunctive = true)
3738
{
38-
if (\count($constraints) === 0) {
39+
if (count($constraints) === 0) {
3940
// EmptyConstraint only exists in composer 1.x. Configure as to run phan against composer 2.x
4041
// @phan-suppress-next-line PhanTypeMismatchReturn, PhanUndeclaredClassMethod
4142
return new EmptyConstraint();
4243
}
4344

44-
if (\count($constraints) === 1) {
45+
if (count($constraints) === 1) {
4546
return $constraints[0];
4647
}
4748

4849
$optimized = self::optimizeConstraints($constraints, $conjunctive);
4950
if ($optimized !== null) {
5051
list($constraints, $conjunctive) = $optimized;
51-
if (\count($constraints) === 1) {
52+
if (count($constraints) === 1) {
5253
return $constraints[0];
5354
}
5455
}
@@ -68,14 +69,14 @@ private static function optimizeConstraints(array $constraints, $conjunctive)
6869
$left = $constraints[0];
6970
$mergedConstraints = [];
7071
$optimized = false;
71-
for ($i = 1, $l = \count($constraints); $i < $l; $i++) {
72+
for ($i = 1, $l = count($constraints); $i < $l; $i++) {
7273
$right = $constraints[$i];
7374
if ($left instanceof SemverMultiConstraint
7475
&& $left->conjunctive
7576
&& $right instanceof SemverMultiConstraint
7677
&& $right->conjunctive
77-
&& \count($left->constraints) === 2
78-
&& \count($right->constraints) === 2
78+
&& count($left->constraints) === 2
79+
&& count($right->constraints) === 2
7980
&& ($left0 = (string) $left->constraints[0])
8081
&& $left0[0] === '>' && $left0[1] === '='
8182
&& ($left1 = (string) $left->constraints[1])

tests/phpunit/LoggerTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Wikimedia\Composer\Merge\V2;
1212

13+
use Composer\IO\IOInterface;
1314
use Prophecy\Argument;
1415
use PHPUnit\Framework\TestCase;
1516

@@ -22,7 +23,7 @@ class LoggerTest extends TestCase
2223
public function testVeryVerboseDebug()
2324
{
2425
$output = [];
25-
$io = $this->prophesize(\Composer\IO\IOInterface::class);
26+
$io = $this->prophesize(IOInterface::class);
2627
$io->isVeryVerbose()->willReturn(true)->shouldBeCalled();
2728
$io->writeError(Argument::type('string'))->will(
2829
function ($args) use (&$output) {
@@ -39,7 +40,7 @@ function ($args) use (&$output) {
3940

4041
public function testNotVeryVerboseDebug()
4142
{
42-
$io = $this->prophesize(\Composer\IO\IOInterface::class);
43+
$io = $this->prophesize(IOInterface::class);
4344
$io->isVeryVerbose()->willReturn(false)->shouldBeCalled();
4445
$io->writeError(Argument::type('string'))->shouldNotBeCalled();
4546
$io->write(Argument::type('string'))->shouldNotBeCalled();
@@ -51,7 +52,7 @@ public function testNotVeryVerboseDebug()
5152
public function testVerboseInfo()
5253
{
5354
$output = [];
54-
$io = $this->prophesize(\Composer\IO\IOInterface::class);
55+
$io = $this->prophesize(IOInterface::class);
5556
$io->isVerbose()->willReturn(true)->shouldBeCalled();
5657
$io->writeError(Argument::type('string'))->will(
5758
function ($args) use (&$output) {
@@ -68,7 +69,7 @@ function ($args) use (&$output) {
6869

6970
public function testNotVerboseInfo()
7071
{
71-
$io = $this->prophesize(\Composer\IO\IOInterface::class);
72+
$io = $this->prophesize(IOInterface::class);
7273
$io->isVerbose()->willReturn(false)->shouldBeCalled();
7374
$io->writeError(Argument::type('string'))->shouldNotBeCalled();
7475
$io->write(Argument::type('string'))->shouldNotBeCalled();
@@ -80,7 +81,7 @@ public function testNotVerboseInfo()
8081
public function testWarning()
8182
{
8283
$output = [];
83-
$io = $this->prophesize(\Composer\IO\IOInterface::class);
84+
$io = $this->prophesize(IOInterface::class);
8485
$io->writeError(Argument::type('string'))->will(
8586
function ($args) use (&$output) {
8687
$output[] = $args[0];

tests/phpunit/MergePluginTest.php

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,31 @@
1111
namespace Wikimedia\Composer\Merge\V2;
1212

1313
use Composer\Composer;
14+
use Composer\Config;
1415
use Composer\DependencyResolver\Operation\InstallOperation;
16+
use Composer\Installer\PackageEvent;
1517
use Composer\Installer\PackageEvents;
1618
use Composer\IO\IOInterface;
1719
use Composer\Package\BasePackage;
1820
use Composer\Package\Link;
21+
use Composer\Package\Locker;
1922
use Composer\Package\Package;
23+
use Composer\Package\RootAliasPackage;
2024
use Composer\Package\RootPackage;
25+
use Composer\Package\RootPackageInterface;
2126
use Composer\Package\Version\VersionParser;
2227
use Composer\Plugin\PluginEvents;
2328
use Composer\Plugin\PluginInterface;
29+
use Composer\Repository\PathRepository;
30+
use Composer\Repository\RepositoryManager;
31+
use Composer\Repository\VcsRepository;
2432
use Composer\Script\Event;
2533
use Composer\Script\ScriptEvents;
34+
use Composer\Util\HttpDownloader;
2635
use Prophecy\Argument;
2736
use PHPUnit\Framework\TestCase;
2837
use Prophecy\Prophecy\ObjectProphecy;
38+
use ReflectionClass;
2939
use ReflectionProperty;
3040

3141
/**
@@ -57,8 +67,8 @@ class MergePluginTest extends TestCase
5767
protected function setUp(): void
5868
{
5969
parent::setUp();
60-
$this->composer = $this->prophesize(\Composer\Composer::class);
61-
$this->io = $this->prophesize(\Composer\IO\IOInterface::class);
70+
$this->composer = $this->prophesize(Composer::class);
71+
$this->io = $this->prophesize(IOInterface::class);
6272

6373
$this->fixture = new MergePlugin();
6474
$this->fixture->activate(
@@ -370,7 +380,7 @@ public function testRecursivePathRepositoriesWithSubDirectory()
370380
$dir = $this->fixtureDir(__FUNCTION__);
371381

372382
$repoManager = $this->prophesize(
373-
\Composer\Repository\RepositoryManager::class
383+
RepositoryManager::class
374384
);
375385
$repoManager->createRepository(
376386
Argument::type('string'),
@@ -383,17 +393,17 @@ function ($args) use ($that, $io) {
383393
$args[1]['url']
384394
);
385395

386-
return new \Composer\Repository\PathRepository(
396+
return new PathRepository(
387397
$args[1],
388398
$io->reveal(),
389-
new \Composer\Config()
399+
new Config()
390400
);
391401
}
392402
);
393403
$repoManager->prependRepository(Argument::any())->will(
394404
function ($args) use ($that) {
395405
$that->assertInstanceOf(
396-
\Composer\Repository\PathRepository::class,
406+
PathRepository::class,
397407
$args[0]
398408
);
399409
}
@@ -569,7 +579,7 @@ public function testMergedRepositories()
569579
$dir = $this->fixtureDir(__FUNCTION__);
570580

571581
$repoManager = $this->prophesize(
572-
\Composer\Repository\RepositoryManager::class
582+
RepositoryManager::class
573583
);
574584
$repoManager->createRepository(
575585
Argument::type('string'),
@@ -582,20 +592,20 @@ function ($args) use ($that, $io) {
582592
$args[1]['url']
583593
);
584594

585-
$config = new \Composer\Config();
595+
$config = new Config();
586596
$mockIO = $io->reveal();
587597
if (version_compare('2.0.0', PluginInterface::PLUGIN_API_VERSION, '>')) {
588-
return new \Composer\Repository\VcsRepository(
598+
return new VcsRepository(
589599
$args[1],
590600
$mockIO,
591601
$config
592602
);
593603
} else {
594-
$httpDownloader = new \Composer\Util\HttpDownloader(
604+
$httpDownloader = new HttpDownloader(
595605
$mockIO,
596606
$config
597607
);
598-
return new \Composer\Repository\VcsRepository(
608+
return new VcsRepository(
599609
$args[1],
600610
$mockIO,
601611
$config,
@@ -607,7 +617,7 @@ function ($args) use ($that, $io) {
607617
$repoManager->prependRepository(Argument::any())->will(
608618
function ($args) use ($that) {
609619
$that->assertInstanceOf(
610-
\Composer\Repository\VcsRepository::class,
620+
VcsRepository::class,
611621
$args[0]
612622
);
613623
}
@@ -661,7 +671,7 @@ public function testPrependRepositories()
661671
$dir = $this->fixtureDir(__FUNCTION__);
662672

663673
$repoManager = $this->prophesize(
664-
\Composer\Repository\RepositoryManager::class
674+
RepositoryManager::class
665675
);
666676
$repoManager->createRepository(
667677
Argument::type('string'),
@@ -674,21 +684,21 @@ function ($args) use ($that, $io) {
674684
$args[1]['url']
675685
);
676686

677-
$config = new \Composer\Config();
687+
$config = new Config();
678688
$mockIO = $io->reveal();
679689
if (version_compare('2.0.0', PluginInterface::PLUGIN_API_VERSION, '>')) {
680-
return new \Composer\Repository\VcsRepository(
690+
return new VcsRepository(
681691
$args[1],
682692
$mockIO,
683693
$config
684694
);
685695
} else {
686-
$httpDownloader = new \Composer\Util\HttpDownloader(
696+
$httpDownloader = new HttpDownloader(
687697
$mockIO,
688698
$config
689699
);
690700

691-
return new \Composer\Repository\VcsRepository(
701+
return new VcsRepository(
692702
$args[1],
693703
$mockIO,
694704
$config,
@@ -700,7 +710,7 @@ function ($args) use ($that, $io) {
700710
$repoManager->prependRepository(Argument::any())->will(
701711
function ($args) use ($that) {
702712
$that->assertInstanceOf(
703-
\Composer\Repository\VcsRepository::class,
713+
VcsRepository::class,
704714
$args[0]
705715
);
706716
}
@@ -721,11 +731,11 @@ function ($args) use ($that) {
721731
$repos = $args[0];
722732
$that->assertCount(2, $repos);
723733
$prependedRepo = $repos[0];
724-
$that->assertInstanceOf(\Composer\Repository\VcsRepository::class, $prependedRepo);
734+
$that->assertInstanceOf(VcsRepository::class, $prependedRepo);
725735
// Ugly, be we need to check a protected member variable and
726736
// PHPUnit decided that having the assertAttributeEquals
727737
// assertion to make that easy was a code smell.
728-
$clazz = new \ReflectionClass($prependedRepo);
738+
$clazz = new ReflectionClass($prependedRepo);
729739
$url = $clazz->getProperty('url');
730740
$url->setAccessible(true);
731741
$that->assertEquals(
@@ -1191,11 +1201,11 @@ public function testOnPostPackageInstall($package, $first, $locked)
11911201
$operation = new InstallOperation(
11921202
new Package($package, '1.2.3.4', '1.2.3')
11931203
);
1194-
$event = $this->prophesize(\Composer\Installer\PackageEvent::class);
1204+
$event = $this->prophesize(PackageEvent::class);
11951205
$event->getOperation()->willReturn($operation)->shouldBeCalled();
11961206

11971207
if ($first) {
1198-
$locker = $this->prophesize(\Composer\Package\Locker::class);
1208+
$locker = $this->prophesize(Locker::class);
11991209
$locker->isLocked()->willReturn($locked)
12001210
->shouldBeCalled();
12011211
$this->composer->getLocker()->willReturn($locker->reveal())
@@ -1242,32 +1252,32 @@ public function testHasBranchAlias($fireInit)
12421252
// RootAliasPackage was updated in 06c44ce to include more setters
12431253
// that we take advantage of if available
12441254
$haveComposerWithCompleteRootAlias = method_exists(
1245-
\Composer\Package\RootPackageInterface::class,
1255+
RootPackageInterface::class,
12461256
'setRepositories'
12471257
);
12481258

12491259
$repoManager = $this->prophesize(
1250-
\Composer\Repository\RepositoryManager::class
1260+
RepositoryManager::class
12511261
);
12521262
$repoManager->createRepository(
12531263
Argument::type('string'),
12541264
Argument::type('array')
12551265
)->will(function ($args) use ($io) {
1256-
$config = new \Composer\Config();
1266+
$config = new Config();
12571267
$mockIO = $io->reveal();
12581268
if (version_compare('2.0.0', PluginInterface::PLUGIN_API_VERSION, '>')) {
1259-
return new \Composer\Repository\VcsRepository(
1269+
return new VcsRepository(
12601270
$args[1],
12611271
$mockIO,
12621272
$config
12631273
);
12641274
} else {
1265-
$httpDownloader = new \Composer\Util\HttpDownloader(
1275+
$httpDownloader = new HttpDownloader(
12661276
$mockIO,
12671277
$config
12681278
);
12691279

1270-
return new \Composer\Repository\VcsRepository(
1280+
return new VcsRepository(
12711281
$args[1],
12721282
$mockIO,
12731283
$config,
@@ -1724,7 +1734,7 @@ protected function rootFromJson($file)
17241734
}
17251735
}
17261736

1727-
$root = $this->prophesize(\Composer\Package\RootPackage::class);
1737+
$root = $this->prophesize(RootPackage::class);
17281738
$root->getVersion()->willReturn($vp->normalize($data['version']));
17291739
$root->getPrettyVersion()->willReturn($data['version']);
17301740
$root->getMinimumStability()->willReturn($data['minimum-stability']);
@@ -1762,7 +1772,7 @@ function ($args) use ($that) {
17621772
*/
17631773
protected function makeAliasFor($root)
17641774
{
1765-
$alias = $this->prophesize(\Composer\Package\RootAliasPackage::class);
1775+
$alias = $this->prophesize(RootAliasPackage::class);
17661776
$alias->getAliasOf()->willReturn($root);
17671777
$alias->getVersion()->will(function () use ($root) {
17681778
return $root->getVersion();

tests/phpunit/PluginStateTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class PluginStateTest extends TestCase
2121

2222
public function testLocked()
2323
{
24-
$composer = $this->prophesize(\Composer\Composer::class)->reveal();
24+
$composer = $this->prophesize(Composer::class)->reveal();
2525
$fixture = new PluginState($composer);
2626

2727
$this->assertFalse($fixture->isLocked());
@@ -34,7 +34,7 @@ public function testLocked()
3434

3535
public function testDumpAutoloader()
3636
{
37-
$composer = $this->prophesize(\Composer\Composer::class)->reveal();
37+
$composer = $this->prophesize(Composer::class)->reveal();
3838
$fixture = new PluginState($composer);
3939

4040
$this->assertFalse($fixture->shouldDumpAutoloader());
@@ -45,7 +45,7 @@ public function testDumpAutoloader()
4545

4646
public function testOptimizeAutoloader()
4747
{
48-
$composer = $this->prophesize(\Composer\Composer::class)->reveal();
48+
$composer = $this->prophesize(Composer::class)->reveal();
4949
$fixture = new PluginState($composer);
5050

5151
$this->assertFalse($fixture->shouldOptimizeAutoloader());

0 commit comments

Comments
 (0)