Commit 3231fbd3 authored by Fabien Potencier's avatar Fabien Potencier Committed by Benjamin Eberlei

Update Symfony\Component\Console to latest version

parent 5cd66217
...@@ -50,7 +50,7 @@ class RunSqlCommand extends Console\Command\Command ...@@ -50,7 +50,7 @@ class RunSqlCommand extends Console\Command\Command
->setDescription('Executes arbitrary SQL directly from the command line.') ->setDescription('Executes arbitrary SQL directly from the command line.')
->setDefinition(array( ->setDefinition(array(
new InputArgument('sql', InputArgument::REQUIRED, 'The SQL statement to execute.'), new InputArgument('sql', InputArgument::REQUIRED, 'The SQL statement to execute.'),
new InputOption('depth', null, InputOption::PARAMETER_REQUIRED, 'Dumping depth of result set.', 7) new InputOption('depth', null, InputOption::VALUE_REQUIRED, 'Dumping depth of result set.', 7)
)) ))
->setHelp(<<<EOT ->setHelp(<<<EOT
Executes arbitrary SQL directly from the command line. Executes arbitrary SQL directly from the command line.
......
...@@ -37,7 +37,7 @@ use Symfony\Component\Console\Helper\DialogHelper; ...@@ -37,7 +37,7 @@ use Symfony\Component\Console\Helper\DialogHelper;
* Usage: * Usage:
* *
* $app = new Application('myapp', '1.0 (stable)'); * $app = new Application('myapp', '1.0 (stable)');
* $app->addCommand(new SimpleCommand()); * $app->add(new SimpleCommand());
* $app->run(); * $app->run();
* *
* @author Fabien Potencier <fabien.potencier@symfony-project.com> * @author Fabien Potencier <fabien.potencier@symfony-project.com>
...@@ -74,18 +74,18 @@ class Application ...@@ -74,18 +74,18 @@ class Application
new DialogHelper(), new DialogHelper(),
)); ));
$this->addCommand(new HelpCommand()); $this->add(new HelpCommand());
$this->addCommand(new ListCommand()); $this->add(new ListCommand());
$this->definition = new InputDefinition(array( $this->definition = new InputDefinition(array(
new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'), new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
new InputOption('--help', '-h', InputOption::PARAMETER_NONE, 'Display this help message.'), new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message.'),
new InputOption('--quiet', '-q', InputOption::PARAMETER_NONE, 'Do not output any message.'), new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message.'),
new InputOption('--verbose', '-v', InputOption::PARAMETER_NONE, 'Increase verbosity of messages.'), new InputOption('--verbose', '-v', InputOption::VALUE_NONE, 'Increase verbosity of messages.'),
new InputOption('--version', '-V', InputOption::PARAMETER_NONE, 'Display this program version.'), new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this program version.'),
new InputOption('--ansi', '-a', InputOption::PARAMETER_NONE, 'Force ANSI output.'), new InputOption('--ansi', '-a', InputOption::VALUE_NONE, 'Force ANSI output.'),
new InputOption('--no-interaction', '-n', InputOption::PARAMETER_NONE, 'Do not ask any interactive question.'), new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question.'),
)); ));
} }
...@@ -181,7 +181,7 @@ class Application ...@@ -181,7 +181,7 @@ class Application
} }
// the command name MUST be the first element of the input // the command name MUST be the first element of the input
$command = $this->findCommand($name); $command = $this->find($name);
$this->runningCommand = $command; $this->runningCommand = $command;
$statusCode = $command->run($input, $output); $statusCode = $command->run($input, $output);
...@@ -329,7 +329,7 @@ class Application ...@@ -329,7 +329,7 @@ class Application
*/ */
public function register($name) public function register($name)
{ {
return $this->addCommand(new Command($name)); return $this->add(new Command($name));
} }
/** /**
...@@ -340,7 +340,7 @@ class Application ...@@ -340,7 +340,7 @@ class Application
public function addCommands(array $commands) public function addCommands(array $commands)
{ {
foreach ($commands as $command) { foreach ($commands as $command) {
$this->addCommand($command); $this->add($command);
} }
} }
...@@ -353,7 +353,7 @@ class Application ...@@ -353,7 +353,7 @@ class Application
* *
* @return Command The registered command * @return Command The registered command
*/ */
public function addCommand(Command $command) public function add(Command $command)
{ {
$command->setApplication($this); $command->setApplication($this);
...@@ -375,7 +375,7 @@ class Application ...@@ -375,7 +375,7 @@ class Application
* *
* @throws \InvalidArgumentException When command name given does not exist * @throws \InvalidArgumentException When command name given does not exist
*/ */
public function getCommand($name) public function get($name)
{ {
if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
throw new \InvalidArgumentException(sprintf('The command "%s" does not exist.', $name)); throw new \InvalidArgumentException(sprintf('The command "%s" does not exist.', $name));
...@@ -386,7 +386,7 @@ class Application ...@@ -386,7 +386,7 @@ class Application
if ($this->wantHelps) { if ($this->wantHelps) {
$this->wantHelps = false; $this->wantHelps = false;
$helpCommand = $this->getCommand('help'); $helpCommand = $this->get('help');
$helpCommand->setCommand($command); $helpCommand->setCommand($command);
return $helpCommand; return $helpCommand;
...@@ -402,7 +402,7 @@ class Application ...@@ -402,7 +402,7 @@ class Application
* *
* @return Boolean true if the command exists, false otherwise * @return Boolean true if the command exists, false otherwise
*/ */
public function hasCommand($name) public function has($name)
{ {
return isset($this->commands[$name]) || isset($this->aliases[$name]); return isset($this->commands[$name]) || isset($this->aliases[$name]);
} }
...@@ -451,7 +451,7 @@ class Application ...@@ -451,7 +451,7 @@ class Application
/** /**
* Finds a command by name or alias. * Finds a command by name or alias.
* *
* Contrary to getCommand, this command tries to find the best * Contrary to get, this command tries to find the best
* match if you give it an abbreviation of a name or alias. * match if you give it an abbreviation of a name or alias.
* *
* @param string $name A command name or a command alias * @param string $name A command name or a command alias
...@@ -460,7 +460,7 @@ class Application ...@@ -460,7 +460,7 @@ class Application
* *
* @throws \InvalidArgumentException When command name is incorrect or ambiguous * @throws \InvalidArgumentException When command name is incorrect or ambiguous
*/ */
public function findCommand($name) public function find($name)
{ {
// namespace // namespace
$namespace = ''; $namespace = '';
...@@ -481,7 +481,7 @@ class Application ...@@ -481,7 +481,7 @@ class Application
$abbrevs = static::getAbbreviations($commands); $abbrevs = static::getAbbreviations($commands);
if (isset($abbrevs[$name]) && 1 == count($abbrevs[$name])) { if (isset($abbrevs[$name]) && 1 == count($abbrevs[$name])) {
return $this->getCommand($namespace ? $namespace.':'.$abbrevs[$name][0] : $abbrevs[$name][0]); return $this->get($namespace ? $namespace.':'.$abbrevs[$name][0] : $abbrevs[$name][0]);
} }
if (isset($abbrevs[$name]) && count($abbrevs[$name]) > 1) { if (isset($abbrevs[$name]) && count($abbrevs[$name]) > 1) {
...@@ -500,7 +500,7 @@ class Application ...@@ -500,7 +500,7 @@ class Application
throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $fullName, $this->getAbbreviationSuggestions($abbrevs[$fullName]))); throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $fullName, $this->getAbbreviationSuggestions($abbrevs[$fullName])));
} }
return $this->getCommand($abbrevs[$fullName][0]); return $this->get($abbrevs[$fullName][0]);
} }
/** /**
...@@ -512,7 +512,7 @@ class Application ...@@ -512,7 +512,7 @@ class Application
* *
* @return array An array of Command instances * @return array An array of Command instances
*/ */
public function getCommands($namespace = null) public function all($namespace = null)
{ {
if (null === $namespace) { if (null === $namespace) {
return $this->commands; return $this->commands;
...@@ -566,7 +566,7 @@ class Application ...@@ -566,7 +566,7 @@ class Application
*/ */
public function asText($namespace = null) public function asText($namespace = null)
{ {
$commands = $namespace ? $this->getCommands($this->findNamespace($namespace)) : $this->commands; $commands = $namespace ? $this->all($this->findNamespace($namespace)) : $this->commands;
$messages = array($this->getHelp(), ''); $messages = array($this->getHelp(), '');
if ($namespace) { if ($namespace) {
...@@ -607,7 +607,7 @@ class Application ...@@ -607,7 +607,7 @@ class Application
*/ */
public function asXml($namespace = null, $asDom = false) public function asXml($namespace = null, $asDom = false)
{ {
$commands = $namespace ? $this->getCommands($this->findNamespace($namespace)) : $this->commands; $commands = $namespace ? $this->all($this->findNamespace($namespace)) : $this->commands;
$dom = new \DOMDocument('1.0', 'UTF-8'); $dom = new \DOMDocument('1.0', 'UTF-8');
$dom->formatOutput = true; $dom->formatOutput = true;
......
...@@ -236,9 +236,9 @@ class Command ...@@ -236,9 +236,9 @@ class Command
* *
* @param string $name The option name * @param string $name The option name
* @param string $shortcut The shortcut (can be null) * @param string $shortcut The shortcut (can be null)
* @param integer $mode The option mode: self::PARAMETER_REQUIRED, self::PARAMETER_NONE or self::PARAMETER_OPTIONAL * @param integer $mode The option mode: One of the InputOption::VALUE_* constants
* @param string $description A description text * @param string $description A description text
* @param mixed $default The default value (must be null for self::PARAMETER_REQUIRED or self::PARAMETER_NONE) * @param mixed $default The default value (must be null for InputOption::VALUE_REQUIRED or self::VALUE_NONE)
* *
* @return Command The current instance * @return Command The current instance
*/ */
......
...@@ -37,7 +37,7 @@ class HelpCommand extends Command ...@@ -37,7 +37,7 @@ class HelpCommand extends Command
$this $this
->setDefinition(array( ->setDefinition(array(
new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'), new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
new InputOption('xml', null, InputOption::PARAMETER_NONE, 'To output help as XML'), new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
)) ))
->setName('help') ->setName('help')
->setAliases(array('?')) ->setAliases(array('?'))
...@@ -65,7 +65,7 @@ EOF ...@@ -65,7 +65,7 @@ EOF
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
if (null === $this->command) { if (null === $this->command) {
$this->command = $this->application->getCommand($input->getArgument('command_name')); $this->command = $this->application->get($input->getArgument('command_name'));
} }
if ($input->getOption('xml')) { if ($input->getOption('xml')) {
......
...@@ -33,7 +33,7 @@ class ListCommand extends Command ...@@ -33,7 +33,7 @@ class ListCommand extends Command
$this $this
->setDefinition(array( ->setDefinition(array(
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
new InputOption('xml', null, InputOption::PARAMETER_NONE, 'To output help as XML'), new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
)) ))
->setName('list') ->setName('list')
->setDescription('Lists commands') ->setDescription('Lists commands')
......
...@@ -88,7 +88,7 @@ class ArgvInput extends Input ...@@ -88,7 +88,7 @@ class ArgvInput extends Input
$name = substr($token, 1); $name = substr($token, 1);
if (strlen($name) > 1) { if (strlen($name) > 1) {
if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptParameter()) { if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
// an option with a value (with no space) // an option with a value (with no space)
$this->addShortOption($name[0], substr($name, 1)); $this->addShortOption($name[0], substr($name, 1));
} else { } else {
...@@ -115,7 +115,7 @@ class ArgvInput extends Input ...@@ -115,7 +115,7 @@ class ArgvInput extends Input
} }
$option = $this->definition->getOptionForShortcut($name[$i]); $option = $this->definition->getOptionForShortcut($name[$i]);
if ($option->acceptParameter()) { if ($option->acceptValue()) {
$this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1)); $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
break; break;
...@@ -190,7 +190,7 @@ class ArgvInput extends Input ...@@ -190,7 +190,7 @@ class ArgvInput extends Input
$option = $this->definition->getOption($name); $option = $this->definition->getOption($name);
if (null === $value && $option->acceptParameter()) { if (null === $value && $option->acceptValue()) {
// if option accepts an optional or mandatory argument // if option accepts an optional or mandatory argument
// let's see if there is one provided // let's see if there is one provided
$next = array_shift($this->parsed); $next = array_shift($this->parsed);
...@@ -202,11 +202,11 @@ class ArgvInput extends Input ...@@ -202,11 +202,11 @@ class ArgvInput extends Input
} }
if (null === $value) { if (null === $value) {
if ($option->isParameterRequired()) { if ($option->isValueRequired()) {
throw new \RuntimeException(sprintf('The "--%s" option requires a value.', $name)); throw new \RuntimeException(sprintf('The "--%s" option requires a value.', $name));
} }
$value = $option->isParameterOptional() ? $option->getDefault() : true; $value = $option->isValueOptional() ? $option->getDefault() : true;
} }
$this->options[$name] = $value; $this->options[$name] = $value;
......
...@@ -133,11 +133,11 @@ class ArrayInput extends Input ...@@ -133,11 +133,11 @@ class ArrayInput extends Input
$option = $this->definition->getOption($name); $option = $this->definition->getOption($name);
if (null === $value) { if (null === $value) {
if ($option->isParameterRequired()) { if ($option->isValueRequired()) {
throw new \InvalidArgumentException(sprintf('The "--%s" option requires a value.', $name)); throw new \InvalidArgumentException(sprintf('The "--%s" option requires a value.', $name));
} }
$value = $option->isParameterOptional() ? $option->getDefault() : true; $value = $option->isValueOptional() ? $option->getDefault() : true;
} }
$this->options[$name] = $value; $this->options[$name] = $value;
......
...@@ -18,7 +18,7 @@ namespace Symfony\Component\Console\Input; ...@@ -18,7 +18,7 @@ namespace Symfony\Component\Console\Input;
* *
* $definition = new InputDefinition(array( * $definition = new InputDefinition(array(
* new InputArgument('name', InputArgument::REQUIRED), * new InputArgument('name', InputArgument::REQUIRED),
* new InputOption('foo', 'f', InputOption::PARAMETER_REQUIRED), * new InputOption('foo', 'f', InputOption::VALUE_REQUIRED),
* )); * ));
* *
* @author Fabien Potencier <fabien.potencier@symfony-project.com> * @author Fabien Potencier <fabien.potencier@symfony-project.com>
...@@ -347,7 +347,7 @@ class InputDefinition ...@@ -347,7 +347,7 @@ class InputDefinition
$elements = array(); $elements = array();
foreach ($this->getOptions() as $option) { foreach ($this->getOptions() as $option) {
$shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : ''; $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
$elements[] = sprintf('['.($option->isParameterRequired() ? '%s--%s="..."' : ($option->isParameterOptional() ? '%s--%s[="..."]' : '%s--%s')).']', $shortcut, $option->getName()); $elements[] = sprintf('['.($option->isValueRequired() ? '%s--%s="..."' : ($option->isValueOptional() ? '%s--%s[="..."]' : '%s--%s')).']', $shortcut, $option->getName());
} }
foreach ($this->getArguments() as $argument) { foreach ($this->getArguments() as $argument) {
...@@ -399,7 +399,7 @@ class InputDefinition ...@@ -399,7 +399,7 @@ class InputDefinition
$text[] = '<comment>Options:</comment>'; $text[] = '<comment>Options:</comment>';
foreach ($this->getOptions() as $option) { foreach ($this->getOptions() as $option) {
if ($option->acceptParameter() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) { if ($option->acceptValue() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) {
$default = sprintf('<comment> (default: %s)</comment>', is_array($option->getDefault()) ? str_replace("\n", '', print_r($option->getDefault(), true)): $option->getDefault()); $default = sprintf('<comment> (default: %s)</comment>', is_array($option->getDefault()) ? str_replace("\n", '', print_r($option->getDefault(), true)): $option->getDefault());
} else { } else {
$default = ''; $default = '';
...@@ -450,13 +450,13 @@ class InputDefinition ...@@ -450,13 +450,13 @@ class InputDefinition
$optionsXML->appendChild($optionXML = $dom->createElement('option')); $optionsXML->appendChild($optionXML = $dom->createElement('option'));
$optionXML->setAttribute('name', '--'.$option->getName()); $optionXML->setAttribute('name', '--'.$option->getName());
$optionXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : ''); $optionXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
$optionXML->setAttribute('accept_parameter', $option->acceptParameter() ? 1 : 0); $optionXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0);
$optionXML->setAttribute('is_parameter_required', $option->isParameterRequired() ? 1 : 0); $optionXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0);
$optionXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0); $optionXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0);
$optionXML->appendChild($descriptionXML = $dom->createElement('description')); $optionXML->appendChild($descriptionXML = $dom->createElement('description'));
$descriptionXML->appendChild($dom->createTextNode($option->getDescription())); $descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
if ($option->acceptParameter()) { if ($option->acceptValue()) {
$optionXML->appendChild($defaultsXML = $dom->createElement('defaults')); $optionXML->appendChild($defaultsXML = $dom->createElement('defaults'));
$defaults = is_array($option->getDefault()) ? $option->getDefault() : ($option->getDefault() ? array($option->getDefault()) : array()); $defaults = is_array($option->getDefault()) ? $option->getDefault() : ($option->getDefault() ? array($option->getDefault()) : array());
foreach ($defaults as $default) { foreach ($defaults as $default) {
......
...@@ -18,10 +18,10 @@ namespace Symfony\Component\Console\Input; ...@@ -18,10 +18,10 @@ namespace Symfony\Component\Console\Input;
*/ */
class InputOption class InputOption
{ {
const PARAMETER_NONE = 1; const VALUE_NONE = 1;
const PARAMETER_REQUIRED = 2; const VALUE_REQUIRED = 2;
const PARAMETER_OPTIONAL = 4; const VALUE_OPTIONAL = 4;
const PARAMETER_IS_ARRAY = 8; const VALUE_IS_ARRAY = 8;
protected $name; protected $name;
protected $shortcut; protected $shortcut;
...@@ -34,9 +34,9 @@ class InputOption ...@@ -34,9 +34,9 @@ class InputOption
* *
* @param string $name The option name * @param string $name The option name
* @param string $shortcut The shortcut (can be null) * @param string $shortcut The shortcut (can be null)
* @param integer $mode The option mode: self::PARAMETER_REQUIRED, self::PARAMETER_NONE or self::PARAMETER_OPTIONAL * @param integer $mode The option mode: One of the VALUE_* constants
* @param string $description A description text * @param string $description A description text
* @param mixed $default The default value (must be null for self::PARAMETER_REQUIRED or self::PARAMETER_NONE) * @param mixed $default The default value (must be null for self::VALUE_REQUIRED or self::VALUE_NONE)
* *
* @throws \InvalidArgumentException If option mode is invalid or incompatible * @throws \InvalidArgumentException If option mode is invalid or incompatible
*/ */
...@@ -57,7 +57,7 @@ class InputOption ...@@ -57,7 +57,7 @@ class InputOption
} }
if (null === $mode) { if (null === $mode) {
$mode = self::PARAMETER_NONE; $mode = self::VALUE_NONE;
} else if (!is_int($mode) || $mode > 15) { } else if (!is_int($mode) || $mode > 15) {
throw new \InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode)); throw new \InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
} }
...@@ -67,8 +67,8 @@ class InputOption ...@@ -67,8 +67,8 @@ class InputOption
$this->mode = $mode; $this->mode = $mode;
$this->description = $description; $this->description = $description;
if ($this->isArray() && !$this->acceptParameter()) { if ($this->isArray() && !$this->acceptValue()) {
throw new \InvalidArgumentException('Impossible to have an option mode PARAMETER_IS_ARRAY if the option does not accept a parameter.'); throw new \InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
} }
$this->setDefault($default); $this->setDefault($default);
...@@ -95,43 +95,43 @@ class InputOption ...@@ -95,43 +95,43 @@ class InputOption
} }
/** /**
* Returns true if the option accept a parameter. * Returns true if the option accepts a value.
* *
* @return Boolean true if parameter mode is not self::PARAMETER_NONE, false otherwise * @return Boolean true if value mode is not self::VALUE_NONE, false otherwise
*/ */
public function acceptParameter() public function acceptValue()
{ {
return $this->isParameterRequired() || $this->isParameterOptional(); return $this->isValueRequired() || $this->isValueOptional();
} }
/** /**
* Returns true if the option requires a parameter. * Returns true if the option requires a value.
* *
* @return Boolean true if parameter mode is self::PARAMETER_REQUIRED, false otherwise * @return Boolean true if value mode is self::VALUE_REQUIRED, false otherwise
*/ */
public function isParameterRequired() public function isValueRequired()
{ {
return self::PARAMETER_REQUIRED === (self::PARAMETER_REQUIRED & $this->mode); return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
} }
/** /**
* Returns true if the option takes an optional parameter. * Returns true if the option takes an optional value.
* *
* @return Boolean true if parameter mode is self::PARAMETER_OPTIONAL, false otherwise * @return Boolean true if value mode is self::VALUE_OPTIONAL, false otherwise
*/ */
public function isParameterOptional() public function isValueOptional()
{ {
return self::PARAMETER_OPTIONAL === (self::PARAMETER_OPTIONAL & $this->mode); return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
} }
/** /**
* Returns true if the option can take multiple values. * Returns true if the option can take multiple values.
* *
* @return Boolean true if mode is self::PARAMETER_IS_ARRAY, false otherwise * @return Boolean true if mode is self::VALUE_IS_ARRAY, false otherwise
*/ */
public function isArray() public function isArray()
{ {
return self::PARAMETER_IS_ARRAY === (self::PARAMETER_IS_ARRAY & $this->mode); return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
} }
/** /**
...@@ -141,8 +141,8 @@ class InputOption ...@@ -141,8 +141,8 @@ class InputOption
*/ */
public function setDefault($default = null) public function setDefault($default = null)
{ {
if (self::PARAMETER_NONE === (self::PARAMETER_NONE & $this->mode) && null !== $default) { if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
throw new \LogicException('Cannot set a default value when using Option::PARAMETER_NONE mode.'); throw new \LogicException('Cannot set a default value when using Option::VALUE_NONE mode.');
} }
if ($this->isArray()) { if ($this->isArray()) {
...@@ -153,7 +153,7 @@ class InputOption ...@@ -153,7 +153,7 @@ class InputOption
} }
} }
$this->default = $this->acceptParameter() ? $default : false; $this->default = $this->acceptValue() ? $default : false;
} }
/** /**
......
...@@ -97,7 +97,7 @@ class Shell ...@@ -97,7 +97,7 @@ class Shell
// task name? // task name?
if (false === strpos($text, ' ') || !$text) { if (false === strpos($text, ' ') || !$text) {
return array_keys($this->application->getCommands()); return array_keys($this->application->all());
} }
// options and arguments? // options and arguments?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment