Merge the environment variables from all installers.

@return array
514547
public function mergeEnv()
    {
        $env = [];
        foreach ($this->installers as $installer) {
            $env = array_merge($env, $installer->getEnv());
        }

        return $env;
    }
724652
protected function generateEnv()
    {
        $env = null;

        // Get the existing .env file contents to replace
        $envPath = $this->laravel->environmentFilePath();

        if (! file_exists($envPath)) {
            // Create the .env file from the example file
            copy($envPath.'.example', $envPath);
            $this->callSilent('key:generate', ['--force' => true]);
        }

        $env = file_get_contents($envPath);

        // Loop over all of the keys we can set and replace the values that are set
        foreach ($this->keys as $key => $var) {
            // Skip if it's not set
            if (! isset($this->$var)) {
                continue;
            }

            $env = preg_replace(
                $this->keyReplacementPattern($key),
                $key.'='.(is_string($this->$var) ? '"'.$this->$var.'"' : $this->$var),
                $env,
                1
            );
        }

        return $env;
    }
857917
public function merge()
    {
        // TODO: verify analysis phase run
        foreach ($this->dataFiles as $replicate => $fractions) {
            $firstFile = current($fractions);
            // Write header
            $this->writeHeader($firstFile['path'], $this->spectrumCount[$replicate], $this->outputFiles[$replicate]);

            // Resets vars
            $this->spectrumIdRef = array();
            $this->timeOffset = 0;
            $this->indexOffset = 0;
            $this->idOffset = 0;

            foreach ($fractions as $fractionIndex => $file) {
                $this->writeSpectrum($file['path'], $this->outputFiles[$replicate],
                    $this->fractionOffsets[$fractionIndex]);
            }

            $this->writeFooter($firstFile['path'], $this->outputFiles[$replicate]);
        }
    }
1184150
private function getEnvironmentVariables()
    {
        // Initialize from globals, allow override of special keys via putenv calls.
        $variables = $this->inheritEnvironment
            ? array_replace($_ENV, $_SERVER, $this->environment)
            : $this->environment;

        foreach (array_keys($variables) as $name) {
            if (false !== ($value = getenv($name))) {
                $variables[$name] = $value;
            }
        }

        return $variables;
    }
1372808
protected function getDefaultCommands()
    {
        $commands = parent::getDefaultCommands();

        $commands[] = new Command\App\AppAdd();
        $commands[] = new Command\App\AppRemove();
        $commands[] = new Command\Environment\EnvironmentAdd();
        $commands[] = new Command\Environment\EnvironmentRemove();
        $commands[] = new Command\Environment\EnvironmentEnable();
        $commands[] = new Command\Environment\EnvironmentDisable();
        $commands[] = new Command\Environment\EnvironmentDeploy();
        $commands[] = new Command\Environment\EnvironmentShell();
        $commands[] = new Command\Environment\EnvironmentScale();
        $commands[] = new Command\Environment\EnvironmentProxyEnable();
        $commands[] = new Command\Environment\EnvironmentTest();
        $commands[] = new Command\Environment\EnvironmentRebuild();
        $commands[] = new Command\Environment\EnvironmentDomains();
        $commands[] = new Command\Environment\EnvironmentDrush();
        $commands[] = new Command\Environment\EnvironmentRun();
        $commands[] = new Command\Environment\EnvironmentUpdate();
        $commands[] = new Command\Status();
        $commands[] = new Command\Queue();

        return $commands;
    }
854715
private static function get_process_env_variables() {
		// Ensure we're using the expected `wp` binary
		$bin_dir        = getenv( 'WP_CLI_BIN_DIR' ) ?: realpath( dirname( dirname( __DIR__ ) ) . '/bin' );
		$vendor_dir     = self::get_vendor_dir();
		$path_separator = Utils\is_windows() ? ';' : ':';
		$env            = array(
			'PATH'      => $bin_dir . $path_separator . $vendor_dir . $path_separator . getenv( 'PATH' ),
			'BEHAT_RUN' => 1,
			'HOME'      => sys_get_temp_dir() . '/wp-cli-home',
		);

		$config_path = getenv( 'WP_CLI_CONFIG_PATH' );
		if ( false !== $config_path ) {
			$env['WP_CLI_CONFIG_PATH'] = $config_path;
		}

		$term = getenv( 'TERM' );
		if ( false !== $term ) {
			$env['TERM'] = $term;
		}

		$php_args = getenv( 'WP_CLI_PHP_ARGS' );
		if ( false !== $php_args ) {
			$env['WP_CLI_PHP_ARGS'] = $php_args;
		}

		$php_used = getenv( 'WP_CLI_PHP_USED' );
		if ( false !== $php_used ) {
			$env['WP_CLI_PHP_USED'] = $php_used;
		}

		$php = getenv( 'WP_CLI_PHP' );
		if ( false !== $php ) {
			$env['WP_CLI_PHP'] = $php;
		}

		$travis_build_dir = getenv( 'TRAVIS_BUILD_DIR' );
		if ( false !== $travis_build_dir ) {
			$env['TRAVIS_BUILD_DIR'] = $travis_build_dir;
		}

		$github_token = getenv( 'GITHUB_TOKEN' );
		if ( false !== $github_token ) {
			$env['GITHUB_TOKEN'] = $github_token;
		}
		return $env;
	}
