Alternative function for array_merge - safe for use with any-type params.
@return array
518170
public static function merge(): array
    {
        $arguments = [];
        foreach (func_get_args() as $key => $val) {
            if (!Any::isArray($val)) {
                $val = [];
            }

            $arguments[$key] = $val;
        }
        return call_user_func_array('array_merge', $arguments);
    }
1127258
public static function merge($arrays)
    {
        $merged = [];

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

        return static::expand($merged);
    }
1117615
private function arrayMergeRecursive(array ...$arrays)
    {
        $base = array_shift($arrays);
        if ( ! is_array($base)) {
            $base = empty($base) ? [] : [$base];
        }

        foreach ($arrays as $append) {
            if ( ! is_array($append)) {
                $append = [$append];
            }
            foreach ($append as $key => $value) {
                if ( ! array_key_exists($key, $base) && ! is_numeric($key)) {
                    $base[$key] = $append[$key];
                    continue;
                }

                if ((is_array($value) || (isset($base[$key]) && is_array($base[$key]))) && $this->isAssoc($value)) {
                    $base[$key] = $this->arrayMergeRecursive(
                        (array) $base[$key],
                        (array) $append[$key]
                    );
                } else {
                    if (is_numeric($key)) {
                        if ( ! in_array($value, $base)) {
                            $base[] = $value;
                        }
                    } else {
                        $base[$key] = $value;
                    }
                }
            }
        }

        return $base;
    }
151238
protected function merge(array $base, array $merge): array
    {
        $options = array_merge($this->default_options, $base, $merge);
        $options = array_intersect_key($options, $this->default_options);

        foreach ($this->default_options as $_key => $_default_option_value) {
            if (!isset($options[$_key])) {
                $options[$_key] = $_default_option_value;
            } else {
                settype($options[$_key], gettype($_default_option_value));
            }
        } // unset($_key, $_default_option_value);

        return $options;
    }
851539
static public function objectMerge() {
		$result = new stdClass();
		
		foreach (func_get_args() as $object) {
			foreach ($object as $key => $value) {
				$result->$key = $value;
			}
		}
		
		return $result;
	}
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;
    }
232236
protected function merge($a, $b)
    {
        if (!is_array($a)) {
            if (!is_array($b)) return [];
            return $b;
        }

        if (!is_array($b)) return $a;

        foreach($b as $k => $v) {
            if (!isset($a[$k])) {
                $a[$k] = $v;
                continue;
            }
            if (!is_array($v)) {
                if (!is_array($a[$k])) {
                    $a[$k] = $v;
                    continue;
                }
                $a[$k] = array_merge($a[$k], [$v]);
                foreach(array_keys($a[$k]) as $kk) {
                    if (is_numeric($kk)) {
                        $a[$k] = array_unique($a[$k]);
                        break;
                    }
                }
                continue;
            }
            $a[$k] = array_merge($a[$k], $b[$k]);
            foreach(array_keys($a[$k]) as $kk) {
                if (is_numeric($kk)) {
                    $a[$k] = array_unique($a[$k]);
                    break;
                }
            }
        }

        return $a;
    }
50109
public function toArray(): array
    {
        if (!empty($this->warnings)) {
            $this->status = 'warning';
        } elseif (!empty($this->errors)) {
            $this->status = 'error';
        }

        return [
            'status' => $this->status,
            'errors' => array_merge(array_map(function($x) {
                return ['severity' => 'error', 'message' => $x];
            }, $this->errors), array_map(function($x) {
                return ['severity' => 'warning', 'message' => $x];
            }, $this->warnings)),
            'info' => $this->info
        ];
    }
606714
public static function ArrayObjectMerge (\ArrayObject $array_object) {
		$args = func_get_args();
		array_shift($args);
		return static::_ArrayObjectMerge($array_object, $args);
	}
258906
public function mergeParameters(array $params = null)
    {
        if (null !== $params) {
            $parameters = $this->getParameters();
            $out = [];
            $i = 1;
            foreach ($parameters as $key => $parameter) {
                $out["rule$i"] = $parameter;
                $i++;
            }
            foreach ($params as $key => $param) {
                $out["rule$i"] = $param;
                $i++;
            }

            $this->setParameters($out);
        }
    }
29506
public static function array_merge_recursive()
  {
    if ( func_num_args() < 2 ){
      trigger_error(__METHOD__ .' needs two or more array arguments', E_USER_WARNING);
    }
    
    $arrays = func_get_args();
    $merged = [];
    
    while($arrays){
      $array = array_shift($arrays);
      if ( !is_array($array) ){
        trigger_error(__METHOD__ .' encountered a non array argument', E_USER_WARNING);
      }
      
      if ( !$array ){
        continue;
      }
      
      foreach($array as $key => $value){
        if ( is_string($key) ){
          if ( is_array($value) && array_key_exists($key, $merged) && is_array($merged[$key]) ){
            $merged[$key] = call_user_func([__NAMESPACE__ . '\\Arrayhelper', __METHOD__], $merged[$key], $value);
          }
          else {
            $merged[$key] = $value;
          }
        }
        else {
          $merged[] = $value;
        }
      }
    }
    
    return $merged;
  }
1323881
function mergeParams(params, addition) {
        return (
            // if it's uncontested, then just return the addition.
            (!params) ? addition
            // if the existing value is an array, then concat it.
            : ($.isArray(params)) ? params.concat(addition)
            // if the existing value is not an array, and either are not objects, arrayify it.
            : (!$.isPlainObject(params) || !$.isPlainObject(addition)) ? [params].concat(addition)
            // else merge them as objects, which is a little more complex
            : mergeObjects(params, addition)
        );
    }
897939
public static function extend(): array
    {
        $merged = [];

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

        return $merged;
    }
527752
public function getValues()
    {
        if ($this->isEmpty()) {
            return [];
        }

        if ($this->hasElement()) {
            return $this->values;
        }

        $values = [];

        foreach ($this->stack as $where) {
            $values[] = $where->getValues();
        }

        return call_user_func_array('array_merge', $values);
    }
1163474
public static function merge($array1, $array2)
	{
		$result = [];
		for ($i = 0; $i < func_num_args(); $i++) {
			$result = parent::merge($result, static::asArray(func_get_arg($i)));
		}

		return $result;
	}
562094
private function mergeArrays($deep, $array1, $array2)
    {
        if ($deep === 'merge') {
            return Utils::arrayMergeRecursiveUnique($array1, $array2);
        }
        if ($deep === true) {
            return array_replace_recursive($array1, $array2);
        }

        return array_merge($array1, $array2);
    }
424189
public function merge()
    {
        $marged = NULL;
        foreach (func_get_args() as $arg) {
            // first is override.
            if ($marged === null) {
                $marged = $arg;

            // when mismatch variable type, then override.
            } elseif (gettype($marged) !== gettype($arg)) {
                $marged = $arg;

            // when not array, then override.
            } elseif (! is_array($arg)) {
                $marged = $arg;

            // when both array, then merge recursive.
            } else {
                foreach ($arg as $_key => $_val) {
                    // when int key, then push.
                    if(is_int($_key)) {
                        $marged[] = $_val;
                    // when not exists key, then override.
                    } elseif(! isset($marged[$_key])) {
                        $marged[$_key] = $_val;
                    // merge.
                    } else {
                        $marged[$_key] = $this->merge($marged[$_key], $_val);
                    }
                }
            }
        }
        return $marged;
    }