Merges a set of values into the given key's set.

@param string $key
@param \Traversable $values
@return void
426392
public function merge($key, $values)
    {
        foreach ((array)$values as $value) {
            $this->add($key, $value);
        }
        $this->stateChanged();
    }
1290848
public function addValue(string $key, string $value) : void
    {
        $this->map[$key] = $value;
    }
1207324
public function add(string $key, $value)
    {
        $current = $this->get($key, []);
        $adds = is_array($value) ? $value : [$value];
        $this->set($key, array_merge($current, array_values($adds)));
    }
153551
private static function combine(array $keys, array $values): array
    {
        $nbKeys = \count($keys);
        $nbValues = \count($values);

        if ($nbKeys < $nbValues) {
            return \array_combine($keys, \array_slice(\array_values($values), 0, $nbKeys));
        }

        if ($nbKeys > $nbValues) {
            return \array_combine($keys, \array_merge($values, \array_fill(0, $nbKeys - $nbValues, null)));
        }

        return \array_combine($keys, $values);
    }
201314
public function mergeTerms($values)
    {
        $values = (array) $values;
        foreach ($values as $v) {
            if (!in_array($v, $this->terms)) {
                $this->_terms[] = $v;
            }
        }
    }
1025499
public static function addTo($key, $value)
  {
    if (isset(self::$vars[$key])) {
      self::$vars[$key] .= $value;
    } else {
      self::$vars[$key] = $value;
    }
  }
85147
public function setExtraKeys(array $values)
    {
        $this->extra = array();

        foreach ($values as $key => $value) {
            $this->setExtraKey($key, $value);
        }
    }
1047492
public function deleteValue(string $key) : void
    {
        if (isset($this->map[$key])) {
            unset($this->map[$key]);
        }
    }
1071695
public function addAll($values)
    {
        foreach ($values as $key => $value)
            $this->set($key, $value);
        return $this;
    }
1062082
public static function maps(array $mappings, $key = 'default')
	{
		self::$mappings = array_merge_recursive(self::$mappings, [ $key => $mappings ]);
	}
771154
public function set($key, $value)
    {
        if (!is_array($value)) {
            $value = [$value];
        }
        parent::set($this->normalizeKey($key), [
            'value' => $value,
            'originalKey' => $key
        ]);
    }
783118
public function merge($newValues, $override = true)
    {
        foreach ($newValues as $key => $value) {
            // If the key doesn't exist yet,
            // we can simply set it.
            if (!array_key_exists($key, $this)) {
                $this[$key] = $value;
                continue;
            }

            // We already know this value exists
            // so if we're in conservative mode
            // we can skip this key
            if ($override === false) {
                continue;
            }

            // Merge the values only if
            // both values are arrays
            if (is_array($this[$key]) && is_array($value)) {
                $this[$key] = array_replace_recursive($this[$key], $value);
            } else {
                $this[$key] = $value;
            }
        }
    }
613532
public function replace($key, $values)
    {
        $this->values[$key] = new SortedSet($values);
        $this->stateChanged();
    }
652007
public function add($key, $value)
    {
        if (!isset($this->values[$key])) {
            $this->values[$key] = new SortedSet();
        }
        $this->values[$key]->add($value);
        $this->stateChanged();
    }
203194
public function add($key, $value)
    {
        $header = $this->get($key, true);
        if (is_array($value)) {
            $header = array_merge($header, $value);
        } else {
            $header[] = $value;
        }
        parent::set($this->normalizeKey($key), $header);
    }
834929
public function merge($values): Set
    {
        $merged = $this->copy();

        foreach ($values as $value) {
            $merged->add($value);
        }

        return $merged;
    }
1116481
protected function mergeDataEntry($value, $key) {
        if (!isset($this->shared[$key])) {
            $this->shared[$key] = $value;
        } elseif (isset($this->shared[$key]['#merged'])) {
            $this->shared[$key]['#value'][] = $value;
        } else {
            $oldValue = $this->shared[$key];
            $this->shared[$key] = [
                '#merged' => true,
                '#value' => [$oldValue, $value]
            ];
        }
    }