Merge the given (raw) UI actions into a unique set.

@param  array ...$params Variable list of actions to merge.
@return array Returns a collection of merged actions.
495066
protected function mergeActions(array ...$params)
    {
        $unique = [];
        foreach ($params as $actions) {
            foreach ($actions as $ident => $action) {
                if ($action === '|') {
                    $unique[$ident] = $action;
                    continue;
                }

                $ident = $this->parseActionIdent($ident, $action);
                $action['ident'] = $ident;

                $hasActions = (isset($action['actions']) && is_array($action['actions']));
                if ($hasActions) {
                    $action['actions'] = $this->mergeActions($action['actions']);
                } else {
                    $action['actions'] = [];
                }

                if (isset($unique[$ident])) {
                    if (static::compareActions($action, $unique[$ident])) {
                        if ($hasActions && !!$unique[$ident]['actions']) {
                            $action['actions'] = $this->mergeActions(
                                $unique[$ident]['actions'],
                                $action['actions']
                            );
                            unset($unique[$ident]['actions']);
                        }
                        $unique[$ident] = array_replace($unique[$ident], $action);
                    } else {
                        if ($hasActions && !!$unique[$ident]['actions']) {
                            $unique[$ident]['actions'] = $this->mergeActions(
                                $unique[$ident]['actions'],
                                $action['actions']
                            );
                            unset($action['actions']);
                        }
                        $unique[$ident] = array_replace($action, $unique[$ident]);
                    }
                } else {
                    $unique[$ident] = $action;
                }
            }
        }

        return $unique;
    }
1184796
public function withParams(array $params): ParamHolderInterface
    {
        $param_holder = clone $this;
        $param_holder->params = array_merge($param_holder->params, $params);
        return $param_holder;
    }
1330116
public function merge($actions)
	{
		if (is_string($actions))
		{
			$actions = json_decode($actions, true);
		}

		if (is_array($actions))
		{
			foreach ($actions as $action => $identities)
			{
				$this->mergeAction($action, $identities);
			}
		}
		elseif ($actions instanceof Rules)
		{
			$data = $actions->getData();

			foreach ($data as $name => $identities)
			{
				$this->mergeAction($name, $identities);
			}
		}
	}
1321376
public static function mergeProps($mergeStack, $options = array())
    {
        $merged = array();
        while ($mergeStack) {
            $props = \array_shift($mergeStack);
            $props = self::moveShortcuts($props);
            $props = self::mergeClassesPrep($merged, $props);
            $props = self::classnamesToArray($props);
            $merged = ArrayUtil::mergeDeep($merged, $props, $options);
        }
        return $merged;
    }
1310713
public function queryAll($params = array())
    {
        $this->mergeParams($params);
        $this->beginQuery();
        $rst = $this->statement->fetchAll(\PDO::FETCH_ASSOC);
        $this->statement->closeCursor();
        return $rst;
    }
211497
protected function setListActions(array $actions)
    {
        $this->parsedListActions = false;

        $this->listActions = $this->mergeActions($this->defaultListActions(), $actions);

        return $this;
    }
1331523
public function export(array $params = array()) {
		$result = array(
			'type' => 'list',
			'count' => $this->getCount(),
			'limit' => elgg_extract('limit', $this->options, elgg_get_config('default_limit')),
			'offset' => elgg_extract('offset', $this->options, 0),
			'items' => array(),
		);

		$batch = $this->getBatch();
		foreach ($batch as $entity) {
			$result['items'][] = hypeApps()->graph->export($entity, $params);
		}

		return $result;
	}
611012
protected function mergeConfigs(array $configs) {
		$result = new stdClass();
		
		$result->parameters   = new stdClass();
		$result->services     = new stdClass();
		$result->initializers = new stdClass();
		
		foreach ($configs as $config) {
			$this->mergeConfigsPart($config->getParameters(), $result->parameters);
			$this->mergeConfigsPart($config->getServices(), $result->services);
			$this->mergeConfigsPart($config->getInitializers(), $result->initializers);
		}
		
		return $result;
	}
1123359
protected function mergeOptions(array $options)
    {
        $merged = [];
        foreach ($this->supportedOptions() as $option) {
            $merged[$option] = $this->mergeOption($option, $options);
        }

        return $merged;
    }
1115820
private function mergeOptions(array $options)
    {
        /** @var Option[] $mergedList */
        $mergedList = array_merge($this->optionList, $options);
        $duplicates = array();
        foreach ($mergedList as $option) {
            foreach ($mergedList as $otherOption) {
                if (($option === $otherOption) || in_array($otherOption, $duplicates)) {
                    continue;
                }
                if ($this->optionsConflict($option, $otherOption)) {
                    throw new \InvalidArgumentException('Failed to add options due to conflict');
                }
                if (($option->short() === $otherOption->short()) && ($option->long() === $otherOption->long())) {
                    $duplicates[] = $option;
                }
            }
        }
        foreach ($mergedList as $index => $option) {
            if (in_array($option, $duplicates)) {
                unset($mergedList[$index]);
            }
        }
        $this->optionList = array_values($mergedList);
    }
