1
0
Fork 0

Fix typos, short var names etc

pull/20/merge
Jordi Boggiano 2011-09-25 23:19:12 +02:00
parent 753caf2b55
commit b9114e16be
7 changed files with 33 additions and 38 deletions

View File

@ -13,17 +13,12 @@
namespace Composer\Command; namespace Composer\Command;
use Symfony\Component\Console\Command\Command as BaseCommand; 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 * Base class for Composer commands
* *
* @author Ryan Weaver <ryan@knplabs.com> * @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 abstract class Command extends BaseCommand
{ {

View File

@ -85,6 +85,7 @@ EOT
$installationManager->execute($operation); $installationManager->execute($operation);
} }
// TODO implement lock
if (false) { if (false) {
$composer->getPackageLock()->lock($localRepo->getPackages()); $composer->getPackageLock()->lock($localRepo->getPackages());
$output->writeln('> Locked'); $output->writeln('> Locked');

View File

@ -29,9 +29,9 @@ class Composer
private $package; private $package;
private $lock; private $lock;
private $rm; private $repositoryManager;
private $dm; private $downloadManager;
private $im; private $installationManager;
public function setPackage(PackageInterface $package) public function setPackage(PackageInterface $package)
{ {
@ -55,31 +55,31 @@ class Composer
public function setRepositoryManager(RepositoryManager $manager) public function setRepositoryManager(RepositoryManager $manager)
{ {
$this->rm = $manager; $this->repositoryManager = $manager;
} }
public function getRepositoryManager() public function getRepositoryManager()
{ {
return $this->rm; return $this->repositoryManager;
} }
public function setDownloadManager(DownloadManager $manager) public function setDownloadManager(DownloadManager $manager)
{ {
$this->dm = $manager; $this->downloadManager = $manager;
} }
public function getDownloadManager() public function getDownloadManager()
{ {
return $this->dm; return $this->downloadManager;
} }
public function setInstallationManager(InstallationManager $manager) public function setInstallationManager(InstallationManager $manager)
{ {
$this->im = $manager; $this->installationManager = $manager;
} }
public function getInstallationManager() public function getInstallationManager()
{ {
return $this->im; return $this->installationManager;
} }
} }

View File

@ -18,8 +18,6 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
use Composer\Command\InstallCommand; use Composer\Command\InstallCommand;
use Composer\Composer; use Composer\Composer;
use Composer\Package\PackageInterface;
use Composer\Package\PackageLock;
/** /**
* The console application that handles the commands * 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() protected function registerCommands()
{ {

View File

@ -68,7 +68,7 @@ class DownloadManager
public function getDownloader($type) public function getDownloader($type)
{ {
if (!isset($this->downloaders[$type])) { if (!isset($this->downloaders[$type])) {
throw new \UnexpectedValueException('Unknown source type: '.$type); throw new \InvalidArgumentException('Unknown source type: '.$type);
} }
return $this->downloaders[$type]; return $this->downloaders[$type];

View File

@ -25,8 +25,8 @@ use Composer\Package\PackageInterface;
*/ */
class LibraryInstaller implements InstallerInterface class LibraryInstaller implements InstallerInterface
{ {
private $dir; private $directory;
private $dm; private $downloadManager;
private $repository; private $repository;
/** /**
@ -36,20 +36,20 @@ class LibraryInstaller implements InstallerInterface
* @param DownloadManager $dm download manager * @param DownloadManager $dm download manager
* @param WritableRepositoryInterface $repository repository controller * @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->directory = $directory;
$this->dm = $dm; $this->downloadManager = $dm;
if (!is_dir($this->dir)) { if (!is_dir($this->directory)) {
if (file_exists($this->dir)) { if (file_exists($this->directory)) {
throw new \UnexpectedValueException( 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( 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) 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); $this->repository->addPackage($package);
} }
@ -98,9 +98,9 @@ class LibraryInstaller implements InstallerInterface
throw new \InvalidArgumentException('Package is not installed: '.$initial); 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->removePackage($initial);
$this->repository->addPackage($target); $this->repository->addPackage($target);
} }
@ -118,9 +118,9 @@ class LibraryInstaller implements InstallerInterface
throw new \InvalidArgumentException('Package is not installed: '.$package); 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); $this->repository->removePackage($package);
} }
} }

View File

@ -24,7 +24,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
$manager->setDownloader('test', $downloader); $manager->setDownloader('test', $downloader);
$this->assertSame($downloader, $manager->getDownloader('test')); $this->assertSame($downloader, $manager->getDownloader('test'));
$this->setExpectedException('UnexpectedValueException'); $this->setExpectedException('InvalidArgumentException');
$manager->getDownloader('unregistered'); $manager->getDownloader('unregistered');
} }
@ -475,13 +475,14 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
$manager->remove($package, 'vendor/pkg'); $manager->remove($package, 'vendor/pkg');
} }
/**
* @expectedException InvalidArgumentException
*/
public function testRemoveBadlyInstalledPackage() public function testRemoveBadlyInstalledPackage()
{ {
$package = $this->createPackageMock(); $package = $this->createPackageMock();
$manager = new DownloadManager(); $manager = new DownloadManager();
$this->setExpectedException('InvalidArgumentException');
$manager->remove($package, 'vendor/pkg'); $manager->remove($package, 'vendor/pkg');
} }