|
|
@ -43,10 +43,9 @@ class ComposerRepository extends ArrayRepository
|
|
|
|
protected $searchUrl;
|
|
|
|
protected $searchUrl;
|
|
|
|
protected $hasProviders = false;
|
|
|
|
protected $hasProviders = false;
|
|
|
|
protected $providersUrl;
|
|
|
|
protected $providersUrl;
|
|
|
|
|
|
|
|
protected $loadedMap = array();
|
|
|
|
protected $lazyProvidersUrl;
|
|
|
|
protected $lazyProvidersUrl;
|
|
|
|
protected $providerListing;
|
|
|
|
protected $providerListing;
|
|
|
|
protected $providers = array();
|
|
|
|
|
|
|
|
protected $providersByUid = array();
|
|
|
|
|
|
|
|
protected $loader;
|
|
|
|
protected $loader;
|
|
|
|
protected $rootAliases;
|
|
|
|
protected $rootAliases;
|
|
|
|
protected $allowSslDowngrade = false;
|
|
|
|
protected $allowSslDowngrade = false;
|
|
|
@ -96,6 +95,51 @@ class ComposerRepository extends ArrayRepository
|
|
|
|
$this->rootAliases = $rootAliases;
|
|
|
|
$this->rootAliases = $rootAliases;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getRootAliases()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return $this->rootAliases;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Load all packages with given names and dependencies
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param array $packageNames
|
|
|
|
|
|
|
|
* @param callable|null $acceptableCallback Callback to filter packages
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return array The loaded package objects
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function loadRecursively(array $packageNames, $acceptableCallback)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$workQueue = new \SplQueue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($packageNames as $packageName) {
|
|
|
|
|
|
|
|
$workQueue->enqueue($packageName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$loadedPackages = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (!$workQueue->isEmpty()) {
|
|
|
|
|
|
|
|
$packageName = $workQueue->dequeue();
|
|
|
|
|
|
|
|
if (isset($this->loadedMap[$packageName])) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->loadedMap[$packageName] = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$packages = $this->loadName($packageName, $acceptableCallback);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($packages as $package) {
|
|
|
|
|
|
|
|
$loadedPackages[] = $package;
|
|
|
|
|
|
|
|
$requires = $package->getRequires();
|
|
|
|
|
|
|
|
foreach ($requires as $link) {
|
|
|
|
|
|
|
|
$workQueue->enqueue($link->getTarget());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $loadedPackages;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -111,7 +155,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;
|
|
|
@ -142,7 +186,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;
|
|
|
@ -240,22 +284,17 @@ class ComposerRepository extends ArrayRepository
|
|
|
|
return $this->hasProviders;
|
|
|
|
return $this->hasProviders;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function resetPackageIds()
|
|
|
|
/**
|
|
|
|
{
|
|
|
|
* Loads package data for a given package name or provider name
|
|
|
|
foreach ($this->providersByUid as $package) {
|
|
|
|
*
|
|
|
|
if ($package instanceof AliasPackage) {
|
|
|
|
* @param string $name
|
|
|
|
$package->getAliasOf()->setId(-1);
|
|
|
|
* @param callable|null $acceptableCallback A callback to check if a package should be loaded
|
|
|
|
}
|
|
|
|
* @param bool $exactMatch Whether packages only providing the name should be ignored
|
|
|
|
$package->setId(-1);
|
|
|
|
*
|
|
|
|
}
|
|
|
|
* @return array All packages that were loaded
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected function loadName($name, $acceptableCallback, $exactMatch = true)
|
|
|
|
public function whatProvides(Pool $pool, $name)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (isset($this->providers[$name])) {
|
|
|
|
|
|
|
|
return $this->providers[$name];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
return array();
|
|
|
|
return array();
|
|
|
@ -296,69 +335,32 @@ class ComposerRepository extends ArrayRepository
|
|
|
|
$packages = $this->fetchFile($url, $cacheKey, $hash);
|
|
|
|
$packages = $this->fetchFile($url, $cacheKey, $hash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$this->providers[$name] = array();
|
|
|
|
$loadedPackages = array();
|
|
|
|
foreach ($packages['packages'] as $versions) {
|
|
|
|
foreach ($packages['packages'] as $packageName => $versions) {
|
|
|
|
foreach ($versions as $version) {
|
|
|
|
if ($exactMatch && $packageName !== $name) {
|
|
|
|
// avoid loading the same objects twice
|
|
|
|
continue;
|
|
|
|
if (isset($this->providersByUid[$version['uid']])) {
|
|
|
|
}
|
|
|
|
// skip if already assigned
|
|
|
|
|
|
|
|
if (!isset($this->providers[$name][$version['uid']])) {
|
|
|
|
|
|
|
|
// expand alias in two packages
|
|
|
|
|
|
|
|
if ($this->providersByUid[$version['uid']] instanceof AliasPackage) {
|
|
|
|
|
|
|
|
$this->providers[$name][$version['uid']] = $this->providersByUid[$version['uid']]->getAliasOf();
|
|
|
|
|
|
|
|
$this->providers[$name][$version['uid'].'-alias'] = $this->providersByUid[$version['uid']];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$this->providers[$name][$version['uid']] = $this->providersByUid[$version['uid']];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// check for root aliases
|
|
|
|
|
|
|
|
if (isset($this->providersByUid[$version['uid'].'-root'])) {
|
|
|
|
|
|
|
|
$this->providers[$name][$version['uid'].'-root'] = $this->providersByUid[$version['uid'].'-root'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (!$pool->isPackageAcceptable(strtolower($version['name']), VersionParser::parseStability($version['version']))) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// load acceptable packages in the providers
|
|
|
|
|
|
|
|
$package = $this->createPackage($version, 'Composer\Package\Package');
|
|
|
|
|
|
|
|
$package->setRepository($this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($package instanceof AliasPackage) {
|
|
|
|
|
|
|
|
$aliased = $package->getAliasOf();
|
|
|
|
|
|
|
|
$aliased->setRepository($this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->providers[$name][$version['uid']] = $aliased;
|
|
|
|
|
|
|
|
$this->providers[$name][$version['uid'].'-alias'] = $package;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// override provider with its alias so it can be expanded in the if block above
|
|
|
|
|
|
|
|
$this->providersByUid[$version['uid']] = $package;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$this->providers[$name][$version['uid']] = $package;
|
|
|
|
|
|
|
|
$this->providersByUid[$version['uid']] = $package;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// handle root package aliases
|
|
|
|
foreach ($versions as $version) {
|
|
|
|
unset($rootAliasData);
|
|
|
|
if ($acceptableCallback && !call_user_func(
|
|
|
|
|
|
|
|
$acceptableCallback, strtolower($version['name']), VersionParser::parseStability($version['version'])
|
|
|
|
|
|
|
|
)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($this->rootAliases[$package->getName()][$package->getVersion()])) {
|
|
|
|
// load acceptable packages in the providers
|
|
|
|
$rootAliasData = $this->rootAliases[$package->getName()][$package->getVersion()];
|
|
|
|
$package = $this->createPackage($version, 'Composer\Package\Package');
|
|
|
|
} elseif ($package instanceof AliasPackage && isset($this->rootAliases[$package->getName()][$package->getAliasOf()->getVersion()])) {
|
|
|
|
$this->addPackage($package);
|
|
|
|
$rootAliasData = $this->rootAliases[$package->getName()][$package->getAliasOf()->getVersion()];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($rootAliasData)) {
|
|
|
|
$loadedPackages[] = $package;
|
|
|
|
$alias = $this->createAliasPackage($package, $rootAliasData['alias_normalized'], $rootAliasData['alias']);
|
|
|
|
|
|
|
|
$alias->setRepository($this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->providers[$name][$version['uid'].'-root'] = $alias;
|
|
|
|
if ($package instanceof AliasPackage) {
|
|
|
|
$this->providersByUid[$version['uid'].'-root'] = $alias;
|
|
|
|
$loadedPackages[] = $package->getAliasOf();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $this->providers[$name];
|
|
|
|
return $loadedPackages;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|