From 62fda2ed85a41cd79de97a5fb1f967ad7b8aaf9f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 13 Apr 2020 12:10:31 +0200 Subject: [PATCH] Reorg ComposerRepository to fix tests --- src/Composer/Repository/ComposerRepository.php | 8 ++++---- tests/Composer/Test/Repository/ComposerRepositoryTest.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index d0880a961..6dbe1cf38 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -498,7 +498,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito * @param string $name package name * @return array|mixed */ - private function whatProvides($name, array $acceptableStabilities = array(), array $stabilityFlags = array()) + private function whatProvides($name, array $acceptableStabilities = null, array $stabilityFlags = null) { if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) { // skip platform packages, root package and composer-plugin-api @@ -590,7 +590,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito $version['version_normalized'] = $this->versionParser->normalize($version['version']); } - if ($this->isVersionAcceptable($acceptableStabilities, $stabilityFlags, null, $normalizedName, $version)) { + if ($this->isVersionAcceptable(null, $normalizedName, $version, $acceptableStabilities, $stabilityFlags)) { $versionsToLoad[$version['uid']] = $version; } } @@ -711,7 +711,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito $version['version_normalized'] = $repo->versionParser->normalize($version['version']); } - if ($repo->isVersionAcceptable($acceptableStabilities, $stabilityFlags, $constraint, $realName, $version)) { + if ($repo->isVersionAcceptable($constraint, $realName, $version, $acceptableStabilities, $stabilityFlags)) { $versionsToLoad[] = $version; } } @@ -741,7 +741,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito * @param string $name package name (must be lowercased already) * @private */ - public function isVersionAcceptable(array $acceptableStabilities, array $stabilityFlags, $constraint, $name, $versionData) + public function isVersionAcceptable($constraint, $name, $versionData, array $acceptableStabilities = null, array $stabilityFlags = null) { $versions = array($versionData['version_normalized']); diff --git a/tests/Composer/Test/Repository/ComposerRepositoryTest.php b/tests/Composer/Test/Repository/ComposerRepositoryTest.php index 1915389c4..4fcbbb431 100644 --- a/tests/Composer/Test/Repository/ComposerRepositoryTest.php +++ b/tests/Composer/Test/Repository/ComposerRepositoryTest.php @@ -154,7 +154,7 @@ class ComposerRepositoryTest extends TestCase $versionParser = new VersionParser(); $reflMethod = new \ReflectionMethod($repo, 'whatProvides'); $reflMethod->setAccessible(true); - $packages = $reflMethod->invoke($repo, 'a', array($this, 'isPackageAcceptableReturnTrue')); + $packages = $reflMethod->invoke($repo, 'a'); $this->assertCount(5, $packages); $this->assertEquals(array('1', '1-alias', '2', '2-alias', '3'), array_keys($packages));