504324
protected function mergeOptions(array $options)
    {
        $mergedOptions = $this->options;

        foreach ($options as $name => $value) {
            if (!array_key_exists($name, $mergedOptions)) {
                throw new \InvalidArgumentException(sprintf('The option \'%s\' does not exist.', $name));
            }

            $mergedOptions[$name] = $value;
        }

        return $mergedOptions;
    }
119677
protected function mergeDefaultOptions($options = [])
    {
        $defaults = $this->getDefaultOptions();

        foreach (array_keys($defaults) as $key) {
            if (!isset($options[$key])) {
                $options[$key] = [];
            }
            $options[$key] += $defaults[$key];
        }

        return $options;
    }
881971
function assemble($params = array())
    {
        ## merge params:
        $p = clone $this->params();
        // when parameters exactly given don't merge recursively and instead replace items
        if ($params) \Poirot\Router\mergeParams($p, $params, false);

        $p        = \Poirot\Std\cast($p)->toArray();
        $criteria = \Poirot\Std\Lexer\parseCriteria($this->getCriteria());
        $path     = \Poirot\Std\Lexer\buildStringFromParsed($criteria, $p);
        
        $uri = new Uri($path);
        return $uri;
    }
1077917
protected function mergeOptions(array $options)
    {
        $defaults = $options + $this->defaultOptions;
        $defaults['params'] = [];
        if (!$defaults['filter_action'] || $this->application->input->{$defaults['method']}($defaults['action']) === $defaults['filter_action']) {
            //Action filter
            //cleaning post/get data
            foreach ($defaults['filters'] as $params => $column) {
                switch ($defaults['method']) {
                    case 'get':
                        if (isset($_GET[$params])) {
                            if (is_array($_GET[$params])) {
                                $_GET[$params] = array_filter(
                                    $_GET[$params],
                                    function ($value) {
                                        return (trim($value) !== '');
                                    }
                                );
                                if (empty($_GET[$params])) {
                                    unset($_GET[$params]);
                                }
                            } elseif (trim($_GET[$params]) === '') {
                                unset($_GET[$params]);
                            }
                        }
                        break;
                    case 'post':
                        if (isset($_POST[$params]) && trim($_POST[$params]) === '') {
                            if (is_array($_POST[$params])) {
                                $_POST[$params] = array_filter(
                                    $_POST[$params],
                                    function ($value) {
                                        return (trim($value) !== '');
                                    }
                                );
                                if (empty($_POST[$params])) {
                                    unset($_POST[$params]);
                                }
                            } elseif (trim($_POST[$params]) === '') {
                                unset($_POST[$params]);
                            }
                            unset($_POST[$params]);
                        }
                        break;
                }
            }
            $defaults['params'] = array_intersect_key($this->application->input->{$defaults['method']}(), $defaults['filters']);
        } elseif ($this->application->input->{$defaults['method']}($defaults['action']) === $defaults['reset_action']) {
            foreach ($defaults['filters'] as $params => $callback) {
                switch ($defaults['method']) {
                    case 'get':
                        unset($_GET[$params]);
                        break;
                    case 'post':
                        unset($_POST[$params]);
                        break;
                }
            }
            //Reset action
            $defaults['params'] = $defaults['default_filters'];
        } elseif ($defaults['save']) {
            $defaults['params'] = $this->application->session->userdata($options['save']);
        }

        // Si aucun filtre n'a été soumis (session non initialisé, filtre par défaut
        $session_exist = false;
        if ($defaults['save']) {
            $session_exist =  $this->application->session->has_userdata($options['save']);
        }
        if (empty($defaults['params']) && !$session_exist) {
             $defaults['params'] = $defaults['default_filters'];
        }
        return $defaults;
    }
1291788
private function normalizeParams($params)
    {
        $keys = array_keys($params);
        $values = array_values($params);

        $keys = array_map(function ($key) {
            return '{' . trim($key, '{}') . '}';
        }, $keys);

        $normalizedParams = array_combine($keys, $values);

        if (count($normalizedParams) !== count($params)) {
            throw new InvalidArgumentException('Identical params.');
        }

        return $normalizedParams;
    }
1127258
public static function merge($arrays)
    {
        $merged = [];

        foreach ($arrays as $array)
        {
            $merged = array_merge($merged, static::flatten($array));
        }

        return static::expand($merged);
    }
1289536
public function UnifiedOrder($params)
    {
        $this->input = new UnifiedOrder();
        $params = array_merge($this->configs, $params);
        $this->setParams($params);
        return Api::unifiedOrder($this->input);
    }