Fix typos, short var names etc
parent
753caf2b55
commit
b9114e16be
|
@ -13,17 +13,12 @@
|
|||
namespace Composer\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command as BaseCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Composer\DependencyResolver\Request;
|
||||
use Composer\DependencyResolver\Solver;
|
||||
use Composer\Installer\Operation;
|
||||
|
||||
/**
|
||||
* Base class for Composer commands
|
||||
*
|
||||
* @author Ryan Weaver <ryan@knplabs.com>
|
||||
* @authro Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* @author Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
*/
|
||||
abstract class Command extends BaseCommand
|
||||
{
|
||||
|
|
|
@ -85,6 +85,7 @@ EOT
|
|||
$installationManager->execute($operation);
|
||||
}
|
||||
|
||||
// TODO implement lock
|
||||
if (false) {
|
||||
$composer->getPackageLock()->lock($localRepo->getPackages());
|
||||
$output->writeln('> Locked');
|
||||
|
|
|
@ -29,9 +29,9 @@ class Composer
|
|||
private $package;
|
||||
private $lock;
|
||||
|
||||
private $rm;
|
||||
private $dm;
|
||||
private $im;
|
||||
private $repositoryManager;
|
||||
private $downloadManager;
|
||||
private $installationManager;
|
||||
|
||||
public function setPackage(PackageInterface $package)
|
||||
{
|
||||
|
@ -55,31 +55,31 @@ class Composer
|
|||
|
||||
public function setRepositoryManager(RepositoryManager $manager)
|
||||
{
|
||||
$this->rm = $manager;
|
||||
$this->repositoryManager = $manager;
|
||||
}
|
||||
|
||||
public function getRepositoryManager()
|
||||
{
|
||||
return $this->rm;
|
||||
return $this->repositoryManager;
|
||||
}
|
||||
|
||||
public function setDownloadManager(DownloadManager $manager)
|
||||
{
|
||||
$this->dm = $manager;
|
||||
$this->downloadManager = $manager;
|
||||
}
|
||||
|
||||
public function getDownloadManager()
|
||||
{
|
||||
return $this->dm;
|
||||
return $this->downloadManager;
|
||||
}
|
||||
|
||||
public function setInstallationManager(InstallationManager $manager)
|
||||
{
|
||||
$this->im = $manager;
|
||||
$this->installationManager = $manager;
|
||||
}
|
||||
|
||||
public function getInstallationManager()
|
||||
{
|
||||
return $this->im;
|
||||
return $this->installationManager;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
use Symfony\Component\Finder\Finder;
|
||||
use Composer\Command\InstallCommand;
|
||||
use Composer\Composer;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Package\PackageLock;
|
||||
|
||||
/**
|
||||
* The console application that handles the commands
|
||||
|
@ -61,7 +59,7 @@ class Application extends BaseApplication
|
|||
}
|
||||
|
||||
/**
|
||||
* Looks for all *Command files in Composer's Command directory
|
||||
* Initializes all the composer commands
|
||||
*/
|
||||
protected function registerCommands()
|
||||
{
|
||||
|
|
|
@ -68,7 +68,7 @@ class DownloadManager
|
|||
public function getDownloader($type)
|
||||
{
|
||||
if (!isset($this->downloaders[$type])) {
|
||||
throw new \UnexpectedValueException('Unknown source type: '.$type);
|
||||
throw new \InvalidArgumentException('Unknown source type: '.$type);
|
||||
}
|
||||
|
||||
return $this->downloaders[$type];
|
||||
|
|
|
@ -25,8 +25,8 @@ use Composer\Package\PackageInterface;
|
|||
*/
|
||||
class LibraryInstaller implements InstallerInterface
|
||||
{
|
||||
private $dir;
|
||||
private $dm;
|
||||
private $directory;
|
||||
private $downloadManager;
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
|
@ -36,20 +36,20 @@ class LibraryInstaller implements InstallerInterface
|
|||
* @param DownloadManager $dm download manager
|
||||
* @param WritableRepositoryInterface $repository repository controller
|
||||
*/
|
||||
public function __construct($dir, DownloadManager $dm, WritableRepositoryInterface $repository)
|
||||
public function __construct($directory, DownloadManager $dm, WritableRepositoryInterface $repository)
|
||||
{
|
||||
$this->dir = $dir;
|
||||
$this->dm = $dm;
|
||||
$this->directory = $directory;
|
||||
$this->downloadManager = $dm;
|
||||
|
||||
if (!is_dir($this->dir)) {
|
||||
if (file_exists($this->dir)) {
|
||||
if (!is_dir($this->directory)) {
|
||||
if (file_exists($this->directory)) {
|
||||
throw new \UnexpectedValueException(
|
||||
$this->dir.' exists and is not a directory.'
|
||||
$this->directory.' exists and is not a directory.'
|
||||
);
|
||||
}
|
||||
if (!mkdir($this->dir, 0777, true)) {
|
||||
if (!mkdir($this->directory, 0777, true)) {
|
||||
throw new \UnexpectedValueException(
|
||||
$this->dir.' does not exist and could not be created.'
|
||||
$this->directory.' does not exist and could not be created.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -78,9 +78,9 @@ class LibraryInstaller implements InstallerInterface
|
|||
*/
|
||||
public function install(PackageInterface $package)
|
||||
{
|
||||
$downloadPath = $this->dir.DIRECTORY_SEPARATOR.$package->getName();
|
||||
$downloadPath = $this->directory.DIRECTORY_SEPARATOR.$package->getName();
|
||||
|
||||
$this->dm->download($package, $downloadPath);
|
||||
$this->downloadManager->download($package, $downloadPath);
|
||||
$this->repository->addPackage($package);
|
||||
}
|
||||
|
||||
|
@ -98,9 +98,9 @@ class LibraryInstaller implements InstallerInterface
|
|||
throw new \InvalidArgumentException('Package is not installed: '.$initial);
|
||||
}
|
||||
|
||||
$downloadPath = $this->dir.DIRECTORY_SEPARATOR.$initial->getName();
|
||||
$downloadPath = $this->directory.DIRECTORY_SEPARATOR.$initial->getName();
|
||||
|
||||
$this->dm->update($initial, $target, $downloadPath);
|
||||
$this->downloadManager->update($initial, $target, $downloadPath);
|
||||
$this->repository->removePackage($initial);
|
||||
$this->repository->addPackage($target);
|
||||
}
|
||||
|
@ -118,9 +118,9 @@ class LibraryInstaller implements InstallerInterface
|
|||
throw new \InvalidArgumentException('Package is not installed: '.$package);
|
||||
}
|
||||
|
||||
$downloadPath = $this->dir.DIRECTORY_SEPARATOR.$package->getName();
|
||||
$downloadPath = $this->directory.DIRECTORY_SEPARATOR.$package->getName();
|
||||
|
||||
$this->dm->remove($package, $downloadPath);
|
||||
$this->downloadManager->remove($package, $downloadPath);
|
||||
$this->repository->removePackage($package);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$manager->setDownloader('test', $downloader);
|
||||
$this->assertSame($downloader, $manager->getDownloader('test'));
|
||||
|
||||
$this->setExpectedException('UnexpectedValueException');
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$manager->getDownloader('unregistered');
|
||||
}
|
||||
|
||||
|
@ -475,13 +475,14 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
|
|||
$manager->remove($package, 'vendor/pkg');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testRemoveBadlyInstalledPackage()
|
||||
{
|
||||
$package = $this->createPackageMock();
|
||||
$manager = new DownloadManager();
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$manager->remove($package, 'vendor/pkg');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue