Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes
This commit is contained in:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
21
vendor/symfony/console/Input/InputOption.php
vendored
21
vendor/symfony/console/Input/InputOption.php
vendored
|
@ -11,6 +11,9 @@
|
|||
|
||||
namespace Symfony\Component\Console\Input;
|
||||
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
|
||||
/**
|
||||
* Represents a command line option.
|
||||
*
|
||||
|
@ -36,9 +39,9 @@ class InputOption
|
|||
* @param string|array $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
|
||||
* @param int $mode The option mode: One of the VALUE_* constants
|
||||
* @param string $description A description text
|
||||
* @param mixed $default The default value (must be null for self::VALUE_REQUIRED or self::VALUE_NONE)
|
||||
* @param mixed $default The default value (must be null for self::VALUE_NONE)
|
||||
*
|
||||
* @throws \InvalidArgumentException If option mode is invalid or incompatible
|
||||
* @throws InvalidArgumentException If option mode is invalid or incompatible
|
||||
*/
|
||||
public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null)
|
||||
{
|
||||
|
@ -47,7 +50,7 @@ class InputOption
|
|||
}
|
||||
|
||||
if (empty($name)) {
|
||||
throw new \InvalidArgumentException('An option name cannot be empty.');
|
||||
throw new InvalidArgumentException('An option name cannot be empty.');
|
||||
}
|
||||
|
||||
if (empty($shortcut)) {
|
||||
|
@ -63,14 +66,14 @@ class InputOption
|
|||
$shortcut = implode('|', $shortcuts);
|
||||
|
||||
if (empty($shortcut)) {
|
||||
throw new \InvalidArgumentException('An option shortcut cannot be empty.');
|
||||
throw new InvalidArgumentException('An option shortcut cannot be empty.');
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $mode) {
|
||||
$mode = self::VALUE_NONE;
|
||||
} elseif (!is_int($mode) || $mode > 15 || $mode < 1) {
|
||||
throw new \InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
|
||||
throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
|
||||
}
|
||||
|
||||
$this->name = $name;
|
||||
|
@ -79,7 +82,7 @@ class InputOption
|
|||
$this->description = $description;
|
||||
|
||||
if ($this->isArray() && !$this->acceptValue()) {
|
||||
throw new \InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
|
||||
throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
|
||||
}
|
||||
|
||||
$this->setDefault($default);
|
||||
|
@ -150,19 +153,19 @@ class InputOption
|
|||
*
|
||||
* @param mixed $default The default value
|
||||
*
|
||||
* @throws \LogicException When incorrect default value is given
|
||||
* @throws LogicException When incorrect default value is given
|
||||
*/
|
||||
public function setDefault($default = null)
|
||||
{
|
||||
if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
|
||||
throw new \LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
|
||||
throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
|
||||
}
|
||||
|
||||
if ($this->isArray()) {
|
||||
if (null === $default) {
|
||||
$default = array();
|
||||
} elseif (!is_array($default)) {
|
||||
throw new \LogicException('A default value for an array option must be an array.');
|
||||
throw new LogicException('A default value for an array option must be an array.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue