public static function mungeFiles($file1, $file2) {
    $default_contents = [];
    $file1_contents = (array) json_decode(file_get_contents($file1), TRUE) + $default_contents;
    $file2_contents = (array) json_decode(file_get_contents($file2), TRUE) + $default_contents;

    $output = self::mergeKeyed($file1_contents, $file2_contents);

    // Ensure that require and require-dev are objects and not arrays.
    if (array_key_exists('require', $output) && is_array($output['require'])) {
      $output['require'] = (object) $output['require'];
    }
    if (array_key_exists('require-dev', $output)&& is_array($output['require-dev'])) {
      $output['require-dev'] = (object) $output['require-dev'];
    }

    $output_json = json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

    return $output_json;
  }