Merge in separate environment specific files.

@param string                  $file
@param MutableBag|MutableBag[] $envs

@return MutableBag|MutableBag[]
769894
protected function mergeExternalFiles(string $file, MutableBag $envs): MutableBag
    {
        $extPos = strrpos($file, '.');
        $pathTemplate = substr_replace($file, '.%s.', $extPos, 1);
        foreach ($envs as $name => $config) {
            // config.yml -> config.production.yml
            $envFile = sprintf($pathTemplate, $name);
            if (!is_readable($envFile)) {
                continue;
            }
            $envConfig = $this->parse($envFile);
            $envs[$name] = $config->replaceRecursive($envConfig);
        }

        return $envs;
    }
550233
protected function obtainMySQLDatabaseInfoFromEnv($file)
    {
        $env = (new Loader($file))->parse()->toArray();

        if (! array_key_exists('DB_CONNECTION', $env)  || $env['DB_CONNECTION'] != 'mysql') {
            return null;
        }

        if (! array_key_exists('DB_DATABASE', $env) ||
             ! array_key_exists('DB_USERNAME', $env) ||
             ! array_key_exists('DB_PASSWORD', $env)) {
            return null;
        }

        return [
          'name' => $env['DB_DATABASE'],
          'user' => $env['DB_USERNAME'],
          'password' => $env['DB_PASSWORD'],
        ];
    }
240149
public function getRelatedFiles(array $files = [])
    {
        if (in_array($this->fileName, $files)) {
            return $files;
        }

        $files[] = $this->fileName;
        foreach ($this->properties as $property) {
            if (in_array($property->getType(), [Reflection\Property::TYPE_COLLECTION, Reflection\Property::TYPE_ENTITY])) {
                $files += self::load($property->getTypeOption())->getRelatedFiles($files);
            }
        }
        return $files;
    }
1258586
private function loadFile ($file)
	{
		if (!isset ($this->files[$file]))
		{
			$filename = $this->folder . $file . '.php';

			// First load these
			if (file_exists ($filename))
			{
				$this->files[$file] = include ($filename);
			}

			// Now overload with environment values
			if (isset ($this->environment))
			{
				$filename = $this->folder . $this->environment . '/' . $file . '.php';
				if (file_exists ($filename))
				{
					$this->merge ($file, include ($filename));
				}
			}

		}
	}
560523
protected function loadEnvFile($file) {
    list($name, ,) = explode('.', $file->name);
    $this->environments[$name] = $this->extractEnv($file->filename);
    $this->environments[$name]['filename'] = $this->parseFilename($file->filename);
  }
1307856
protected function mergeExistingTranslations($file, $outputFile, $translations)
    {
        if (file_exists($outputFile)) {
            $extension = pathinfo($outputFile, PATHINFO_EXTENSION);
            $loader = $this->getContainer()->get('lexik_translation.translator')->getLoader($extension);
            $messageCatalogue = $loader->load($outputFile, $file->getLocale(), $file->getDomain());

            $translations = array_merge($messageCatalogue->all($file->getDomain()), $translations);
        }

        return $translations;
    }
334095
public function load($file = '@root/.env')
    {
        $this->_file = $file;

        $file = $this->alias->resolve($file);
        $parsed_file = $file . '.php';
        if (is_file($parsed_file)) {
            /** @noinspection PhpIncludeInspection */
            $env = require $parsed_file;
        } elseif (is_file($file)) {
            $lines = file($file, FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES);
            if ($lines === false) {
                throw new RuntimeException(['read `:file` failed', 'file' => $file]);
            }
            $env = $this->parse($lines);
        } else {
            throw new FileNotFoundException(['.env file is not found: :file', 'file' => $file]);
        }

        /** @noinspection AdditionOperationOnArraysInspection */
        $this->_env += $env;

        if ($this->_toEnv) {
            /** @noinspection AdditionOperationOnArraysInspection */
            $_ENV += $env;
        }

        return $this;
    }
1053590
def merge_base(all_envs)
      base = all_envs["base"] || {}
      all_envs.each do |lono_env, env_settings|
        all_envs[lono_env] = base.merge(env_settings) unless lono_env == "base"
      end
      all_envs
    end
