Fix some improvements

main
François Pluchino 13 years ago
parent 0f9dcc9618
commit a5fb4abb36

@ -78,7 +78,7 @@ class Application extends BaseApplication
public function getComposer()
{
if (null === $this->composer) {
$this->composer = self::bootstrapComposer(null, $this->io);
$this->composer = self::bootstrapComposer($this->io);
}
return $this->composer;
@ -97,7 +97,7 @@ class Application extends BaseApplication
*
* @return Composer
*/
public static function bootstrapComposer($composerFile = null, IOInterface $io)
public static function bootstrapComposer(IOInterface $io, $composerFile = null)
{
// load Composer configuration
if (null === $composerFile) {

@ -12,10 +12,8 @@
namespace Composer\IO;
use Composer\IO\IOInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Helper\HelperSet;
@ -37,89 +35,17 @@ class ConsoleIO implements IOInterface
/**
* Constructor.
*
* @param InputInterface $input The input instance
* @param ConsoleOutputInterface $output The output instance
* @param HelperSet $helperSet The helperSet instance
* @param InputInterface $input The input instance
* @param OutputInterface $output The output instance
* @param HelperSet $helperSet The helperSet instance
*/
public function __construct(InputInterface $input, ConsoleOutputInterface $output, HelperSet $helperSet)
public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet)
{
$this->input = $input;
$this->output = $output;
$this->helperSet = $helperSet;
}
/**
* {@inheritDoc}
*/
public function getFirstArgument()
{
return $this->input->getFirstArgument();
}
/**
* {@inheritDoc}
*/
public function hasParameterOption($values)
{
return $this->input->hasParameterOption($values);
}
/**
* {@inheritDoc}
*/
public function getParameterOption($values, $default = false)
{
return $this->input->getParameterOption($values, $default);
}
/**
* {@inheritDoc}
*/
public function bind(InputDefinition $definition)
{
$this->input->bind($definition);
}
/**
* {@inheritDoc}
*/
public function validate()
{
$this->input->validate();
}
/**
* {@inheritDoc}
*/
public function getArguments()
{
return $this->input->getArguments();
}
/**
* {@inheritDoc}
*/
public function getArgument($name)
{
return $this->input->getArgument($name);
}
/**
* {@inheritDoc}
*/
public function getOptions()
{
return $this->input->getOptions();
}
/**
* {@inheritDoc}
*/
public function getOption($name)
{
return $this->input->getOption($name);
}
/**
* {@inheritDoc}
*/
@ -128,22 +54,6 @@ class ConsoleIO implements IOInterface
return $this->input->isInteractive();
}
/**
* {@inheritDoc}
*/
public function getErrorOutput()
{
return $this->output->getErrorOutput();
}
/**
* {@inheritDoc}
*/
public function setErrorOutput(OutputInterface $error)
{
$this->output->setErrorOutput($error);
}
/**
* {@inheritDoc}
*/
@ -290,7 +200,7 @@ class ConsoleIO implements IOInterface
}
// for other OS with shell_exec (hide the answer)
else if (rtrim(shell_exec($command)) === 'OK') {
if (rtrim(shell_exec($command)) === 'OK') {
$command = "/usr/bin/env bash -c 'echo OK'";
$this->write($question);

@ -12,8 +12,7 @@
namespace Composer\IO;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\HelperSet;
/**
@ -21,8 +20,17 @@ use Symfony\Component\Console\Helper\HelperSet;
*
* @author François Pluchino <francois.pluchino@opendisplay.com>
*/
interface IOInterface extends InputInterface, ConsoleOutputInterface
interface IOInterface extends OutputInterface
{
/**
* Is this input means interactive?
*
* @return Boolean
*/
function isInteractive();
/**
* Overwrites a previous message to the output.
*
@ -31,7 +39,7 @@ interface IOInterface extends InputInterface, ConsoleOutputInterface
* @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);
function overwrite($messages, $size = 80, $newline = false, $type = 0);
/**
* Overwrites a previous message to the output and adds a newline at the end.
@ -40,7 +48,7 @@ interface IOInterface extends InputInterface, ConsoleOutputInterface
* @param integer $size The size of line
* @param integer $type The type of output
*/
public function overwriteln($messages, $size = 80, $type = 0);
function overwriteln($messages, $size = 80, $type = 0);
/**
* Asks a question to the user.
@ -52,7 +60,7 @@ interface IOInterface extends InputInterface, ConsoleOutputInterface
*
* @throws \RuntimeException If there is no data to read in the input stream
*/
public function ask($question, $default = null);
function ask($question, $default = null);
/**
* Asks a confirmation to the user.
@ -64,7 +72,7 @@ interface IOInterface extends InputInterface, ConsoleOutputInterface
*
* @return Boolean true if the user has confirmed, false otherwise
*/
public function askConfirmation($question, $default = true);
function askConfirmation($question, $default = true);
/**
* Asks for a value and validates the response.
@ -82,7 +90,7 @@ interface IOInterface extends InputInterface, ConsoleOutputInterface
*
* @throws \Exception When any of the validators return an error
*/
public function askAndValidate($question, $validator, $attempts = false, $default = null);
function askAndValidate($question, $validator, $attempts = false, $default = null);
/**
* Asks a question to the user and hide the answer.
@ -91,28 +99,28 @@ interface IOInterface extends InputInterface, ConsoleOutputInterface
*
* @return string The answer
*/
public function askAndHideAnswer($question);
function askAndHideAnswer($question);
/**
* Get the last username entered.
*
* @return string The username
*/
public function getLastUsername();
function getLastUsername();
/**
* Get the last password entered.
*
* @return string The password
*/
public function getLastPassword();
function getLastPassword();
/**
* Get all authentification informations entered.
*
* @return array The map of authentification
*/
public function getAuthentifications();
function getAuthentifications();
/**
* Verify if the repository has a authentification informations.
@ -121,7 +129,7 @@ interface IOInterface extends InputInterface, ConsoleOutputInterface
*
* @return boolean
*/
public function hasAuthentification($repositoryName);
function hasAuthentification($repositoryName);
/**
* Get the username and password of repository.
@ -130,7 +138,7 @@ interface IOInterface extends InputInterface, ConsoleOutputInterface
*
* @return array The 'username' and 'password'
*/
public function getAuthentification($repositoryName);
function getAuthentification($repositoryName);
/**
* Set the authentification informations for the repository.
@ -139,5 +147,5 @@ interface IOInterface extends InputInterface, ConsoleOutputInterface
* @param string $username The username
* @param string $password The password
*/
public function setAuthentification($repositoryName, $username, $password = null);
function setAuthentification($repositoryName, $username, $password = null);
}

@ -122,8 +122,9 @@ abstract class VcsDriver
$this->io->setAuthentification($this->url, $username, $password);
return $this->getContents($url);
}
} else if (404 === $code) {
if (404 === $code) {
throw new \LogicException("The '$url' URL not found");
}

@ -2,8 +2,6 @@
namespace Composer\Repository\Vcs;
use Composer\Console\Helper\Wrapper;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>
*/

Loading…
Cancel
Save