Merge more context to current context

@param array $moreContext The context to merge to the (eventually) existing one

@return $this
548169
public function mergeContext(array $moreContext)
    {
        $this->context = array_replace_recursive(isset($this->context) ? $this->context : [], $moreContext);

        return $this;
    }
197638
public function getContext()
    {
        if (!isset($this->currentContext)) {
            $this->initiateContext();
        }
        return $this->contexts[$this->currentContext];
    }
65327
private function createDocBlockContext()
    {
        $file = $this->descriptor->getFile();
        $namespaceAliases = $file ? $file->getNamespaceAliases()->getAll() : array();

        return new Context($this->descriptor->getNamespace(), $namespaceAliases);
    }
71075
public function addContexts($contexts)
    {
        if (is_array($contexts)) {
            foreach ($contexts as $context) {
                $this->insertContextInAllowedExtensions($context);
            }
        } elseif ($contexts !== false) {
            $this->insertContextInAllowedExtensions($contexts);
        }

        return $this;
    }
380065
public function content(): Context
    {
        if (!$this->content)
        {
            $this->setContent(new Context(
                new Helper(),
                new Extensions()
            ));
        }

        return $this->content;
    }
508321
protected function _actionAdd(AnCommandContext $context)
    {
        $data = $context->data;

        return $this->getRepository()->create($data->toArray());
    }
321852
public static function extendDistinct()
    {
        $merged = [];

        foreach (func_get_args() as $array) {
            foreach ($array as $key => $value) {
                if (is_array($value) && static::has($merged, $key) && is_array($merged[$key])) {
                    if (static::isAssoc($value) && static::isAssoc($merged[$key])) {
                        $merged[$key] = static::extendDistinct($merged[$key], $value);

                        continue;
                    }
                }

                $merged[$key] = $value;
            }
        }

        return $merged;
    }
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;
            }
        }
    }
754017
public function merge(ArrayObject $other, $recursive = TRUE) {
        foreach($other as $key => $value) {
            if($recursive && $this->offsetExists($key)) {
                $ownvalue = $this->offsetGet($key);
                if($ownvalue instanceof ArrayObject && $value instanceof ArrayObject) {
                    $ownvalue->merge($value, TRUE);
                    continue;
                }
            }

            $this->offsetSet($key, $value);
        }

        return $this;
    }
763426
public function merge(self $other)
    {
        $new      = clone $this;
        $newWhere = $new->select->where;
        
        foreach ($other->select->where->getPredicates() as $pData) {
            $newWhere->addPredicate($pData[1], $pData[0]);
        }
        
        return $new;
    }
547425
public function merge(self $config, $override = true)
    {
        if ($override) {
            $this->config = array_replace_recursive($this->config, $config->toArray());
        } else {
            $this->config = array_replace_recursive($config->toArray(), $this->config);
        }

        return $this;
    }
295256
public function merge(ConfigInterface $config)
    {
        $this->data = array_replace_recursive($this->data, $config->all());
        return $this;
    }
1230029
public function merge($array)
    {
        if ($this->isInstanceOf($array, $this)) {
            $array = $array->val();
        }

        $this->val(array_merge($this->val(), $array));

        return $this;
    }
1122455
public function mergeGlobals(array $context)
    {
        // we don't use array_merge as the context being generally
        // bigger than globals, this code is faster.
        foreach ($this->getGlobals() as $key => $value) {
            if (!array_key_exists($key, $context)) {
                $context[$key] = $value;
            }
        }

        return $context;
    }
381500
public function pushContext($key, $context)
    {
        $newContext = $this->getCurrentContext();
        $newContext[$key] = $context;
        $this->contextStack[] = $newContext;
    }
662223
public function setContext(array $context)
    {
        $this->clearContext();
        foreach ($context as $key => $value) {
            $this->setContextValue($key, $value);
        }
    }
544272
protected function buildTopLevelArrayNestedForContext(array $context)
    {
        // Context becomes the main level, so anything in context (with some caveats)
        // is moved up to the top level -- by making %context% the main 'message'
        // output in the log line.

        // Rename to prefix context variables with 'reserved' names
        $nested = [];

        foreach ($this->reservedTopLevelKeys as $key) {

            if (array_key_exists($key, $context)) {
                $nested[ $key ] = $context[ $key ];
                unset ($context[ $key ]);
            }
        }

        // The 'context' key is a special case: its value should be merged
        // into the nested context at that level.
        // (So context.context.key becomes context.key)

        if (array_key_exists('context', $context)) {

            if ( ! is_array($context['context'])) {
                $context['context'] = (array) $context['context'];
            }

            $context['context'] = array_merge($context['context'], $nested);

        } else {
            // if it does not exist yet, just make a nested context
            $context['context'] = $nested;
        }

        return $context;
    }