src/Robo/Common/YamlMunge.php
public static function arrayMergeRecursiveExceptEmpty(array &$array1, array &$array2) {
    $merged = $array1;

    foreach ($array2 as $key => &$value) {
      if (is_array($value) && isset($merged[$key]) && is_array($merged[$key]) && !empty($value)) {
        $merged[$key] = self::arrayMergeRecursiveExceptEmpty($merged[$key], $value);
      }
      else {
        $merged[$key] = $value;
      }
    }

    return $merged;
  }
public static function arrayMergeRecursiveExceptEmpty(array &$array1, array &$array2) {
    $merged = $array1;

    foreach ($array2 as $key => &$value) {
      if (is_array($value) && isset($merged[$key]) && is_array($merged[$key]) && !empty($value)) {
        $merged[$key] = self::arrayMergeRecursiveExceptEmpty($merged[$key], $value);
      }
      else {
        $merged[$key] = $value;
      }
    }

    return $merged;
  }
public static function arrayMergeRecursiveExceptEmpty ( array & $ array1 , array & $ array2 ) { $ merged = $ array1 ; foreach ( $ array2 as $ key => & $ value ) { if ( is_array ( $ value ) && isset ( $ merged [ $ key ] ) && is_array ( $ merged [ $ key ] ) && ! empty ( $ value ) ) { $ merged [ $ key ] = self :: arrayMergeRecursiveExceptEmpty ( $ merged [ $ key ] , $ value ) ; } else { $ merged [ $ key ] = $ value ; } } return $ merged ; }
Recursively merges arrays UNLESS second array is empty.

Preserves data types. If value in second array is empty, it will REPLACE
the corresponding key in the first array, rather than being merged.

@param array $array1
The first array.
@param array $array2
The second array.

@return array
Recursively merges arrays UNLESS second array is empty .