1
0
Fork 0

Remplace all echo with writeln method of IO

pull/198/head
François Pluchino 2012-01-16 20:44:06 +01:00
parent 7888ec5313
commit 0f9dcc9618
5 changed files with 33 additions and 15 deletions

View File

@ -123,7 +123,7 @@ EOT
// prepare solver
$installationManager = $composer->getInstallationManager();
$policy = new DependencyResolver\DefaultPolicy();
$solver = new DependencyResolver\Solver($policy, $pool, $installedRepo);
$solver = new DependencyResolver\Solver($policy, $pool, $installedRepo, $this->getApplication()->getIO());
// solve dependencies
$operations = $solver->solve($request);

View File

@ -84,6 +84,14 @@ class Application extends BaseApplication
return $this->composer;
}
/**
* @return IOInterface
*/
public function getIO()
{
return $this->io;
}
/**
* Bootstraps a Composer instance
*
@ -144,8 +152,8 @@ class Application extends BaseApplication
// initialize installation manager
$im = new Installer\InstallationManager($vendorDir);
$im->addInstaller(new Installer\LibraryInstaller($vendorDir, $binDir, $dm, $rm->getLocalRepository(), null));
$im->addInstaller(new Installer\InstallerInstaller($vendorDir, $binDir, $dm, $rm->getLocalRepository(), $im));
$im->addInstaller(new Installer\LibraryInstaller($vendorDir, $binDir, $dm, $rm->getLocalRepository(), $io, null));
$im->addInstaller(new Installer\InstallerInstaller($vendorDir, $binDir, $dm, $rm->getLocalRepository(), $io, $im));
// load package
$loader = new Package\Loader\RootPackageLoader($rm);

View File

@ -12,6 +12,7 @@
namespace Composer\DependencyResolver;
use Composer\IO\IOInterface;
use Composer\Repository\RepositoryInterface;
use Composer\Package\PackageInterface;
use Composer\DependencyResolver\Operation;
@ -55,12 +56,15 @@ class Solver
protected $packageToUpdateRule = array();
protected $packageToFeatureRule = array();
public function __construct(PolicyInterface $policy, Pool $pool, RepositoryInterface $installed)
protected $io;
public function __construct(PolicyInterface $policy, Pool $pool, RepositoryInterface $installed, IOInterface $io)
{
$this->policy = $policy;
$this->pool = $pool;
$this->installed = $installed;
$this->rules = new RuleSet;
$this->io = $io;
}
/**
@ -2046,26 +2050,26 @@ class Solver
public function printDecisionMap()
{
echo "\nDecisionMap: \n";
$this->io->writeln("\nDecisionMap: ");
foreach ($this->decisionMap as $packageId => $level) {
if ($packageId === 0) {
continue;
}
if ($level > 0) {
echo ' +' . $this->pool->packageById($packageId) . "\n";
$this->io->writeln(' +' . $this->pool->packageById($packageId));
} else {
echo ' -' . $this->pool->packageById($packageId) . "\n";
$this->io->writeln(' -' . $this->pool->packageById($packageId));
}
}
echo "\n";
$this->io->writeln('');
}
public function printDecisionQueue()
{
echo "DecisionQueue: \n";
$this->io->writeln("DecisionQueue: ");
foreach ($this->decisionQueue as $i => $literal) {
echo ' ' . $literal . ' ' . $this->decisionQueueWhy[$i] . "\n";
$this->io->writeln(' ' . $literal . ' ' . $this->decisionQueueWhy[$i]);
}
echo "\n";
$this->io->writeln('');
}
}

View File

@ -12,6 +12,7 @@
namespace Composer\Installer;
use Composer\IO\IOInterface;
use Composer\Autoload\AutoloadGenerator;
use Composer\Downloader\DownloadManager;
use Composer\Repository\WritableRepositoryInterface;
@ -33,10 +34,11 @@ class InstallerInstaller extends LibraryInstaller
* @param string $binDir relative path for binaries
* @param DownloadManager $dm download manager
* @param WritableRepositoryInterface $repository repository controller
* @param IOInterface $io io instance
*/
public function __construct($vendorDir, $binDir, DownloadManager $dm, WritableRepositoryInterface $repository, InstallationManager $im)
public function __construct($vendorDir, $binDir, DownloadManager $dm, WritableRepositoryInterface $repository, IOInterface $io, InstallationManager $im)
{
parent::__construct($vendorDir, $binDir, $dm, $repository, 'composer-installer');
parent::__construct($vendorDir, $binDir, $dm, $repository, $io, 'composer-installer');
$this->installationManager = $im;
foreach ($repository->getPackages() as $package) {

View File

@ -12,6 +12,7 @@
namespace Composer\Installer;
use Composer\IO\IOInterface;
use Composer\Downloader\DownloadManager;
use Composer\Repository\WritableRepositoryInterface;
use Composer\DependencyResolver\Operation\OperationInterface;
@ -30,6 +31,7 @@ class LibraryInstaller implements InstallerInterface
protected $binDir;
protected $downloadManager;
protected $repository;
protected $io;
private $type;
private $filesystem;
@ -40,12 +42,14 @@ class LibraryInstaller implements InstallerInterface
* @param string $binDir relative path for binaries
* @param DownloadManager $dm download manager
* @param WritableRepositoryInterface $repository repository controller
* @param IOInterface $io io instance
* @param string $type package type that this installer handles
*/
public function __construct($vendorDir, $binDir, DownloadManager $dm, WritableRepositoryInterface $repository, $type = 'library')
public function __construct($vendorDir, $binDir, DownloadManager $dm, WritableRepositoryInterface $repository, IOInterface $io, $type = 'library')
{
$this->downloadManager = $dm;
$this->repository = $repository;
$this->io = $io;
$this->type = $type;
$this->filesystem = new Filesystem();
@ -136,7 +140,7 @@ class LibraryInstaller implements InstallerInterface
foreach ($package->getBinaries() as $bin) {
$link = $this->binDir.'/'.basename($bin);
if (file_exists($link)) {
echo 'Skipped installation of '.$bin.' for package '.$package->getName().', name conflicts with an existing file'.PHP_EOL;
$this->io->writeln('Skipped installation of '.$bin.' for package '.$package->getName().', name conflicts with an existing file');
continue;
}
$bin = $this->getInstallPath($package).'/'.$bin;