From 5f2e42ec462f0b22fd4c714565ba273123a6c068 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 10 Mar 2012 01:16:37 +0100 Subject: [PATCH] CS fixes, made EventDispatcher optional in factory method --- src/Composer/Command/CreateProjectCommand.php | 4 +-- src/Composer/Command/InstallCommand.php | 14 ++++---- src/Composer/Installer.php | 36 +++++++++---------- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 04b6266f2..5c0039b77 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -18,7 +18,6 @@ use Composer\Installer\ProjectInstaller; use Composer\IO\IOInterface; use Composer\Repository\ComposerRepository; use Composer\Repository\FilesystemRepository; -use Composer\Script\EventDispatcher; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -119,8 +118,7 @@ EOT chdir($directory); $composer = Factory::create($io); - $eventDispatcher = new EventDispatcher($composer, $io); - $installer = Installer::create($io, $composer, $eventDispatcher); + $installer = Installer::create($io, $composer); $installer->run($preferSource); } diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index e8744af5a..d06278e7d 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -13,7 +13,6 @@ namespace Composer\Command; use Composer\Installer; -use Composer\Script\EventDispatcher; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -52,15 +51,14 @@ EOT { $composer = $this->getComposer(); $io = $this->getApplication()->getIO(); - $eventDispatcher = new EventDispatcher($composer, $io); - $install = Installer::create($io, $composer, $eventDispatcher); + $install = Installer::create($io, $composer); return $install->run( - (Boolean)$input->getOption('prefer-source'), - (Boolean)$input->getOption('dry-run'), - (Boolean)$input->getOption('verbose'), - (Boolean)$input->getOption('no-install-recommends'), - (Boolean)$input->getOption('install-suggests') + (Boolean) $input->getOption('prefer-source'), + (Boolean) $input->getOption('dry-run'), + (Boolean) $input->getOption('verbose'), + (Boolean) $input->getOption('no-install-recommends'), + (Boolean) $input->getOption('install-suggests') ); } } diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 6bb13eb86..f6fb70c1d 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -33,53 +33,51 @@ use Composer\Repository\RepositoryManager; use Composer\Script\EventDispatcher; use Composer\Script\ScriptEvents; +/** + * @author Jordi Boggiano + * @author Beau Simensen + * @author Konstantin Kudryashov + */ class Installer { /** - * * @var IOInterface */ protected $io; /** - * * @var PackageInterface */ protected $package; /** - * * @var DownloadManager */ protected $downloadManager; /** - * * @var RepositoryManager */ protected $repositoryManager; /** - * * @var Locker */ protected $locker; /** - * * @var InstallationManager */ protected $installationManager; /** - * * @var EventDispatcher */ protected $eventDispatcher; /** * Constructor - * + * * @param IOInterface $io * @param PackageInterface $package * @param DownloadManager $downloadManager @@ -102,12 +100,12 @@ class Installer /** * Run installation (or update) * - * @param bool $preferSource - * @param bool $dryRun - * @param bool $verbose - * @param bool $noInstallRecommends - * @param bool $installSuggests - * @param bool $update + * @param Boolean $preferSource + * @param Boolean $dryRun + * @param Boolean $verbose + * @param Boolean $noInstallRecommends + * @param Boolean $installSuggests + * @param Boolean $update * @param RepositoryInterface $additionalInstalledRepository */ public function run($preferSource = false, $dryRun = false, $verbose = false, $noInstallRecommends = false, $installSuggests = false, $update = false, RepositoryInterface $additionalInstalledRepository = null) @@ -202,8 +200,8 @@ class Installer } // prepare solver - $policy = new DefaultPolicy(); - $solver = new Solver($policy, $pool, $installedRepo); + $policy = new DefaultPolicy(); + $solver = new Solver($policy, $pool, $installedRepo); // solve dependencies $operations = $solver->solve($request); @@ -316,14 +314,16 @@ class Installer /** * Create Installer - * + * * @param IOInterface $io * @param Composer $composer * @param EventDispatcher $eventDispatcher * @return Installer */ - static public function create(IOInterface $io, Composer $composer, EventDispatcher $eventDispatcher) + static public function create(IOInterface $io, Composer $composer, EventDispatcher $eventDispatcher = null) { + $eventDispatcher = $eventDispatcher ?: new EventDispatcher($composer, $io); + return new static( $io, $composer->getPackage(),