This entirely removes StreamableRepositories and minimal package arrays
parent
5edc0925cf
commit
89bd9be295
|
@ -22,7 +22,6 @@ use Composer\Repository\RepositoryInterface;
|
|||
use Composer\Repository\CompositeRepository;
|
||||
use Composer\Repository\ComposerRepository;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
use Composer\Repository\StreamableRepositoryInterface;
|
||||
use Composer\Repository\PlatformRepository;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
||||
|
@ -97,79 +96,6 @@ class Pool
|
|||
$this->providerRepos[] = $repo;
|
||||
$repo->setRootAliases($rootAliases);
|
||||
$repo->resetPackageIds();
|
||||
} elseif ($repo instanceof StreamableRepositoryInterface) {
|
||||
foreach ($repo->getMinimalPackages() as $package) {
|
||||
$name = $package['name'];
|
||||
$version = $package['version'];
|
||||
$stability = VersionParser::parseStability($version);
|
||||
|
||||
// collect names
|
||||
$names = array(
|
||||
$name => true,
|
||||
);
|
||||
if (isset($package['provide'])) {
|
||||
foreach ($package['provide'] as $target => $constraint) {
|
||||
$names[$target] = true;
|
||||
}
|
||||
}
|
||||
if (isset($package['replace'])) {
|
||||
foreach ($package['replace'] as $target => $constraint) {
|
||||
$names[$target] = true;
|
||||
}
|
||||
}
|
||||
$names = array_keys($names);
|
||||
|
||||
if ($exempt || $this->isPackageAcceptable($names, $stability)) {
|
||||
$package['id'] = $this->id++;
|
||||
$package['stability'] = $stability;
|
||||
$this->packages[] = $package;
|
||||
$this->packageByExactName[$name][$package['id']] = $this->packages[$this->id - 2];
|
||||
|
||||
foreach ($names as $provided) {
|
||||
$this->packageByName[$provided][$package['id']] = $this->packages[$this->id - 2];
|
||||
}
|
||||
|
||||
// handle root package aliases
|
||||
unset($rootAliasData);
|
||||
if (isset($rootAliases[$name][$version])) {
|
||||
$rootAliasData = $rootAliases[$name][$version];
|
||||
} elseif (isset($package['alias_normalized']) && isset($rootAliases[$name][$package['alias_normalized']])) {
|
||||
$rootAliasData = $rootAliases[$name][$package['alias_normalized']];
|
||||
}
|
||||
|
||||
if (isset($rootAliasData)) {
|
||||
$alias = $package;
|
||||
unset($alias['raw']);
|
||||
$alias['version'] = $rootAliasData['alias_normalized'];
|
||||
$alias['alias'] = $rootAliasData['alias'];
|
||||
$alias['alias_of'] = $package['id'];
|
||||
$alias['id'] = $this->id++;
|
||||
$alias['root_alias'] = true;
|
||||
$this->packages[] = $alias;
|
||||
$this->packageByExactName[$name][$alias['id']] = $this->packages[$this->id - 2];
|
||||
|
||||
foreach ($names as $provided) {
|
||||
$this->packageByName[$provided][$alias['id']] = $this->packages[$this->id - 2];
|
||||
}
|
||||
}
|
||||
|
||||
// handle normal package aliases
|
||||
if (isset($package['alias'])) {
|
||||
$alias = $package;
|
||||
unset($alias['raw']);
|
||||
$alias['version'] = $package['alias_normalized'];
|
||||
$alias['alias'] = $package['alias'];
|
||||
$alias['alias_of'] = $package['id'];
|
||||
$alias['id'] = $this->id++;
|
||||
$this->packages[] = $alias;
|
||||
$this->packageByExactName[$name][$alias['id']] = $this->packages[$this->id - 2];
|
||||
|
||||
foreach ($names as $provided) {
|
||||
$this->packageByName[$provided][$alias['id']] = $this->packages[$this->id - 2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($repo->getPackages() as $package) {
|
||||
$names = $package->getNames();
|
||||
|
@ -227,7 +153,7 @@ class Pool
|
|||
*/
|
||||
public function packageById($id)
|
||||
{
|
||||
return $this->ensurePackageIsLoaded($this->packages[$id - 1]);
|
||||
return $this->packages[$id - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -307,15 +233,15 @@ class Pool
|
|||
|
||||
case self::MATCH:
|
||||
$nameMatch = true;
|
||||
$matches[] = $this->ensurePackageIsLoaded($candidate);
|
||||
$matches[] = $candidate;
|
||||
break;
|
||||
|
||||
case self::MATCH_PROVIDE:
|
||||
$provideMatches[] = $this->ensurePackageIsLoaded($candidate);
|
||||
$provideMatches[] = $candidate;
|
||||
break;
|
||||
|
||||
case self::MATCH_REPLACE:
|
||||
$matches[] = $this->ensurePackageIsLoaded($candidate);
|
||||
$matches[] = $candidate;
|
||||
break;
|
||||
|
||||
case self::MATCH_FILTERED:
|
||||
|
@ -376,28 +302,6 @@ class Pool
|
|||
return false;
|
||||
}
|
||||
|
||||
private function ensurePackageIsLoaded($data)
|
||||
{
|
||||
if (is_array($data)) {
|
||||
if (isset($data['alias_of'])) {
|
||||
$aliasOf = $this->packageById($data['alias_of']);
|
||||
$package = $this->packages[$data['id'] - 1] = $data['repo']->loadAliasPackage($data, $aliasOf);
|
||||
$package->setRootPackageAlias(!empty($data['root_alias']));
|
||||
} else {
|
||||
$package = $this->packages[$data['id'] - 1] = $data['repo']->loadPackage($data);
|
||||
}
|
||||
|
||||
foreach ($package->getNames() as $name) {
|
||||
$this->packageByName[$name][$data['id']] = $package;
|
||||
}
|
||||
$package->setId($data['id']);
|
||||
|
||||
return $package;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the package matches the given constraint directly or through
|
||||
* provided or replaced packages
|
||||
|
|
|
@ -30,7 +30,7 @@ use Composer\EventDispatcher\EventDispatcher;
|
|||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class ComposerRepository extends ArrayRepository implements StreamableRepositoryInterface
|
||||
class ComposerRepository extends ArrayRepository
|
||||
{
|
||||
protected $config;
|
||||
protected $options;
|
||||
|
@ -165,49 +165,6 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
|
|||
return parent::getPackages();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMinimalPackages()
|
||||
{
|
||||
if (isset($this->minimalPackages)) {
|
||||
return $this->minimalPackages;
|
||||
}
|
||||
|
||||
if (null === $this->rawData) {
|
||||
$this->rawData = $this->loadDataFromServer();
|
||||
}
|
||||
|
||||
$this->minimalPackages = array();
|
||||
$versionParser = new VersionParser;
|
||||
|
||||
foreach ($this->rawData as $package) {
|
||||
$version = !empty($package['version_normalized']) ? $package['version_normalized'] : $versionParser->normalize($package['version']);
|
||||
$data = array(
|
||||
'name' => strtolower($package['name']),
|
||||
'repo' => $this,
|
||||
'version' => $version,
|
||||
'raw' => $package,
|
||||
);
|
||||
if (!empty($package['replace'])) {
|
||||
$data['replace'] = $package['replace'];
|
||||
}
|
||||
if (!empty($package['provide'])) {
|
||||
$data['provide'] = $package['provide'];
|
||||
}
|
||||
|
||||
// add branch aliases
|
||||
if ($aliasNormalized = $this->loader->getBranchAlias($package)) {
|
||||
$data['alias'] = preg_replace('{(\.9{7})+}', '.x', $aliasNormalized);
|
||||
$data['alias_normalized'] = $aliasNormalized;
|
||||
}
|
||||
|
||||
$this->minimalPackages[] = $data;
|
||||
}
|
||||
|
||||
return $this->minimalPackages;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -262,20 +219,6 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
|
|||
return $providers;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function loadPackage(array $data)
|
||||
{
|
||||
$package = $this->createPackage($data['raw'], 'Composer\Package\Package');
|
||||
if ($package instanceof AliasPackage) {
|
||||
$package = $package->getAliasOf();
|
||||
}
|
||||
$package->setRepository($this);
|
||||
|
||||
return $package;
|
||||
}
|
||||
|
||||
protected function configurePackageTransportOptions(PackageInterface $package)
|
||||
{
|
||||
foreach ($package->getDistUrls() as $url) {
|
||||
|
@ -287,17 +230,6 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function loadAliasPackage(array $data, PackageInterface $aliasOf)
|
||||
{
|
||||
$aliasPackage = $this->createAliasPackage($aliasOf, $data['version'], $data['alias']);
|
||||
$aliasPackage->setRepository($this);
|
||||
|
||||
return $aliasPackage;
|
||||
}
|
||||
|
||||
public function hasProviders()
|
||||
{
|
||||
$this->loadRootServerFile();
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Repository;
|
||||
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
interface StreamableRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Return partial package data without loading them all to save on memory
|
||||
*
|
||||
* The function must return an array of package arrays.
|
||||
*
|
||||
* The package array must contain the following fields:
|
||||
* - name: package name (normalized/lowercased)
|
||||
* - repo: reference to the repository instance
|
||||
* - version: normalized version
|
||||
* - replace: array of package name => version constraint, optional
|
||||
* - provide: array of package name => version constraint, optional
|
||||
* - alias: pretty alias that this package should be aliased to, optional
|
||||
* - alias_normalized: normalized alias that this package should be aliased to, optional
|
||||
*
|
||||
* Any additional information can be returned and will be sent back
|
||||
* into loadPackage/loadAliasPackage for completing the package loading
|
||||
* when it's needed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMinimalPackages();
|
||||
|
||||
/**
|
||||
* Loads a package from minimal info of the package
|
||||
*
|
||||
* @param array $data the minimal info as was returned by getMinimalPackage
|
||||
* @return PackageInterface
|
||||
*/
|
||||
public function loadPackage(array $data);
|
||||
|
||||
/**
|
||||
* Loads an alias package from minimal info of the package
|
||||
*
|
||||
* @param array $data the minimal info as was returned by getMinimalPackage
|
||||
* @param PackageInterface $aliasOf the package which this alias is an alias of
|
||||
* @return AliasPackage
|
||||
*/
|
||||
public function loadAliasPackage(array $data, PackageInterface $aliasOf);
|
||||
}
|
Loading…
Reference in New Issue