Parse main config file.

@param string $file

@throws ConfigException If env extends an env not parsed yet.

@return MutableBag|MutableBag[]
518093
protected function parseMainFile(string $file): MutableBag
    {
        $envs = $this->parse($file);

        if (!$envs->has('default')) {
            $envs['default'] = new MutableBag();
        }

        $envs = $this->sortEnvs($envs);

        // Merge in parent configs for each environment, specified with "_extends" key
        foreach ($envs as $name => $config) {
            // Skip "default" since this is the based for all
            if ($name === 'default') {
                continue;
            }

            $parent = $config->remove('_extends', 'default');
            $envs[$name] = $envs[$parent]->replaceRecursive($config);
        }

        return $envs;
    }
1202483
protected function parseCombinedFile($file)
    {
        // Array with path and type keys
        if (is_array($file) && isset($file['path']) && isset($file['type'])) {
            return array($file['path'], $file['type']);
        }

        // Extract value from indexed array
        if (is_array($file)) {
            $path = array_shift($file);

            // See if there's a type specifier
            if ($file) {
                $type = array_shift($file);
                return array($path, $type);
            }

            // Otherwise convent to string
            $file = $path;
        }

        $type = File::get_file_extension($file);
        return array($file, $type);
    }
1014428
protected function readConfigurationFile($file)
    {
        if (! file_exists($file)) {
            throw InvalidSetupException::confNotFound($file);
        }
        if (! $json = file_get_contents($file)) {
            throw InvalidSetupException::confNotReadable($file);
        }
        if (! $config = json_decode($json)) {
            throw InvalidSetupException::confNotJson($file);
        }
        sodium_memzero($json);
        return $config;
    }
2144
public static function fromConfigFile($file)
	{
		if(!is_file($file))
		{
			throw new \RuntimeException(sprintf('Config file "%s" does not exist', $file));
		}
		
		$config = new Configuration(static::processConfigFileData(require $file));
		
		return new ConnectionManager($config->getConfig('ConnectionManager'));
	}
1070145
public  function loadConfig( $file ){
		if( file_exists( $file ) ){
			$config = include $file;
			$driver = $config['driver'];
			if( $driver == 'file'){
				$session = new \Wudimei\Session\File($config);
			}
			$this->session = $session;
		}
		else{
			throw new \Exception('sesstion config file "' . $file . '" does not exists');
		}
		

	}
44835
public function loadFile($file)
    {
        if (is_array($file)) {
            return collect($file)->mapWithKeys(function ($subFile, $key) {
                return [$key => $this->loadFile($subFile)];
            })->toArray();
        }

        return $this->parser->parseFile($file);
    }
599336
public static function config($config, $file = false) {
        $app = self::$app;
        if (isset ($app->configs [ $config ]) && !$file) {
            $confObj = $app->configs [ $config ];
        } else {
            $confObj = $file ? ConfigurationLoader::loadFromFile($config) : $app->configLoader->loadConfig($config);
            if (!$confObj) {
                $confObj = new Configuration ($config);
            }
            $app->configs [ $config ] = $confObj;
        }

        return $confObj;
    }
336169
public function getConfigVar($file)
    {
        $_config = [];

        $absFile = $this->appPath . 'config/' . $this->appStatus . '/' . $file . '.cfg.php';

        if (file_exists($absFile)) {
            include $absFile;
        }
        return $_config;
    }
73989
public function parse($file = null) {
        if ($file !== null) {
            $this->setFile($file);
        }
        if (empty($this->file)) {
            throw new LogicException("Need a file to parse.");
        }

        $simple_parsed = parse_ini_file($this->file, true);
        $inheritance_parsed = $this->parseSections($simple_parsed);
        return $this->parseKeys($inheritance_parsed);
    }
1105308
private function parseIniFile(string $file): array
    {
        $ini = parse_ini_file($file, true);

        if (!\is_array($ini)) {
            throw new \RuntimeException("File $file cannot be decoded");
        }

        if (!isset($ini['requires']) || !\is_array($ini['requires'])) {
            return [];
        }

        return $ini['requires'];
    }
1240991
public function loadFile($file)
    {
        if ($this->enableSpyc()) {
            if (! file_exists($file)) return [];

            // parse environment
            $content = file_get_contents($file);
            $content = $this->parseEnvironmentVariables($content);

            return $this->loadBySpyc($content);
        } else {
            throw new NotFoundException('Not found YAML parser.');
        }
    }
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;
    }
1353170
protected function parseFile($file)
    {
        try {
            $dom = XmlUtils::loadFile($file, array($this, 'validateSchema'));
        } catch (\InvalidArgumentException $e) {
            throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
        }

        return simplexml_import_dom($dom);
    }
987100
private function load(string $file): array
    {
        $file = basename($file);
        $fileName = realpath($this->configDirectory . '/' . $file);

        try {
            $json = @file_get_contents($fileName);

            if ($json !== false) {
                $configuration = json_decode($json, true);

                if (!empty($configuration)) {
                    if (!empty($configuration['@extends'])) {
                        $extends = $configuration['@extends'];
                        unset($configuration['@extends']);

                        $configuration = array_replace_recursive($this->load($extends), $configuration);
                    }
                } else {
                    throw new BerliozException(sprintf('Not a valid JSON configuration file "%s"', $file));
                }
            } else {
                throw new BerliozException(sprintf('Unable to load configuration file "%s"', $file));
            }
        } catch (BerliozException $e) {
            throw $e;
        } catch (\Exception $e) {
            throw new BerliozException(sprintf('Unable to load configuration file "%s"', $file));
        }

        return $configuration;
    }
602816
private function parseFile($file)
    {
        try {
            $dom = XmlUtils::loadFile($file, __DIR__.'/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd');
        } catch (\Exception $e) {
            throw new MappingException($e->getMessage(), $e->getCode(), $e);
        }

        return simplexml_import_dom($dom);
    }
607335
public static function parseFile($file)
    {
        if (!file_exists($file) || !is_readable($file)) {
            $message = "crontab config file is not exists or not readable";
            throw new \RuntimeException($message);
        }

        $tasks = array();
        $lines = file($file);
        foreach ($lines as $line) {
            $job = new JobParse($line);
            $tasks[] = $job->getTask();
        }

        return $tasks;
    }
1306200
protected static function loadFromFile(?string $file)
    {
        if ($file === null) {
            return [];
        }

        $ext = \strrchr($file, '.');
        if ($ext === '.yml' || $ext === '.yaml') {
            return static::loadYaml($file, $ext);
        }

        return require $file;
    }