mergeDefaults

@param array $given

@return array
774045
private function mergeDefaults(array $given, $methods)
    {
        $defaults = array_merge(array_combine(self::$keys, array_pad([], count(self::$keys), null)), $given);

        if (null === $defaults[self::K_SCHEME]) {
            $defaults[self::K_SCHEME] = 'http|https';
        }

        if (null === $defaults[self::K_NAME]) {
            $defaults[self::K_NAME] = $this->generateName($methods);
        }

        return $defaults;
    }
716847
public static function merge()
    {
        $array = func_get_arg(0);
        $Arr = array_slice(func_get_args(), 1);

        if (!is_array($array)) {
            throw new \Exception('Arr::merge() - all arguments must be Array.');
        }

        foreach ($Arr as $arr) {
            if (!is_array($arr)) {
                throw new \Exception('Arr::merge() - all arguments must be Array.');
            }

            foreach ($arr as $key => $value) {
                if (is_int($key)) {
                    array_key_exists($key, $array) ? array_push($array, $value) : $array[$key] = $value;
                } elseif (is_array($value) && array_key_exists($key, $array) && is_array($array[$key])) {
                    $array[$key] = self::merge($array[$key], $value);
                } else {
                    $array[$key] = $value;
                }
            }
        }

        return $array;
    }
156232
protected function mergeConfigs(array $configs)
    {
        $merged = array();
        foreach ($configs as $config) {
            $merged = array_merge($merged, $config);
        }

        return $merged;
    }
700475
protected function mergeParameters(array $reflectionParameters, array $providedParameters): array
	{
		// Make reflection parameter array associative

		$associativeReflectionParameters = [];

		foreach($reflectionParameters as $value)
		{
			$associativeReflectionParameters[$value->getName()] = $value;
		}

		// Make the provided parameter array associative

		$associativeProvidedParameters = [];

		foreach($providedParameters as $key => $value)
		{
			if(is_int($key))
			{
				$associativeProvidedParameters[$reflectionParameters[$key]->getName()] = $value;
			}
			else
			{
				$associativeProvidedParameters[$key] = $value;
			}
		}

		// Return merged parameters

		return array_replace($associativeReflectionParameters, $associativeProvidedParameters);
	}
137593
protected function mergeExisting($new, $existing)
    {
        foreach ($new as $aliasName => &$newAlias) {
            // If the alias already exists, recursively replace existing
            // settings with new ones.
            if (isset($existing[$aliasName])) {
                $newAlias = array_replace_recursive($existing[$aliasName], $newAlias);
            }
        }

        return $new;
    }
771548
protected function mergeChangesArrays($left, $right)
	{
		$return = $left;

		foreach ($right as $type => $changes)
		{
			if (isset($left[$type]))
			{
				$return[$type] = array_merge($right[$type], $left[$type]);
			}
			else
			{
				$return[$type] = $changes;
			}
		}

		return $return;
	}
726534
public static function merge(array $to, array $from)
    {
        $args = func_get_args();
        $res = array_shift($args);
        while (!empty($args)) {
            $next = array_shift($args);
            foreach ($next as $k => $v) {
                if (is_integer($k)) {
                    isset($res[$k]) ? $res[] = $v : $res[$k] = $v;
                } elseif (is_array($v) && isset($res[$k]) && is_array($res[$k])) {
                    $res[$k] = self::merge($res[$k], $v);
                } else {
                    $res[$k] = $v;
                }
            }
        }
        return $res;
    }
770708
public function mergeParams($method, Array $params = [])
    {
        $result = parent::mergeParams($method, $params);

        foreach ($this->map as $oldKey => $newKey)
        {
            if (array_key_exists($oldKey, $result[$method])) {
                $result[$method][$newKey] = $result[$method][$oldKey];
                $result[$method][$oldKey] = null;
                unset($result[$method][$oldKey]);
            }
        }

        return $result;
    }
266062
public function mergeTranslations(LocaleContract $locale = null, array $ignored = [])
    {
        $merged       = [];
        $translations = array_merge(
            is_null($locale) ? [] : $locale->getTranslations(),
            $this->getTranslations()
        );

        foreach ($translations as $key => $trans) {
            if ( ! Str::startsWith($key, $ignored)) {
                $merged[$key] = $trans;
            }
        }

        return $merged;
    }
