function Question::setAutocompleterValues
Sets values for the autocompleter.
Return value
$this
Throws
1 call to Question::setAutocompleterValues()
- ChoiceQuestion::__construct in vendor/
symfony/ console/ Question/ ChoiceQuestion.php
File
-
vendor/
symfony/ console/ Question/ Question.php, line 142
Class
- Question
- Represents a Question.
Namespace
Symfony\Component\Console\QuestionCode
public function setAutocompleterValues(?iterable $values) : static {
if (\is_array($values)) {
$values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
$callback = static fn() => $values;
}
elseif ($values instanceof \Traversable) {
$callback = static function () use ($values) {
static $valueCache;
return $valueCache ??= iterator_to_array($values, false);
};
}
else {
$callback = null;
}
return $this->setAutocompleterCallback($callback);
}