Fix regression added in 33af9eea95
, fixes #1841
parent
823ca21e6c
commit
5264d0637b
@ -0,0 +1,66 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* Writable array repository.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class WritableArrayRepository extends ArrayRepository implements WritableRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function write()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function reload()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getCanonicalPackages()
|
||||
{
|
||||
$packages = $this->getPackages();
|
||||
|
||||
// get at most one package of each name, prefering non-aliased ones
|
||||
$packagesByName = array();
|
||||
foreach ($packages as $package) {
|
||||
if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
|
||||
$packagesByName[$package->getName()] = $package;
|
||||
}
|
||||
}
|
||||
|
||||
$canonicalPackages = array();
|
||||
|
||||
// unfold aliased packages
|
||||
foreach ($packagesByName as $package) {
|
||||
while ($package instanceof AliasPackage) {
|
||||
$package = $package->getAliasOf();
|
||||
}
|
||||
|
||||
$canonicalPackages[] = $package;
|
||||
}
|
||||
|
||||
return $canonicalPackages;
|
||||
}
|
||||
}
|
@ -1,26 +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\Mock;
|
||||
|
||||
use Composer\Repository\ArrayRepository;
|
||||
use Composer\Repository\WritableRepositoryInterface;
|
||||
|
||||
class WritableRepositoryMock extends ArrayRepository implements WritableRepositoryInterface
|
||||
{
|
||||
public function reload()
|
||||
{
|
||||
}
|
||||
|
||||
public function write()
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue