Merge pull request #4324 from MalteWunsch/getCanonicalPackages-with-different-versions
Improve documentation for WritableRepositoryInterface::getCanonicalPackagespull/4345/head
commit
bd23ce672a
|
@ -26,6 +26,7 @@ use Composer\Package\LinkConstraint\VersionConstraint;
|
||||||
*/
|
*/
|
||||||
class ArrayRepository implements RepositoryInterface
|
class ArrayRepository implements RepositoryInterface
|
||||||
{
|
{
|
||||||
|
/** @var PackageInterface[] */
|
||||||
protected $packages;
|
protected $packages;
|
||||||
|
|
||||||
public function __construct(array $packages = array())
|
public function __construct(array $packages = array())
|
||||||
|
|
|
@ -42,7 +42,7 @@ class WritableArrayRepository extends ArrayRepository implements WritableReposit
|
||||||
{
|
{
|
||||||
$packages = $this->getPackages();
|
$packages = $this->getPackages();
|
||||||
|
|
||||||
// get at most one package of each name, prefering non-aliased ones
|
// get at most one package of each name, preferring non-aliased ones
|
||||||
$packagesByName = array();
|
$packagesByName = array();
|
||||||
foreach ($packages as $package) {
|
foreach ($packages as $package) {
|
||||||
if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
|
if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
|
||||||
|
|
|
@ -41,14 +41,14 @@ interface WritableRepositoryInterface extends RepositoryInterface
|
||||||
public function removePackage(PackageInterface $package);
|
public function removePackage(PackageInterface $package);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get unique packages, with aliases resolved and removed
|
* Get unique packages (at most one package of each name), with aliases resolved and removed.
|
||||||
*
|
*
|
||||||
* @return PackageInterface[]
|
* @return PackageInterface[]
|
||||||
*/
|
*/
|
||||||
public function getCanonicalPackages();
|
public function getCanonicalPackages();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forces a reload of all packages
|
* Forces a reload of all packages.
|
||||||
*/
|
*/
|
||||||
public function reload();
|
public function reload();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue