public function setAutocompleterValues($values)
    {
        if (\is_array($values)) {
            $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);

            $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.');
        }

        return $this->setAutocompleterCallback($callback);
    }
public function setAutocompleterValues($values)
    {
        if (\is_array($values)) {
            $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);

            $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.');
        }

        return $this->setAutocompleterCallback($callback);
    }
public function setAutocompleterValues ( $ values ) { if ( \ is_array ( $ values ) ) { $ values = $ this -> isAssoc ( $ values ) ? array_merge ( array_keys ( $ values ) , array_values ( $ values ) ) : array_values ( $ values ) ; $ 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.' ) ; } return $ this -> setAutocompleterCallback ( $ callback ) ; }
Sets values for the autocompleter.

@param iterable|null $values

@return $this

@throws InvalidArgumentException
@throws LogicException
Sets values for the autocompleter .