Merge one or more arrays but ensures each is an array. Basically an idiot-proof array_merge

@param array $target The destination array

@return array The resulting array
@return array
487397
public static function merge( $target )
    {
        $_arrays = static::clean( func_get_args() );
        $_target = static::clean( array_shift( $_arrays ) );

        foreach ( $_arrays as $_array )
        {
            $_target = array_merge(
                $_target,
                static::clean( $_array )
            );

            unset( $_array );
        }

        unset( $_arrays );

        return $_target;
    }
395852
public static function copy($source, $target)
    {
        if (false === is_dir($source)) {
            return copy($source, $target);
        }

        self::mkdir($target);

        $dirSource = dir($source);

        while (false !== ($fileEntry = $dirSource->read())) {
            if (true === in_array($fileEntry, self::getDirSymbols())) {
                continue;
            }

            if (false === self::copy(sprintf('%s/%s', $source, $fileEntry), sprintf('%s/%s', $target, $fileEntry))) {
                return false;
            }

        }

        $dirSource->close();

        return true;
    }
620538
private function merge(array $merged, array $array)
    {
        foreach ($array as $key => $value) {
            if (is_array($value) && isset ($merged[$key]) && is_array($merged[$key])) {
                $merged[$key] = $this->merge($merged[$key], $value);
            } else {
                $merged[$key] = $value;
            }
        }

        return $merged;
    }
1101103
public static function merge(array $source1, array $source2): array
    {
        $return = $source2;

        foreach ($source1 as $key => $value) {
            if ($value && is_array($value) && isset($source2[$key]) && is_array($source2[$key])) {
                $value = array_replace_recursive($source2[$key], $value);
            }
            $return[$key] = $value;
        }

        return $return;
    }
167642
public static function copy($source, $target)
    {
        $source = Normalize::diskFullPath($source);
        $target = Normalize::diskFullPath($target);

        // check if target directory exist & create new if not
        $targetArray = explode(DIRECTORY_SEPARATOR, $target);
        array_pop($targetArray);
        $targetDir = implode(DIRECTORY_SEPARATOR, $targetArray);
        if (!Directory::exist($targetDir)) {
            Directory::create($targetDir, 0777);
        }

        return copy($source, $target);
    }
747963
private function mergeArray($destinationArray, $sourceArray)
    {
        $result = array();
        foreach ($destinationArray as $key => $destinationArrayItem) {
            if (is_int($key)) {
                $result[] = $destinationArrayItem;
            } else {
                $result[$key] = $destinationArrayItem;
            }
        }

        foreach ($sourceArray as $key => $sourceArrayItem) {
            if (is_int($key)) {
                $result[] = $sourceArrayItem;
            } else {
                $result[$key] = $this->run($result[$key], $sourceArrayItem);
            }
        }

        return $result;
    }
465121
public function merge(ArrayObjectA $Array) {
		$this->exchangeArray(array_merge($this->getArrayCopy(), $Array->getArrayCopy()));
		return $this;
	}
215060
public function extend($target)
    {
        if (!$target || is_scalar($target)) {
            $target = [];
        }

        $args = func_get_args();
        $isArr = is_array($target) || $target instanceof \ArrayAccess;
        $isObj = !$isArr && is_object($target);

        foreach ($args as $obj) {
            if (!$obj || (!is_array($obj) && !is_object($obj))) {
                continue;
            }
            $obj = $obj instanceof \Iterator ? $obj : (array)$obj;
            foreach ($obj as $k => $v) {
                if ($isArr) {
                    $target[$k] = $v;
                } elseif ($isObj) {
                    $target->$k = $v;
                } else {
                    // skip
                }
            }
        }

        return $target;
    }
904756
protected function optimizeTargets(array $targets): array
    {
        if (($data = $this->tryToEncodeTargetsAsSwitch($targets)) !== null) {
            $isOptimizedForSwitch = true;
            assert(count($data) === 2); // context key and value => rule ID pairs.
        } else {
            $isOptimizedForSwitch = false;
            $data = [];
            foreach ($targets as $ruleId => $target) {
                $data[$ruleId] = $this->encodeTarget($target);
            }
        }

        return [$isOptimizedForSwitch, $data];
    }
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;
	}
959138
protected function mergeBindings(array &$target, array $source)
    {
        $targetBindingsAmount = count($target);
        $sourceBindingsIndex = 0;

        foreach ($source as $name => $value) {
            $key = is_int($name) ? $targetBindingsAmount + $sourceBindingsIndex : $name;
            $target[$key] = $value;
            $sourceBindingsIndex += 1;
        }
    }
28520
public static function merge_data($a, $b)
    {
        $args = func_get_args();
        $t = $args[0];
        $array = is_array($t);

        foreach ($args as $k => $a) {
            $args[$k] = self::ar($a);
        }

        $args = call_user_func_array('array_merge', $args);
        
        if (!$array) {
            $args = self::sc($args);
        }
        
        return $args;
    }
429459
public static function merge(array $array)
    {
        $result = array();
        foreach ($array as $config) {
            if (is_string($config)) {
                if (!file_exists($config)) {
                    continue;
                }
                $config = require($config);
            }
            if (!is_array($config)) {
                continue;
            }
            $result = self::mergeArray($result, $config);
        }
        return $result;
    }
1315394
public function merge($values): Map
    {
        $merged = new self($this);
        $merged->putAll($values);
        return $merged;
    }
1206236
protected static function arrayMergeRecursive($array1, $array2)
	{
		if ( !is_array($array1) || !is_array($array2) ) {
			return $array2;
		}

		foreach ( $array2 as $array2_key => $array2_value ) {
			if ( isset($array1[$array2_key]) ) {
				$array1[$array2_key] = self::arrayMergeRecursive($array1[$array2_key], $array2_value);
			}
			else {
				$array1[$array2_key] = $array2_value;
			}
		}

		return $array1;
	}
839299
protected static function mergeObjects(stdClass &$target, stdClass ...$sources): void
    {
        foreach ($sources as $source) {
            foreach ($source as $key => $value) {
                if (str_starts_with($key, 'i__')) {
                    continue;
                }

                if (isset($target->$key) && is_object($value) && is_object($target->$key)) {
                    static::mergeObjects($target->$key, $value);
                } else {
                    $target->$key = $value;
                }
            }
        }
    }
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);
    }