753848
protected function mergeDefinitions(array $definitions)
    {
        return array_merge(
            $definitions,
            array(
                new InputOption('config', 'c', InputOption::VALUE_OPTIONAL, 'Path to config file. Inline options override.', Resque::DEFAULT_CONFIG_FILE),
                new InputOption('include', 'I', InputOption::VALUE_OPTIONAL, 'Path to include php file'),
                new InputOption('host', 'H', InputOption::VALUE_OPTIONAL, 'The Redis hostname.', Resque\Redis::DEFAULT_HOST),
                new InputOption('port', 'p', InputOption::VALUE_OPTIONAL, 'The Redis port.', Resque\Redis::DEFAULT_PORT),
                new InputOption('scheme', null, InputOption::VALUE_REQUIRED, 'The Redis scheme to use.', Resque\Redis::DEFAULT_SCHEME),
                new InputOption('namespace', null, InputOption::VALUE_REQUIRED, 'The Redis namespace to use. This is prefixed to all keys.', Resque\Redis::DEFAULT_NS),
                new InputOption('password', null, InputOption::VALUE_OPTIONAL, 'The Redis AUTH password.'),
                new InputOption('log', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Specify the handler(s) to use for logging.'),
                new InputOption('events', 'e', InputOption::VALUE_NONE, 'Outputs all events to the console, for debugging.'),
            )
        );
    }
1165310
public static function mergeConfigurations($target, $source)
    {
        foreach (['attributes', 'entities', 'relationships', 'autocode', 'languages', 'frameworks', 'orms'] as $configurationPart) {
            if (isset($source[$configurationPart])) {
                $target[$configurationPart] = self::mergeArrays($target[$configurationPart], $source[$configurationPart]);
            }
        }

        return $target;
    }
1364926
protected function mergeArrays()
    {
        $arrays = func_get_args();
        $merged = array();

        foreach ($arrays as $array) {
            foreach ($array as $key => $value) {
                $merged = $this->setValue($key, $value, $merged);
            }
        }

        return $merged;
    }
141298
protected function mergeParametersDefaults(array $criteriaParameters, array $parameters)
    {
        $tmp = [];
        foreach ($criteriaParameters as $cpValues) {
            $tmp = $this->collectionMergeDefault($tmp, $cpValues);
        }

        $parameters = $this->collectionMergeDefault($tmp, $parameters);

        return $parameters;
    }
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;
    }
335697
public function mergeShared(array $context)
    {
        // we don't use array_merge as the context being generally
        // bigger than globals, this code is faster.
        foreach ($this->app['view']->getShared() as $key => $value) {
            if (!array_key_exists($key, $context)) {
                $context[$key] = $value;
            }
        }

        return $context;
    }
1342443
function MergeDone($srcTable, $dstTable, $pkeys, $srcignoreflds, $setsrc,
		$srcUpdateDateFld,
		$srcCopyFlagFld,  $flagvals=array('Y','N','P','='),
		$srcCopyDateFld = false,
		$dstCopyDateFld = false,
		$whereClauses = '',
		$orderBy = '', # MUST INCLUDE THE "ORDER BY" suffix
		$copyDoneFlagIdx = 2,
		$defaultDestRaiseErrorFn = '')
	{
		return  $this->Merge($srcTable, $dstTable, $pkeys, $srcignoreflds, $setsrc,
		$srcUpdateDateFld,
		$srcCopyFlagFld,  $flagvals,
		$srcCopyDateFld,
		$dstCopyDateFld,
		$whereClauses,
		$orderBy, # MUST INCLUDE THE "ORDER BY" suffix
		$copyDoneFlagIdx,
		$defaultDestRaiseErrorFn);
	}
1148051
private function mergeDefaults(&$options)
    {
        // Merging optimization for when no headers are present
        if (!isset($options['headers'])
            || !isset($this->defaults['headers'])) {
            $options = array_replace_recursive($this->defaults, $options);
            return null;
        }

        $defaults = $this->defaults;
        unset($defaults['headers']);
        $options = array_replace_recursive($defaults, $options);

        return $this->defaults['headers'];
    }