1
0
Fork 0

Entirely remove whatProvides from Composer repository

pull/3994/head
Nils Adermann 2015-05-05 19:28:15 +02:00
parent 090711b21c
commit b99c03ea04
2 changed files with 9 additions and 31 deletions

View File

@ -99,7 +99,6 @@ class Pool
if ($repo instanceof ComposerRepository && $repo->hasProviders()) { if ($repo instanceof ComposerRepository && $repo->hasProviders()) {
$this->providerRepos[] = $repo; $this->providerRepos[] = $repo;
$repo->setRootAliases($rootAliases); $repo->setRootAliases($rootAliases);
$repo->resetPackageIds();
} else { } else {
foreach ($repo->getPackages() as $package) { foreach ($repo->getPackages() as $package) {
$this->loadPackage($package, $rootAliases, $exempt); $this->loadPackage($package, $rootAliases, $exempt);
@ -222,26 +221,13 @@ class Pool
private function computeWhatProvides($name, $constraint, $mustMatchName = false) private function computeWhatProvides($name, $constraint, $mustMatchName = false)
{ {
$candidates = array(); $candidates = array();
/*
foreach ($this->providerRepos as $repo) {
foreach ($repo->whatProvides($this, $name) as $candidate) {
$candidates[] = $candidate;
if ($candidate->id < 1) {
$candidate->setId($this->id++);
$this->packages[$this->id - 2] = $candidate;
}
}
}*/
if ($mustMatchName) { if ($mustMatchName) {
$candidates = array_filter($candidates, function ($candidate) use ($name) {
return $candidate->getName() == $name;
});
if (isset($this->packageByExactName[$name])) { if (isset($this->packageByExactName[$name])) {
$candidates = array_merge($candidates, $this->packageByExactName[$name]); $candidates = $this->packageByExactName[$name];
} }
} elseif (isset($this->packageByName[$name])) { } elseif (isset($this->packageByName[$name])) {
$candidates = array_merge($candidates, $this->packageByName[$name]); $candidates = $this->packageByName[$name];
} }
$matches = $provideMatches = array(); $matches = $provideMatches = array();

View File

@ -135,7 +135,7 @@ class ComposerRepository extends ArrayRepository
return $loadedPackages; return $loadedPackages;
} }
protected function loadName($name, $acceptableCallback) protected function loadName($name, $acceptableCallback, $exactMatch = true)
{ {
// skip platform packages // skip platform packages
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name) || '__root__' === $name) { if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name) || '__root__' === $name) {
@ -180,25 +180,22 @@ class ComposerRepository extends ArrayRepository
$loadedPackages = array(); $loadedPackages = array();
foreach ($packages['packages'] as $versions) { foreach ($packages['packages'] as $versions) {
foreach ($versions as $version) { foreach ($versions as $version) {
if ($version['name'] !== $name) { if ($exactMatch && $version['name'] !== $name) {
continue; continue;
} }
if (!$acceptableCallback(strtolower($version['name']), VersionParser::parseStability($version['version']))) { if ($acceptableCallback && !$acceptableCallback(strtolower($version['name']), VersionParser::parseStability($version['version']))) {
continue; continue;
} }
// load acceptable packages in the providers // load acceptable packages in the providers
$package = $this->createPackage($version, 'Composer\Package\Package'); $package = $this->createPackage($version, 'Composer\Package\Package');
$package->setRepository($this); $this->addPackage($package);
$loadedPackages[] = $package; $loadedPackages[] = $package;
if ($package instanceof AliasPackage) { if ($package instanceof AliasPackage) {
$aliased = $package->getAliasOf(); $loadedPackages[] = $package->getAliasOf();
$aliased->setRepository($this);
$loadedPackages[] = $aliased;
} }
} }
} }
@ -221,7 +218,7 @@ class ComposerRepository extends ArrayRepository
foreach ($this->getProviderNames() as $providerName) { foreach ($this->getProviderNames() as $providerName) {
if ($name === $providerName) { if ($name === $providerName) {
$packages = $this->whatProvides(new Pool('dev'), $providerName); $packages = $this->loadName($providerName, null, false);
foreach ($packages as $package) { foreach ($packages as $package) {
if ($name == $package->getName() && $version === $package->getVersion()) { if ($name == $package->getName() && $version === $package->getVersion()) {
return $package; return $package;
@ -252,7 +249,7 @@ class ComposerRepository extends ArrayRepository
foreach ($this->getProviderNames() as $providerName) { foreach ($this->getProviderNames() as $providerName) {
if ($name === $providerName) { if ($name === $providerName) {
$packages = $this->whatProvides(new Pool('dev'), $providerName); $packages = $this->loadName($providerName, null, false);
foreach ($packages as $package) { foreach ($packages as $package) {
if ($name == $package->getName() && (null === $version || $version === $package->getVersion())) { if ($name == $package->getName() && (null === $version || $version === $package->getVersion())) {
$packages[] = $package; $packages[] = $package;
@ -350,11 +347,6 @@ class ComposerRepository extends ArrayRepository
return $this->hasProviders; return $this->hasProviders;
} }
public function whatProvides(Pool $pool, $name)
{
throw new \RuntimeException("Runtime repository provider calculation no longer occurs");
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */