1
0
Fork 0

Reverted inadvertent API change, improved API documentation

pull/4324/head
Malte Wunsch 2015-08-04 09:32:23 +02:00
parent 767279b41a
commit 70ff00c9de
3 changed files with 5 additions and 35 deletions

View File

@ -42,12 +42,11 @@ class WritableArrayRepository extends ArrayRepository implements WritableReposit
{
$packages = $this->getPackages();
// get at most one package of each (name, version) combination, prefering non-aliased ones
// get at most one package of each name, preferring non-aliased ones
$packagesByName = array();
foreach ($packages as $package) {
$index = $package->getName() . $package->getVersion();
if (!isset($packagesByName[$index]) || $packagesByName[$index] instanceof AliasPackage) {
$packagesByName[$index] = $package;
if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
$packagesByName[$package->getName()] = $package;
}
}

View File

@ -41,14 +41,14 @@ interface WritableRepositoryInterface extends RepositoryInterface
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[]
*/
public function getCanonicalPackages();
/**
* Forces a reload of all packages
* Forces a reload of all packages.
*/
public function reload();
}

View File

@ -1,29 +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\Test\Repository;
use Composer\Repository\WritableArrayRepository;
use Composer\TestCase;
final class WritableArrayRepositoryTest extends TestCase
{
public function testGetCanonicalPackagesReturnsDifferentVersionsOfSameNamedPackage()
{
$repository = new WritableArrayRepository();
$repository->addPackage($this->getPackage('foo', 1));
$repository->addPackage($this->getPackage('foo', 2));
$this->assertCount(2, $repository->getCanonicalPackages());
}
}