mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-02 13:09:53 +09:00
Update to laravel 7
This commit is contained in:
80
vendor/symfony/console/Question/Question.php
vendored
80
vendor/symfony/console/Question/Question.php
vendored
@@ -29,10 +29,12 @@ class Question
|
||||
private $validator;
|
||||
private $default;
|
||||
private $normalizer;
|
||||
private $trimmable = true;
|
||||
private $multiline = false;
|
||||
|
||||
/**
|
||||
* @param string $question The question to ask to the user
|
||||
* @param mixed $default The default answer to return if the user enters nothing
|
||||
* @param string $question The question to ask to the user
|
||||
* @param string|bool|int|float|null $default The default answer to return if the user enters nothing
|
||||
*/
|
||||
public function __construct(string $question, $default = null)
|
||||
{
|
||||
@@ -53,13 +55,33 @@ class Question
|
||||
/**
|
||||
* Returns the default answer.
|
||||
*
|
||||
* @return mixed
|
||||
* @return string|bool|int|float|null
|
||||
*/
|
||||
public function getDefault()
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the user response accepts newline characters.
|
||||
*/
|
||||
public function isMultiline(): bool
|
||||
{
|
||||
return $this->multiline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the user response should accept newline characters.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMultiline(bool $multiline): self
|
||||
{
|
||||
$this->multiline = $multiline;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the user response must be hidden.
|
||||
*
|
||||
@@ -73,25 +95,23 @@ class Question
|
||||
/**
|
||||
* Sets whether the user response must be hidden or not.
|
||||
*
|
||||
* @param bool $hidden
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws LogicException In case the autocompleter is also used
|
||||
*/
|
||||
public function setHidden($hidden)
|
||||
public function setHidden(bool $hidden)
|
||||
{
|
||||
if ($this->autocompleterCallback) {
|
||||
throw new LogicException('A hidden question cannot use the autocompleter.');
|
||||
}
|
||||
|
||||
$this->hidden = (bool) $hidden;
|
||||
$this->hidden = $hidden;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* In case the response can not be hidden, whether to fallback on non-hidden question or not.
|
||||
* In case the response cannot be hidden, whether to fallback on non-hidden question or not.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -101,15 +121,13 @@ class Question
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to fallback on non-hidden question if the response can not be hidden.
|
||||
*
|
||||
* @param bool $fallback
|
||||
* Sets whether to fallback on non-hidden question if the response cannot be hidden.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHiddenFallback($fallback)
|
||||
public function setHiddenFallback(bool $fallback)
|
||||
{
|
||||
$this->hiddenFallback = (bool) $fallback;
|
||||
$this->hiddenFallback = $fallback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -129,14 +147,11 @@ class Question
|
||||
/**
|
||||
* Sets values for the autocompleter.
|
||||
*
|
||||
* @param iterable|null $values
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function setAutocompleterValues($values)
|
||||
public function setAutocompleterValues(?iterable $values)
|
||||
{
|
||||
if (\is_array($values)) {
|
||||
$values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
|
||||
@@ -149,10 +164,8 @@ class Question
|
||||
$callback = static function () use ($values, &$valueCache) {
|
||||
return $valueCache ?? $valueCache = iterator_to_array($values, false);
|
||||
};
|
||||
} elseif (null === $values) {
|
||||
$callback = null;
|
||||
} else {
|
||||
throw new InvalidArgumentException('Autocompleter values can be either an array, "null" or a "Traversable" object.');
|
||||
$callback = null;
|
||||
}
|
||||
|
||||
return $this->setAutocompleterCallback($callback);
|
||||
@@ -187,8 +200,6 @@ class Question
|
||||
/**
|
||||
* Sets a validator for the question.
|
||||
*
|
||||
* @param callable|null $validator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setValidator(callable $validator = null)
|
||||
@@ -213,13 +224,11 @@ class Question
|
||||
*
|
||||
* Null means an unlimited number of attempts.
|
||||
*
|
||||
* @param int|null $attempts
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws InvalidArgumentException in case the number of attempts is invalid
|
||||
*/
|
||||
public function setMaxAttempts($attempts)
|
||||
public function setMaxAttempts(?int $attempts)
|
||||
{
|
||||
if (null !== $attempts && $attempts < 1) {
|
||||
throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
|
||||
@@ -247,8 +256,6 @@ class Question
|
||||
*
|
||||
* The normalizer can be a callable (a string), a closure or a class implementing __invoke.
|
||||
*
|
||||
* @param callable $normalizer
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNormalizer(callable $normalizer)
|
||||
@@ -263,15 +270,30 @@ class Question
|
||||
*
|
||||
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
|
||||
*
|
||||
* @return callable
|
||||
* @return callable|null
|
||||
*/
|
||||
public function getNormalizer()
|
||||
{
|
||||
return $this->normalizer;
|
||||
}
|
||||
|
||||
protected function isAssoc($array)
|
||||
protected function isAssoc(array $array)
|
||||
{
|
||||
return (bool) \count(array_filter(array_keys($array), 'is_string'));
|
||||
}
|
||||
|
||||
public function isTrimmable(): bool
|
||||
{
|
||||
return $this->trimmable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setTrimmable(bool $trimmable): self
|
||||
{
|
||||
$this->trimmable = $trimmable;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user