160376
protected function getDefaultInstall()
    {
        $data = array();
        $data['database']['port'] = 3306;
        $data['database']['user'] = 'root';
        $data['database']['type'] = 'mysql';
        $data['database']['host'] = 'localhost';
        $data['database']['password'] = '';
        $data['store']['basepath'] = '';
        $data['store']['title'] = 'GPL Cart';
        $data['store']['host'] = 'localhost';
        $data['store']['timezone'] = date_default_timezone_get();

        return $data;
    }
435183
private function prepareEnvironment()
    {
        $filesystem = $this->make(Filesystem::class);


        if ($filesystem instanceof Filesystem) {
            if ($filesystem->exists($path = $this->getEnvironmentPath())) {
                $env = $filesystem->get($path);


                array_map(
                    function ($env) {

                        if ($env !== '' && $env !== null) {
                            putenv($env);
                        }
                    },
                    explode("\n", $env)
                );

                $this->environments = count($_ENV) ? $_ENV : isset($_SERVER['ENV']) ? $_SERVER['ENV'] : [];
            }
        }

    }
232484
protected function mergePackageConfiguration()
    {
        $defaultConfig = require self::CONFIG_PATH;
        $currentConfig = $this->config->get('redis-sentinel', [ ]);

        $this->packageConfig = array_merge($defaultConfig, $currentConfig);
    }
1290355
protected static function mergeConfiguredEmails($config, $env)
    {
        // Normalise config list
        $normalised = [];
        $source = (array)static::config()->get($config);
        foreach ($source as $address => $name) {
            if ($address && !is_numeric($address)) {
                $normalised[$address] = $name;
            } elseif ($name) {
                $normalised[$name] = null;
            }
        }
        $extra = Environment::getEnv($env);
        if ($extra) {
            $normalised[$extra] = null;
        }
        return $normalised;
    }
475431
private function loadConfigurations($environment)
    {
        $configs = new ConfigObject([]);
        $configFolder = $this->applicationAbsolutePath . 'App/Config/' . $environment;
        $h = scandir($configFolder);

        foreach ($h as $configFile) {
            if (strpos($configFile, 'yaml') === false) {
                continue;
            }

            $configs->mergeWith($this->config()->yaml($configFolder . DIRECTORY_SEPARATOR . $configFile));
        }

        return $configs;
    }
691380
protected function getGlobalConfig(): array
    {
        $loader = new FileLoader();
        foreach ($this->globalConfigPaths as $path) {
            $loader->addPath($path);
        }

        return $loader->load();
    }
137991
public function getProjectPaths() {
		$paths = array();
		if(!file_exists($this->getEnvironmentDir())) {
			throw new Exception('The environment directory '.$this->getEnvironmentDir().' doesn\'t exist. Create it first and add some projects to it.');
		}
		foreach(scandir($this->getEnvironmentDir()) as $project) {
			// Exlcude dot-prefixed directories (.git was getting in the way)
			if(preg_match('/^[^\.]/', $project)) {
				$path = $this->getEnvironmentDir().'/'.$project;
				if(is_dir($path) && $project!='.' && $project!='..') {
					$paths[] = $project;
				}
			}
		}
		sort($paths);
		return array_values($paths);
	}
328612
protected function mergePackagesConfig()
    {
        $this->getInstaller()
             ->mergeConfigData(
                 'packages.local',
                 include __DIR__ . '/../../../../config/default.packages.php',
                 function ( & $config )
                 {
                     if ( ! empty( $config['modules']['Grid\Core']['enabledPackages'] ) )
                     {
                         foreach ( $config['modules']['Grid\Core']['enabledPackages'] as & $packages )
                         {
                             if ( ! is_array( $packages ) )
                             {
                                 $packages = array(
                                     $packages => (string) $packages
                                 );
                             }

                             $packages = array_unique( array_map(
                                 'strtolower',
                                 array_filter(
                                     $packages,
                                     function ( $package )
                                     {
                                         return (bool) preg_match(
                                             '#^[a-z0-9_-]+/[a-z0-9_-]+$#i',
                                             $package
                                         );
                                     }
                                 )
                             ) );
                         }
                     }

                     return $config;
                 }
             );
    }
930858
protected function getModuleConfig(): array
    {
        $merged = [];
        $merger = $this->getMerger();
        foreach ($this->getModules() as $module) {
            if ($module instanceof ConditionProviderInterface && $module->isConditioned() === true) {
                continue;
            }

            if ($module instanceof ConfigProviderInterface) {
                $merged = $merger->merge(
                    $merged,
                    $module->getConfig()->load()
                );
            }
        }

        return $merged;
    }
1160415
private function getEnvironment()
  {
    $env = new \Dotenv\Dotenv($this->basePath);
    $env->load();
    $this->env['env'] = getenv('APP_ENV');
    $this->env['debug'] = getenv('APP_DEBUG');
    $this->env['appSecret'] = getenv('APP_KEY');
  }
787179
public function getEnvironments()
    {
        $project = $this->getProject();
        if (!$project) {
            return [];
        }

        return array_keys($this->api->getEnvironments($project, false, false));
    }