From 9af46ad800bc00d48cc517b1090281a2f16ba2b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pluchino?= Date: Wed, 11 Jan 2012 13:55:05 +0100 Subject: [PATCH] Add Helper Wrapper --- src/Composer/Console/Application.php | 23 +-- src/Composer/Console/Helper/Wrapper.php | 160 ++++++++++++++++++ .../Console/Helper/WrapperInterface.php | 95 +++++++++++ src/Composer/Console/Output/ConsoleOutput.php | 104 ------------ src/Composer/Downloader/FileDownloader.php | 29 ++-- .../Repository/ComposerRepository.php | 10 +- src/Composer/Repository/PackageRepository.php | 13 +- src/Composer/Repository/PearRepository.php | 9 +- src/Composer/Repository/RepositoryManager.php | 13 +- .../Repository/Vcs/GitBitbucketDriver.php | 7 +- src/Composer/Repository/Vcs/GitDriver.php | 7 +- src/Composer/Repository/Vcs/GitHubDriver.php | 7 +- .../Repository/Vcs/HgBitbucketDriver.php | 7 +- src/Composer/Repository/Vcs/HgDriver.php | 7 +- src/Composer/Repository/Vcs/SvnDriver.php | 7 +- src/Composer/Repository/Vcs/VcsDriver.php | 20 +-- src/Composer/Repository/VcsRepository.php | 15 +- 17 files changed, 320 insertions(+), 213 deletions(-) create mode 100644 src/Composer/Console/Helper/Wrapper.php create mode 100644 src/Composer/Console/Helper/WrapperInterface.php delete mode 100644 src/Composer/Console/Output/ConsoleOutput.php diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 368af21a0..fb649c812 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -12,13 +12,16 @@ namespace Composer\Console; +use Composer\Console\Helper\WrapperInterface; + use Symfony\Component\Console\Application as BaseApplication; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Finder\Finder; -use Composer\Console\Output\ConsoleOutput; +use Composer\Console\Helper\Wrapper; use Composer\Command; use Composer\Composer; use Composer\Installer; @@ -37,8 +40,7 @@ use Composer\Json\JsonFile; class Application extends BaseApplication { protected $composer; - protected $input; - protected $output; + protected $wrapper; public function __construct() { @@ -67,8 +69,7 @@ class Application extends BaseApplication { $this->registerCommands(); - $this->input = $input; - $this->output = $output; + $this->wrapper = new Wrapper($input, $output); return parent::doRun($input, $output); } @@ -79,7 +80,7 @@ class Application extends BaseApplication public function getComposer() { if (null === $this->composer) { - $this->composer = self::bootstrapComposer(null, $this->input, $this->output); + $this->composer = self::bootstrapComposer(null, $this->wrapper); } return $this->composer; @@ -90,7 +91,7 @@ class Application extends BaseApplication * * @return Composer */ - public static function bootstrapComposer($composerFile = null, InputInterface $input = null, OutputInterface $output = null) + public static function bootstrapComposer($composerFile = null, WrapperInterface $wrapper) { // load Composer configuration if (null === $composerFile) { @@ -128,7 +129,7 @@ class Application extends BaseApplication $binDir = getenv('COMPOSER_BIN_DIR') ?: $packageConfig['config']['bin-dir']; // initialize repository manager - $rm = new Repository\RepositoryManager($input, $output); + $rm = new Repository\RepositoryManager($wrapper); $rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($vendorDir.'/.composer/installed.json'))); $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository'); $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository'); @@ -140,8 +141,8 @@ class Application extends BaseApplication $dm->setDownloader('git', new Downloader\GitDownloader()); $dm->setDownloader('svn', new Downloader\SvnDownloader()); $dm->setDownloader('hg', new Downloader\HgDownloader()); - $dm->setDownloader('pear', new Downloader\PearDownloader($input, $output)); - $dm->setDownloader('zip', new Downloader\ZipDownloader($input, $output)); + $dm->setDownloader('pear', new Downloader\PearDownloader($wrapper)); + $dm->setDownloader('zip', new Downloader\ZipDownloader($wrapper)); // initialize installation manager $im = new Installer\InstallationManager($vendorDir); @@ -154,7 +155,7 @@ class Application extends BaseApplication // load default repository unless it's explicitly disabled if (!isset($packageConfig['repositories']['packagist']) || $packageConfig['repositories']['packagist'] !== false) { - $rm->addRepository(new Repository\ComposerRepository($input, $output, array('url' => 'http://packagist.org'))); + $rm->addRepository(new Repository\ComposerRepository(array('url' => 'http://packagist.org'))); } // init locker diff --git a/src/Composer/Console/Helper/Wrapper.php b/src/Composer/Console/Helper/Wrapper.php new file mode 100644 index 000000000..6600386e6 --- /dev/null +++ b/src/Composer/Console/Helper/Wrapper.php @@ -0,0 +1,160 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Console\Helper; + +use Composer\Console\Helper\WrapperInterface; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\ConsoleOutputInterface; +use Symfony\Component\Console\Helper\HelperInterface; + +/** + * Helper wrapper. + * + * @author François Pluchino + */ +class Wrapper implements WrapperInterface +{ + protected $input; + protected $output; + protected $helper; + + /** + * Constructor. + * + * @param InputInterface $input The input instance + * @param ConsoleOutputInterface $output The output instance + * @param HelperInterface $helper The helper instance + */ + public function __construct(InputInterface $input, ConsoleOutputInterface $output, HelperInterface $helper = null) + { + $this->input = $input; + $this->output = $output; + $this->helper = $helper; + } + + /** + * {@inheritDoc} + */ + public function getInput() + { + return $this->input; + } + + /** + * {@inheritDoc} + */ + public function setInput(InputInterface $input) + { + $this->input = $input; + } + + /** + * {@inheritDoc} + */ + public function getOutput() + { + return $this->output; + } + + /** + * {@inheritDoc} + */ + public function setOutput(ConsoleOutputInterface $output) + { + $this->output = $output; + } + + /** + * {@inheritDoc} + */ + public function getHelper() + { + return $this->helper; + } + + /** + * {@inheritDoc} + */ + public function setHelper(HelperInterface $helper) + { + $this->helper = $helper; + } + + /** + * {@inheritDoc} + */ + public function overwrite($messages, $size = 80, $newline = false, $type = 0) + { + for ($place = $size; $place > 0; $place--) { + $this->getOutput()->write("\x08"); + } + + $this->getOutput()->write($messages, false, $type); + + for ($place = ($size - strlen($messages)); $place > 0; $place--) { + $this->getOutput()->write(' '); + } + + // clean up the end line + for ($place = ($size - strlen($messages)); $place > 0; $place--) { + $this->getOutput()->write("\x08"); + } + + if ($newline) { + $this->getOutput()->writeln(''); + } + } + + /** + * {@inheritDoc} + */ + public function overwriteln($messages, $size = 80, $type = 0) + { + $this->overwrite($messages, $size, true, $type); + } + + /** + * {@inheritDoc} + */ + public function promptSilent($title = '') + { + // for windows OS + if (preg_match('/^win/i', PHP_OS)) { + $vbscript = sys_get_temp_dir() . '/prompt_password.vbs'; + file_put_contents($vbscript, + 'wscript.echo(Inputbox("' . addslashes($title) . '","' + . addslashes($title) . '", ""))'); + $command = "cscript //nologo " . escapeshellarg($vbscript); + $value = rtrim(shell_exec($command)); + unlink($vbscript); + $this->getOutput()->writeln(''); + + return $value; + } + + // for other OS + else { + $command = "/usr/bin/env bash -c 'echo OK'"; + + if (rtrim(shell_exec($command)) !== 'OK') { + throw new \RuntimeException("Can't invoke bash for silent prompt"); + } + + $command = "/usr/bin/env bash -c 'read -s mypassword && echo \$mypassword'"; + $value = rtrim(shell_exec($command)); + $this->getOutput()->writeln(''); + + return $value; + } + } +} diff --git a/src/Composer/Console/Helper/WrapperInterface.php b/src/Composer/Console/Helper/WrapperInterface.php new file mode 100644 index 000000000..f0fe8b922 --- /dev/null +++ b/src/Composer/Console/Helper/WrapperInterface.php @@ -0,0 +1,95 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Console\Helper; + +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\ConsoleOutputInterface; +use Symfony\Component\Console\Helper\HelperInterface; + +/** + * Helper wrapper interface. + * + * @author François Pluchino + */ +interface WrapperInterface +{ + /** + * Returns an InputInterface instance. + * + * @return InputInterface "InputArgument", "InputOption", "InputDefinition" + */ + function getInput(); + + /** + * Set an InputInterface instance. + * + * @param InputInterface $input The input + */ + function setInput(InputInterface $input); + + /** + * Returns an ConsoleOutput instance. + * + * @return ConsoleOutputInterface + */ + function getOutput(); + + /** + * Set an ConsoleOutput instance. + * + * @param ConsoleOutputInterface $output The output + */ + function setOutput(ConsoleOutputInterface $output); + + /** + * Returns an HelperInterface instance. + * + * @return HelperInterface + */ + function getHelper(); + + /** + * Set an HelperInterface instance. + * + * @param HelperInterface $helper The helper + */ + function setHelper(HelperInterface $helper); + + /** + * Overwrites a previous message to the output. + * + * @param string|array $messages The message as an array of lines of a single string + * @param integer $size The size of line + * @param Boolean $newline Whether to add a newline or not + * @param integer $type The type of output + */ + public function overwrite($messages, $size = 80, $newline = false, $type = 0); + + /** + * Overwrites a previous message to the output and adds a newline at the end. + * + * @param string|array $messages The message as an array of lines of a single string + * @param integer $size The size of line + * @param integer $type The type of output + */ + public function overwriteln($messages, $size = 80, $type = 0); + + /** + * Interactively prompts for input without echoing to the terminal. + * + * @param string $title The title of prompt (used only for windows) + * + * @return string The value + */ + public function promptSilent($title = ''); +} diff --git a/src/Composer/Console/Output/ConsoleOutput.php b/src/Composer/Console/Output/ConsoleOutput.php deleted file mode 100644 index a301dd504..000000000 --- a/src/Composer/Console/Output/ConsoleOutput.php +++ /dev/null @@ -1,104 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Console\Output; - -use Symfony\Component\Console\Output\ConsoleOutput as BaseConsoleOutput; - -/** - * ConsoleOutput is the default class for all CLI output. - * - * @author François Pluchino - */ -class ConsoleOutput extends BaseConsoleOutput -{ - /** - * Overwrites a previous message to the output. - * - * @param string|array $messages The message as an array of lines of a single string - * @param integer $size The size of line - * @param Boolean $newline Whether to add a newline or not - * @param integer $type The type of output - */ - public function overwrite($messages, $size = 80, $newline = false, $type = 0) - { - for ($place = $size; $place > 0; $place--) { - $this->write("\x08"); - } - - $this->write($messages, false, $type); - - for ($place = ($size - strlen($messages)); $place > 0; $place--) { - $this->write(' '); - } - - // clean up the end line - for ($place = ($size - strlen($messages)); $place > 0; $place--) { - $this->write("\x08"); - } - - if ($newline) { - $this->writeln(''); - } - } - - /** - * Overwrites a previous message to the output and adds a newline at the end. - * - * @param string|array $messages The message as an array of lines of a single string - * @param integer $size The size of line - * @param integer $type The type of output - */ - public function overwriteln($messages, $size = 80, $type = 0) - { - $this->write($messages, $size, true, $type); - } - - /** - * Interactively prompts for input without echoing to the terminal. - * Requires a bash shell or Windows and won't work with safe_mode - * settings (Uses `shell_exec`). - * - * @param string $title The title of prompt (only for windows) - * - * @return string The value - */ - public function promptSilent($title = '') - { - if (preg_match('/^win/i', PHP_OS)) { - $vbscript = sys_get_temp_dir() . '/prompt_password.vbs'; - file_put_contents($vbscript, - 'wscript.echo(Inputbox("' . addslashes($title) . '","' - . addslashes($title) . '", ""))'); - $command = "cscript //nologo " . escapeshellarg($vbscript); - $value = rtrim(shell_exec($command)); - unlink($vbscript); - $this->writeln(''); - - return $value; - - } else { - $command = "/usr/bin/env bash -c 'echo OK'"; - - if (rtrim(shell_exec($command)) !== 'OK') { - trigger_error("Can't invoke bash"); - return; - } - - $command = "/usr/bin/env bash -c 'read -s mypassword && echo \$mypassword'"; - $value = rtrim(shell_exec($command)); - $this->writeln(''); - - return $value; - } - } -} diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 456241899..504460644 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -11,9 +11,8 @@ namespace Composer\Downloader; +use Composer\Console\Helper\WrapperInterface; use Composer\Package\PackageInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; /** * Base downloader for file packages @@ -24,20 +23,17 @@ use Symfony\Component\Console\Input\InputInterface; */ abstract class FileDownloader implements DownloaderInterface { - protected $intput; - protected $output; + protected $wrapper; protected $bytesMax; /** * Constructor. * - * @param InputInterface $input The Input instance - * @param OutputInterface $output The Output instance + * @param WrapperInterface $wrapper The Wrapper instance */ - public function __construct(InputInterface $input, OutputInterface $output) + public function __construct(WrapperInterface $wrapper) { - $this->intput = $input; - $this->output = $output; + $this->wrapper = $wrapper; } /** @@ -70,7 +66,7 @@ abstract class FileDownloader implements DownloaderInterface $fileName = rtrim($path.'/'.md5(time().rand()).'.'.pathinfo($url, PATHINFO_EXTENSION), '.'); - $this->output->writeln(" - Package " . $package->getName() . " (" . $package->getPrettyVersion() . ")"); + $this->wrapper->getOutput()->writeln(" - Package " . $package->getName() . " (" . $package->getPrettyVersion() . ")"); if (!extension_loaded('openssl') && (0 === strpos($url, 'https:') || 0 === strpos($url, 'http://github.com'))) { // bypass https for github if openssl is disabled @@ -104,8 +100,7 @@ abstract class FileDownloader implements DownloaderInterface copy($url, $fileName, $ctx); - $this->output->overwrite(" Downloading: OK", 80); - $this->writeln(''); + $this->wrapper->overwriteln(" Downloading: OK", 80); if (!file_exists($fileName)) { throw new \UnexpectedValueException($url.' could not be saved to '.$fileName.', make sure the' @@ -116,11 +111,11 @@ abstract class FileDownloader implements DownloaderInterface throw new \UnexpectedValueException('The checksum verification of the archive failed (downloaded from '.$url.')'); } - $this->output->writeln(' Unpacking archive'); + $this->wrapper->getOutput()->writeln(' Unpacking archive'); $this->extract($fileName, $path); - $this->output->writeln(' Cleaning up'); + $this->wrapper->getOutput()->writeln(' Cleaning up'); unlink($fileName); // If we have only a one dir inside it suppose to be a package itself @@ -135,8 +130,8 @@ abstract class FileDownloader implements DownloaderInterface rmdir($contentDir); } - $this->output->overwrite(''); - $this->output->writeln(''); + $this->wrapper->overwrite(''); + $this->wrapper->getOutput()->writeln(''); } /** @@ -195,7 +190,7 @@ abstract class FileDownloader implements DownloaderInterface $progression = round($progression, 0); if (in_array($progression, $levels)) { - $this->output->overwrite(" Downloading: $progression%", 80); + $this->wrapper->overwrite(" Downloading: $progression%", 80); } } diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 8a78af773..fadfd6a7c 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -15,25 +15,17 @@ namespace Composer\Repository; use Composer\Package\Loader\ArrayLoader; use Composer\Package\LinkConstraint\VersionConstraint; use Composer\Json\JsonFile; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; /** * @author Jordi Boggiano - * @author François Pluchino */ class ComposerRepository extends ArrayRepository { protected $url; protected $packages; - protected $input; - protected $output; - public function __construct(InputInterface $input, OutputInterface $output, array $config) + public function __construct(array $config) { - $this->input = $input; - $this->output = $output; - if (!preg_match('{^\w+://}', $config['url'])) { // assume http as the default protocol $config['url'] = 'http://'.$config['url']; diff --git a/src/Composer/Repository/PackageRepository.php b/src/Composer/Repository/PackageRepository.php index 113e8c0b7..01b1b24c2 100644 --- a/src/Composer/Repository/PackageRepository.php +++ b/src/Composer/Repository/PackageRepository.php @@ -16,33 +16,24 @@ use Composer\Json\JsonFile; use Composer\Package\PackageInterface; use Composer\Package\Loader\ArrayLoader; use Composer\Package\Dumper\ArrayDumper; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; /** * Package repository. * * @author Jordi Boggiano - * @author François Pluchino */ class PackageRepository extends ArrayRepository { private $config; - private $input; - private $output; /** * Initializes filesystem repository. * - * @param InputInterface $input The Input instance - * @param OutputInterface $output The Output instance - * @param array $config package definition + * @param array $config package definition */ - public function __construct(InputInterface $input, OutputInterface $output, array $config) + public function __construct(array $config) { $this->config = $config; - $this->input = $input; - $this->output = $output; } /** diff --git a/src/Composer/Repository/PearRepository.php b/src/Composer/Repository/PearRepository.php index ae26e5579..b19620b3a 100644 --- a/src/Composer/Repository/PearRepository.php +++ b/src/Composer/Repository/PearRepository.php @@ -13,21 +13,16 @@ namespace Composer\Repository; use Composer\Package\Loader\ArrayLoader; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; /** * @author Benjamin Eberlei * @author Jordi Boggiano - * @author François Pluchino */ class PearRepository extends ArrayRepository { protected $url; - private $input; - private $output; - public function __construct(InputInterface $input, OutputInterface $output, array $config) + public function __construct(array $config) { if (!preg_match('{^https?://}', $config['url'])) { $config['url'] = 'http://'.$config['url']; @@ -37,8 +32,6 @@ class PearRepository extends ArrayRepository } $this->url = $config['url']; - $this->input = $input; - $this->output = $output; } protected function initialize() diff --git a/src/Composer/Repository/RepositoryManager.php b/src/Composer/Repository/RepositoryManager.php index 1157ae493..b6c902b6a 100644 --- a/src/Composer/Repository/RepositoryManager.php +++ b/src/Composer/Repository/RepositoryManager.php @@ -12,8 +12,7 @@ namespace Composer\Repository; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use Composer\Console\Helper\WrapperInterface; /** * Repositories manager. @@ -27,13 +26,11 @@ class RepositoryManager private $localRepository; private $repositories = array(); private $repositoryClasses = array(); - private $input; - private $output; + private $wrapper; - public function __construct(InputInterface $input, OutputInterface $output) + public function __construct(WrapperInterface $wrapper) { - $this->input = $input; - $this->output = $output; + $this->wrapper = $wrapper; } /** @@ -78,7 +75,7 @@ class RepositoryManager } $class = $this->repositoryClasses[$type]; - return new $class($this->input, $this->output, $config); + return new $class($config, $this->wrapper); } /** diff --git a/src/Composer/Repository/Vcs/GitBitbucketDriver.php b/src/Composer/Repository/Vcs/GitBitbucketDriver.php index 19a418515..01e90bc89 100644 --- a/src/Composer/Repository/Vcs/GitBitbucketDriver.php +++ b/src/Composer/Repository/Vcs/GitBitbucketDriver.php @@ -13,8 +13,7 @@ namespace Composer\Repository\Vcs; use Composer\Json\JsonFile; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use Composer\Console\Helper\WrapperInterface; /** * @author Per Bernhardt @@ -29,13 +28,13 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface protected $rootIdentifier; protected $infoCache = array(); - public function __construct($url, InputInterface $input, OutputInterface $output) + public function __construct($url, WrapperInterface $wrapper) { preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)\.git$#', $url, $match); $this->owner = $match[1]; $this->repository = $match[2]; - parent::__construct($url, $input, $output); + parent::__construct($url, $wrapper); } /** diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index 09afc0c8e..971b13f73 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -3,8 +3,7 @@ namespace Composer\Repository\Vcs; use Composer\Json\JsonFile; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use Composer\Console\Helper\WrapperInterface; /** * @author Jordi Boggiano @@ -17,11 +16,11 @@ class GitDriver extends VcsDriver implements VcsDriverInterface protected $rootIdentifier; protected $infoCache = array(); - public function __construct($url, InputInterface $input, OutputInterface $output) + public function __construct($url, WrapperInterface $wrapper) { $this->tmpDir = sys_get_temp_dir() . '/composer-' . preg_replace('{[^a-z0-9]}i', '-', $url) . '/'; - parent::__construct($url, $input, $output); + parent::__construct($url, $wrapper); } /** diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index 841be35f6..35f1f2737 100644 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -3,8 +3,7 @@ namespace Composer\Repository\Vcs; use Composer\Json\JsonFile; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use Composer\Console\Helper\WrapperInterface; /** * @author Jordi Boggiano @@ -19,13 +18,13 @@ class GitHubDriver extends VcsDriver implements VcsDriverInterface protected $rootIdentifier; protected $infoCache = array(); - public function __construct($url, InputInterface $input, OutputInterface $output) + public function __construct($url, WrapperInterface $wrapper) { preg_match('#^(?:https?|git)://github\.com/([^/]+)/(.+?)(?:\.git)?$#', $url, $match); $this->owner = $match[1]; $this->repository = $match[2]; - parent::__construct($url, $input, $output); + parent::__construct($url, $wrapper); } /** diff --git a/src/Composer/Repository/Vcs/HgBitbucketDriver.php b/src/Composer/Repository/Vcs/HgBitbucketDriver.php index 15b2d4660..2b7908c37 100644 --- a/src/Composer/Repository/Vcs/HgBitbucketDriver.php +++ b/src/Composer/Repository/Vcs/HgBitbucketDriver.php @@ -13,8 +13,7 @@ namespace Composer\Repository\Vcs; use Composer\Json\JsonFile; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use Composer\Console\Helper\WrapperInterface; /** * @author Per Bernhardt @@ -29,13 +28,13 @@ class HgBitbucketDriver extends VcsDriver implements VcsDriverInterface protected $rootIdentifier; protected $infoCache = array(); - public function __construct($url, InputInterface $input, OutputInterface $output) + public function __construct($url, WrapperInterface $wrapper) { preg_match('#^https://bitbucket\.org/([^/]+)/([^/]+)/?$#', $url, $match); $this->owner = $match[1]; $this->repository = $match[2]; - parent::__construct($url, $input, $output); + parent::__construct($url, $wrapper); } /** diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php index 366cd7b88..928723a46 100644 --- a/src/Composer/Repository/Vcs/HgDriver.php +++ b/src/Composer/Repository/Vcs/HgDriver.php @@ -13,8 +13,7 @@ namespace Composer\Repository\Vcs; use Composer\Json\JsonFile; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use Composer\Console\Helper\WrapperInterface; /** * @author Per Bernhardt @@ -27,11 +26,11 @@ class HgDriver extends VcsDriver implements VcsDriverInterface protected $rootIdentifier; protected $infoCache = array(); - public function __construct($url, InputInterface $input, OutputInterface $output) + public function __construct($url, WrapperInterface $wrapper) { $this->tmpDir = sys_get_temp_dir() . '/composer-' . preg_replace('{[^a-z0-9]}i', '-', $url) . '/'; - parent::__construct($url, $input, $output); + parent::__construct($url, $wrapper); } /** diff --git a/src/Composer/Repository/Vcs/SvnDriver.php b/src/Composer/Repository/Vcs/SvnDriver.php index f6a27feac..9d2941d0e 100644 --- a/src/Composer/Repository/Vcs/SvnDriver.php +++ b/src/Composer/Repository/Vcs/SvnDriver.php @@ -3,8 +3,7 @@ namespace Composer\Repository\Vcs; use Composer\Json\JsonFile; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use Composer\Console\Helper\WrapperInterface; /** * @author Jordi Boggiano @@ -17,9 +16,9 @@ class SvnDriver extends VcsDriver implements VcsDriverInterface protected $branches; protected $infoCache = array(); - public function __construct($url, InputInterface $input, OutputInterface $output) + public function __construct($url, WrapperInterface $wrapper) { - parent::__construct($this->baseUrl = rtrim($url, '/'), $input, $output); + parent::__construct($this->baseUrl = rtrim($url, '/'), $wrapper); if (false !== ($pos = strrpos($url, '/trunk'))) { $this->baseUrl = substr($url, 0, $pos); diff --git a/src/Composer/Repository/Vcs/VcsDriver.php b/src/Composer/Repository/Vcs/VcsDriver.php index 98650d4f3..3c0682f6e 100644 --- a/src/Composer/Repository/Vcs/VcsDriver.php +++ b/src/Composer/Repository/Vcs/VcsDriver.php @@ -13,32 +13,28 @@ namespace Composer\Repository\Vcs; /** - * A driver implementation + * A driver implementation for driver with authentification interaction. * * @author François Pluchino */ -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use Composer\Console\Helper\WrapperInterface; abstract class VcsDriver { protected $url; - protected $input; - protected $output; + protected $wrapper; /** - * Constructor + * Constructor. * - * @param string $url The URL - * @param InputInterface $input The Input instance - * @param OutputInterface $output The output instance + * @param string $url The URL + * @param WrapperInterface $wrapper The Wrapper instance */ - public function __construct($url, InputInterface $input, OutputInterface $output) + public function __construct($url, WrapperInterface $wrapper) { $this->url = $url; - $this->input = $input; - $this->output = $output; + $this->wrapper = $wrapper; } /** diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index 52802c5a5..b1f43a28c 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/src/Composer/Repository/VcsRepository.php @@ -5,8 +5,7 @@ namespace Composer\Repository; use Composer\Repository\Vcs\VcsDriverInterface; use Composer\Package\Version\VersionParser; use Composer\Package\Loader\ArrayLoader; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Input\InputInterface; +use Composer\Console\Helper\WrapperInterface; /** * @author Jordi Boggiano @@ -17,10 +16,9 @@ class VcsRepository extends ArrayRepository protected $url; protected $packageName; protected $debug; - protected $input; - protected $output; + protected $wrapper; - public function __construct(InputInterface $input, OutputInterface $output, array $config, array $drivers = null) + public function __construct(WrapperInterface $wrapper, array $config, array $drivers = null) { if (!filter_var($config['url'], FILTER_VALIDATE_URL)) { throw new \UnexpectedValueException('Invalid url given for PEAR repository: '.$config['url']); @@ -36,8 +34,7 @@ class VcsRepository extends ArrayRepository ); $this->url = $config['url']; - $this->input = $input; - $this->output = $output; + $this->wrapper = $wrapper; } public function setDebug($debug) @@ -49,7 +46,7 @@ class VcsRepository extends ArrayRepository { foreach ($this->drivers as $driver) { if ($driver::supports($this->url)) { - $driver = new $driver($this->url, $this->input, $this->output); + $driver = new $driver($this->url, $this->wrapper); $driver->initialize(); return $driver; } @@ -57,7 +54,7 @@ class VcsRepository extends ArrayRepository foreach ($this->drivers as $driver) { if ($driver::supports($this->url, true)) { - $driver = new $driver($this->url); + $driver = new $driver($this->url, $this->wrapper); $driver->initialize(); return $driver; }