Fix regression added in 33af9eea95
, fixes #1841
parent
823ca21e6c
commit
5264d0637b
|
@ -16,7 +16,7 @@ use Composer\Config;
|
|||
use Composer\Installer\InstallationManager;
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Repository\RepositoryInterface;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
use Composer\Util\Filesystem;
|
||||
use Composer\Script\EventDispatcher;
|
||||
use Composer\Script\ScriptEvents;
|
||||
|
@ -37,7 +37,7 @@ class AutoloadGenerator
|
|||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
public function dump(Config $config, RepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '')
|
||||
public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '')
|
||||
{
|
||||
$filesystem = new Filesystem();
|
||||
$filesystem->ensureDirectoryExists($config->get('vendor-dir'));
|
||||
|
@ -66,7 +66,7 @@ return array(
|
|||
|
||||
EOF;
|
||||
|
||||
$packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getPackages());
|
||||
$packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getCanonicalPackages());
|
||||
$autoloads = $this->parseAutoloads($packageMap, $mainPackage);
|
||||
|
||||
foreach ($autoloads['psr-0'] as $namespace => $paths) {
|
||||
|
@ -205,10 +205,6 @@ EOF;
|
|||
$packageMap = array(array($mainPackage, ''));
|
||||
|
||||
foreach ($packages as $package) {
|
||||
// unfold aliased packages
|
||||
while ($package instanceof AliasPackage && !in_array($package->getAliasOf(), $packages, true)) {
|
||||
$package = $package->getAliasOf();
|
||||
}
|
||||
if ($package instanceof AliasPackage) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -259,7 +259,7 @@ class Installer
|
|||
$platformDevReqs = $this->devMode ? $this->extractPlatformRequirements($this->package->getDevRequires()) : array();
|
||||
|
||||
$updatedLock = $this->locker->setLockData(
|
||||
array_diff($localRepo->getPackages(), (array) $devPackages),
|
||||
array_diff($localRepo->getCanonicalPackages(), (array) $devPackages),
|
||||
$devPackages,
|
||||
$platformReqs,
|
||||
$platformDevReqs,
|
||||
|
@ -582,16 +582,12 @@ class Installer
|
|||
$operations = array();
|
||||
}
|
||||
|
||||
foreach ($localRepo->getPackages() as $package) {
|
||||
foreach ($localRepo->getCanonicalPackages() as $package) {
|
||||
// skip non-dev packages
|
||||
if (!$package->isDev()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($package instanceof AliasPackage) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip packages that will be updated/uninstalled
|
||||
foreach ($operations as $operation) {
|
||||
if (('update' === $operation->getJobType() && $operation->getInitialPackage()->equals($package))
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
namespace Composer\Repository;
|
||||
|
||||
use Composer\Json\JsonFile;
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\Loader\ArrayLoader;
|
||||
use Composer\Package\Dumper\ArrayDumper;
|
||||
|
||||
|
@ -23,7 +22,7 @@ use Composer\Package\Dumper\ArrayDumper;
|
|||
* @author Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class FilesystemRepository extends ArrayRepository implements WritableRepositoryInterface
|
||||
class FilesystemRepository extends WritableArrayRepository
|
||||
{
|
||||
private $file;
|
||||
|
||||
|
@ -77,16 +76,10 @@ class FilesystemRepository extends ArrayRepository implements WritableRepository
|
|||
public function write()
|
||||
{
|
||||
$data = array();
|
||||
$dumper = new ArrayDumper();
|
||||
$packages = $this->getPackages();
|
||||
foreach ($packages as $package) {
|
||||
// unfold aliased packages
|
||||
while ($package instanceof AliasPackage && !in_array($package->getAliasOf(), $packages, true)) {
|
||||
$package = $package->getAliasOf();
|
||||
}
|
||||
if (!$package instanceof AliasPackage) {
|
||||
$data[] = $dumper->dump($package);
|
||||
}
|
||||
$dumper = new ArrayDumper();
|
||||
|
||||
foreach ($this->getCanonicalPackages() as $package) {
|
||||
$data[] = $dumper->dump($package);
|
||||
}
|
||||
|
||||
$this->file->write($data);
|
||||
|
|
|
@ -19,19 +19,6 @@ namespace Composer\Repository;
|
|||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class InstalledArrayRepository extends ArrayRepository implements InstalledRepositoryInterface
|
||||
class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function write()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function reload()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,9 +125,9 @@ class RepositoryManager
|
|||
/**
|
||||
* Sets local repository for the project.
|
||||
*
|
||||
* @param RepositoryInterface $repository repository instance
|
||||
* @param WritableRepositoryInterface $repository repository instance
|
||||
*/
|
||||
public function setLocalRepository(RepositoryInterface $repository)
|
||||
public function setLocalRepository(WritableRepositoryInterface $repository)
|
||||
{
|
||||
$this->localRepository = $repository;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ class RepositoryManager
|
|||
/**
|
||||
* Returns local repository for the project.
|
||||
*
|
||||
* @return RepositoryInterface
|
||||
* @return WritableRepositoryInterface
|
||||
*/
|
||||
public function getLocalRepository()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -40,6 +40,13 @@ interface WritableRepositoryInterface extends RepositoryInterface
|
|||
*/
|
||||
public function removePackage(PackageInterface $package);
|
||||
|
||||
/**
|
||||
* Get unique packages, with aliases resolved and removed
|
||||
*
|
||||
* @return PackageInterface[]
|
||||
*/
|
||||
public function getCanonicalPackages();
|
||||
|
||||
/**
|
||||
* Forces a reload of all packages
|
||||
*/
|
||||
|
|
|
@ -155,7 +155,7 @@ class EventDispatcher
|
|||
}
|
||||
|
||||
$generator = $this->composer->getAutoloadGenerator();
|
||||
$packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages();
|
||||
$packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
|
||||
$packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
|
||||
$map = $generator->parseAutoloads($packageMap, $package);
|
||||
$this->loader = $generator->createLoader($map);
|
||||
|
|
|
@ -69,7 +69,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$targetDir = $package->getTargetDir();
|
||||
return $that->vendorDir.'/'.$package->getName() . ($targetDir ? '/'.$targetDir : '');
|
||||
}));
|
||||
$this->repository = $this->getMock('Composer\Repository\RepositoryInterface');
|
||||
$this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
|
||||
|
||||
$this->eventDispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -99,7 +99,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/composer');
|
||||
|
@ -125,7 +125,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
|
||||
|
@ -149,7 +149,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->vendorDir .= '/subdir';
|
||||
|
@ -175,7 +175,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$package->setTargetDir('Main/Foo/');
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->vendorDir.'/a');
|
||||
|
@ -205,7 +205,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$b->setAutoload(array('psr-0' => array('B\\Sub\\Name' => 'src/')));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue($packages));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
|
||||
|
@ -225,7 +225,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$package->setAutoload(array('psr-0' => array('foo/bar/non/existing/')));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_8');
|
||||
|
@ -247,7 +247,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$b->setAutoload(array('classmap' => array('src/', 'lib/')));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue($packages));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
|
||||
|
@ -283,7 +283,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$b->setAutoload(array('classmap' => array('src/')));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue($packages));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
|
||||
|
@ -319,7 +319,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$c->setAutoload(array('classmap' => array('./')));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue($packages));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
|
||||
|
@ -358,7 +358,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$c->setTargetDir('foo/bar');
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue($packages));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->vendorDir.'/a/a');
|
||||
|
@ -412,7 +412,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$e->setRequires(array(new Link('e/e', 'c/lorem')));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue($packages));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->vendorDir . '/z/foo');
|
||||
|
@ -454,7 +454,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$b->setAutoload(array('psr-0' => array('B\\Sub\\Name' => 'src/')));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue($packages));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/lib/A/B');
|
||||
|
@ -524,7 +524,7 @@ EOF;
|
|||
$packages[] = $c;
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method("getPackages")
|
||||
->method("getCanonicalPackages")
|
||||
->will($this->returnValue($packages));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
|
||||
|
@ -553,7 +553,7 @@ EOF;
|
|||
$packages[] = $a;
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method("getPackages")
|
||||
->method("getCanonicalPackages")
|
||||
->will($this->returnValue($packages));
|
||||
|
||||
mkdir($this->vendorDir."/composer", 0777, true);
|
||||
|
@ -581,7 +581,7 @@ EOF;
|
|||
$a->setIncludePaths(array("lib/"));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method("getPackages")
|
||||
->method("getCanonicalPackages")
|
||||
->will($this->returnValue($packages));
|
||||
|
||||
mkdir($this->vendorDir."/composer", 0777, true);
|
||||
|
@ -609,7 +609,7 @@ EOF;
|
|||
$packages[] = $a;
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method("getPackages")
|
||||
->method("getCanonicalPackages")
|
||||
->will($this->returnValue($packages));
|
||||
|
||||
mkdir($this->vendorDir."/composer", 0777, true);
|
||||
|
@ -630,7 +630,7 @@ EOF;
|
|||
$package->setAutoload(array('psr-0' => array('foo/bar/non/existing/')));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_8');
|
||||
|
@ -645,7 +645,7 @@ EOF;
|
|||
$package->setTargetDir('Main/Foo/');
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->config->expects($this->at(2))
|
||||
|
@ -682,7 +682,7 @@ EOF;
|
|||
));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue(array($vendorPackage)));
|
||||
|
||||
$im = $this->getMockBuilder('Composer\Installer\InstallationManager')
|
||||
|
@ -764,7 +764,7 @@ EOF;
|
|||
));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/src/Foo');
|
||||
|
@ -818,7 +818,7 @@ EOF;
|
|||
));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('getPackages')
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$this->fs->ensureDirectoryExists($this->workingDir.'/Foo');
|
||||
|
|
|
@ -17,13 +17,13 @@ use Composer\Config;
|
|||
use Composer\Json\JsonFile;
|
||||
use Composer\Repository\ArrayRepository;
|
||||
use Composer\Repository\RepositoryManager;
|
||||
use Composer\Repository\InstalledArrayRepository;
|
||||
use Composer\Package\RootPackageInterface;
|
||||
use Composer\Package\Link;
|
||||
use Composer\Package\Locker;
|
||||
use Composer\Test\Mock\FactoryMock;
|
||||
use Composer\Test\Mock\InstalledFilesystemRepositoryMock;
|
||||
use Composer\Test\Mock\InstallationManagerMock;
|
||||
use Composer\Test\Mock\WritableRepositoryMock;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
|
@ -53,7 +53,7 @@ class InstallerTest extends TestCase
|
|||
$config = $this->getMock('Composer\Config');
|
||||
|
||||
$repositoryManager = new RepositoryManager($io, $config);
|
||||
$repositoryManager->setLocalRepository(new WritableRepositoryMock());
|
||||
$repositoryManager->setLocalRepository(new InstalledArrayRepository());
|
||||
|
||||
if (!is_array($repositories)) {
|
||||
$repositories = array($repositories);
|
||||
|
|
|
@ -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