Update composer dependencies

This commit is contained in:
Chris
2019-06-11 12:29:32 +01:00
parent 7d6df3843b
commit 1f608b1c21
1835 changed files with 74500 additions and 27482 deletions

View File

@@ -25,7 +25,7 @@ class Question
private $attempts;
private $hidden = false;
private $hiddenFallback = true;
private $autocompleterValues;
private $autocompleterCallback;
private $validator;
private $default;
private $normalizer;
@@ -81,7 +81,7 @@ class Question
*/
public function setHidden($hidden)
{
if ($this->autocompleterValues) {
if ($this->autocompleterCallback) {
throw new LogicException('A hidden question cannot use the autocompleter.');
}
@@ -121,7 +121,9 @@ class Question
*/
public function getAutocompleterValues()
{
return $this->autocompleterValues;
$callback = $this->getAutocompleterCallback();
return $callback ? $callback('') : null;
}
/**
@@ -138,17 +140,46 @@ class Question
{
if (\is_array($values)) {
$values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
}
if (null !== $values && !\is_array($values) && !$values instanceof \Traversable) {
$callback = static function () use ($values) {
return $values;
};
} elseif ($values instanceof \Traversable) {
$valueCache = null;
$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.');
}
if ($this->hidden) {
return $this->setAutocompleterCallback($callback);
}
/**
* Gets the callback function used for the autocompleter.
*/
public function getAutocompleterCallback(): ?callable
{
return $this->autocompleterCallback;
}
/**
* Sets the callback function used for the autocompleter.
*
* The callback is passed the user input as argument and should return an iterable of corresponding suggestions.
*
* @return $this
*/
public function setAutocompleterCallback(callable $callback = null): self
{
if ($this->hidden && null !== $callback) {
throw new LogicException('A hidden question cannot use the autocompleter.');
}
$this->autocompleterValues = $values;
$this->autocompleterCallback = $callback;
return $this;
}