519243
protected function parse(string $file): MutableBag
    {
        $data = Yaml::parse(file_get_contents($file));

        return MutableBag::fromRecursive($data);
    }
660125
function (file, enc, cb) {
        var yaml_files = options.src;

        if (typeof yaml_files === 'string') {
            yaml_files = [yaml_files];
        }

        var yaml_data = {};

        // Read all files in order, and override if later files contain same values.
        for (var i = 0; i < yaml_files.length; i++) {
            yaml_data = Object.assign(yaml_data, readYamlFile(yaml_files[i]));
        }

        var current_data = file[options.property];
        var new_data = null;

        // Merge with possible previous data.
        if (options.override) {
            new_data = Object.assign(current_data, yaml_data);
        } else {
            new_data = Object.assign(yaml_data, current_data);
        }

        file[options.property] = new_data;

        cb(null, file);
    }
1075726
public static function merge(...$options) {
            $o = [];

            foreach ($options as $opt) {
                if ($opt instanceof Options) {
                    $o = array_merge($o, $opt->toArray());
                } elseif (is_array($opt)) {
                    $o = array_merge($o, $opt);
                }
            }

            return new self(Util::trimNulls($o));
        }
21885
public function addFile($file)
    {
        if (is_string($file)) {
            $file = array($file);
        }

        if (is_array($file)) {
            foreach ($file as $name) {
                if (!isset($this->_files[$name]) && !empty($name)) {
                    $this->_files[$name] = $name;
                }
            }
        }

        return $this;
    }
402486
public static function parseFiles($paths, $file) {
		if ($paths === null) {
			$paths = ROOT . DS . 'config' . DS;
		}

		$list = [];
		foreach ((array)$paths as $path) {
			$list += static::parseFile($path . $file);
		}

		return $list;
	}
1115054
public function share($file)
    {
        $mapping = $this->config->get('remote.directories');

        // Get path to current file and shared file
        $currentFile = $this->releasesManager->getCurrentReleasePath($file);
        $sharedFile = preg_replace('#'.$mapping['releases'].'/[0-9]+/#', $mapping['shared'].'/', $currentFile);

        // If no instance of the shared file exists, use current one
        if (!$this->modulable->fileExists($sharedFile)) {
            $this->modulable->move($currentFile, $sharedFile);
        }

        $this->explainer->line('Sharing file '.$currentFile);

        return $this->modulable->symlink($sharedFile, $currentFile);
    }
641873
public function setMerged(array $files)
    {
        if (!empty($files)) {
            foreach ($files as $_file) {
                if (is_array($_file) && isset($_file['file'])) {
                    if (isset($_file['media'])) {
                        $this->add($_file['file'], $_file['media']);
                    } else {
                        $this->add($_file['file']);
                    }
                } elseif (is_string($_file)) {
                    $this->add($_file);
                }
            }
        }
        return $this;
    }
709891
public static function getModulesByFile($file = 'Module.php')
    {
        $modules = Module::getModules();
        $source = app_path('Modules' . DIRECTORY_SEPARATOR . '{author}' . DIRECTORY_SEPARATOR . '{module}' . DIRECTORY_SEPARATOR . $file);
        $files = [];
        if ($modules && count($modules))
            foreach ($modules as $author => $subModules)
            {
                foreach ($subModules as $module)
                {
                    $data = ['{author}' => $module['author'], '{module}' => $module['name']];
                    $real_source = str_replace(array_keys($data), array_values($data), $source);
                    if (\File::exists($real_source))
                    {
                        $files[] = [
                            'author' => $author,
                            'module' => $module,
                            'name' => $author . DIRECTORY_SEPARATOR . $module['name'],
                            'installed' => isset($module['installed']),
                        ];
                    }
                }
            }
        return $files;
    }
1155283
protected static function mergeJsonData( $file, $data )
    {
        return static::saveJsonData( $file, ArrayUtils::merge(
            (array) static::loadJsonData( $file ),
            $data
        ) );
    }