src/Common/Util/ArrayToolkit.php
public static function mergeScalarSafe(array &$first, array &$second)
    {
        $merged = $first;

        foreach ($second as $key => &$value) {
            if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
                $merged[$key] = self::mergeScalarSafe($merged[$key], $value);
            } else {
                $merged[$key] = $value;
            }
        }

        return $merged;
    }
public static function mergeScalarSafe(array &$first, array &$second)
    {
        $merged = $first;

        foreach ($second as $key => &$value) {
            if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
                $merged[$key] = self::mergeScalarSafe($merged[$key], $value);
            } else {
                $merged[$key] = $value;
            }
        }

        return $merged;
    }
public static function mergeScalarSafe ( array & $ first , array & $ second ) { $ merged = $ first ; foreach ( $ second as $ key => & $ value ) { if ( is_array ( $ value ) && isset ( $ merged [ $ key ] ) && is_array ( $ merged [ $ key ] ) ) { $ merged [ $ key ] = self :: mergeScalarSafe ( $ merged [ $ key ] , $ value ) ; } else { $ merged [ $ key ] = $ value ; } } return $ merged ; }
Merges the given second array over the first one similar to the PHP internal
array_merge_recursive method, but does not change scalar values into arrays
when duplicate keys occur.

@param array $first first or default array
@param array $second array to merge over the first array

@return array merged result with scalar values still being scalar
Merges the given second array over the first one similar to the PHP internal array_merge_recursive method but does not change scalar values into arrays when duplicate keys occur .