TODO

@param $file
@param array $config
@return bool|mixed|resource
182183
public function open($file, $config = array())
    {
        $this->separator = $this->detectSeparator($file);
        return $this->handle = fopen($file, 'rb');
    }
1208451
public function make(array $config): SearchClient
    {
        $config = $this->getConfig($config);

        return $this->getClient($config);
    }
525860
protected function loadFile(string $file, array $options)
    {
        if (isset($options['num']) || isset($options['callbacks'])) {
            throw new BadMethodCallException("Options 'num' and 'callbacks' aren't supported with the Symfony"
                ." YAML parser. Please install the yaml PHP extension.");
        }

        try {
            return $this->parser->parseFile($file, Yaml::PARSE_OBJECT_FOR_MAP);
        } catch (ParseException $parseException) {
            $err = $parseException->getMessage();
            throw new LoadException("Failed to load settings from '$file': {$err}", 0, $parseException);
        }
    }
1144098
public static function readConfigFile($file = self::DEFAULT_CONFIG_FILE)
    {
        if (!is_string($file)) {
            throw new InvalidArgumentException('The config file path must be a string, type passed "'.gettype($file).'".');
        }

        $baseDir = realpath(dirname($file));
        $searchDirs = array(
            $baseDir.'/',
            $baseDir.'/../',
            $baseDir.'/../../',
            $baseDir.'/config/',
            $baseDir.'/../config/',
            $baseDir.'/../../config/'
        );

        $filename = basename($file);

        $configFile = null;
        foreach ($searchDirs as $dir) {
            if (realpath($dir.$filename) and is_readable($dir.$filename)) {
                $configFile = realpath($dir.$filename);
                break;
            }
        }

        if (is_null($configFile) and $file !== self::DEFAULT_CONFIG_FILE) {
            throw new InvalidArgumentException('The config file "'.$file.'" cannot be found or read.');
        }

        if (!$configFile) {
            return static::$config;
        }

        // Try to parse the contents
        try {
            $yaml = Yaml\Yaml::parse(file_get_contents($configFile));
        } catch (Yaml\Exception\ParseException $e) {
            throw new Exception('Unable to parse the config file: '.$e->getMessage());
        }

        return static::$config = $yaml;
    }
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'));
	}
814095
public function copy($from, $to, array $config = [])
    {
        [$fsFrom, $from] = $this->getFilesystemAndPath($from);
        $buffer = $fsFrom->readStream($from);

        if ($buffer === false) {
            return false;
        }

        [$fsTo, $to] = $this->getFilesystemAndPath($to);
        $result = $fsTo->writeStream($to, $buffer, $config);

        if (\is_resource($buffer)) {
            \fclose($buffer);
        }

        return $result;
    }
117184
public function make(array $config): Facebook
    {
        $config = $this->getConfig($config);

        return $this->getClient($config);
    }
763099
public function copy(string $from, string $to, array $config = []): bool
    {
        list($prefixFrom, $from) = $this->getPrefixAndPath($from);

        if (($buffer = $this->getFileSystem($prefixFrom)->readStream($from)) === false) {
            return false;
        }

        unset($prefixFrom, $from);

        list($prefixTo, $to) = $this->getPrefixAndPath($to);

        if ($this->getFileSystem($prefixTo)->writeStream($to, $buffer, $config)) {
            unset($prefixTo, $to, $buffer);
            return true;
        }

        return false;
    }
802697
private function load($file, $dir = '')
    {
        $path = config_path().'/'.$dir;
        $handle = opendir($path);
        $ignore = ['.', '..'];
        while ($f = readdir($handle)) {
            if (!in_array($f, $ignore)) {
                if (is_dir($path.$f)) {
                    if (file_exists($path.$f.'/'.$file.'.php')) {
                        return $this->load($file, $f);
                    }
                } else {
                    $filename = explode('.', $f)[0];
                    if ($filename == $file) {
                        return require $path.'/'.$f;
                    }
                }
            }
        }
        closedir($handle);

        return false;
    }
1130191
public function createFileSystem(array $config)
    {

        $this->validateS3Config($config, $this->requiredAwsKeys);

        $client = S3Client::factory([
            FileUploadConstants::AWS_CREDENTIALS => [
                FileUploadConstants::KEY => $config[FileUploadConstants::AWS_KEY],
                FileUploadConstants::SECRET => $config[FileUploadConstants::AWS_SECRET],
            ],
            FileUploadConstants::REGION => $config[FileUploadConstants::AWS_REGION],
            FileUploadConstants::VERSION => FileUploadConstants::LATEST,
        ]);

        $adapter = new AwsS3Adapter(
            $client,
            $config[FileUploadConstants::BUCKET_NAME],
            isset($config[FileUploadConstants::BUCKET_PREFIX]) ? $config[FileUploadConstants::BUCKET_PREFIX] : null
        );

        $filesystem = new Filesystem($adapter);

        return $filesystem;
    }
1114221
private static function includeConfigFile(array &$config, $config_file, File $base_dir, ConfigReader $reader)
    {
        // try relative path
        $file = new File($config_file, $base_dir);
        
        if ( $file->exists() ){
            $included = self::loadConfigFileByFormat( $file, $reader );
            $config = array_merge_recursive($config, $included);
            return;
        }
        
        // try full path
        $file = new File($config_file);
        
        if ( $file->exists() ){
            $included = self::loadConfigFileByFormat( $file, $reader );
            $config = array_merge_recursive($config, $included);
            return;
        }
        
        throw new IncludeConfigFileNotFoundException($config_file);
    }
1066891
public function loadFromFile(string $file, array $options = []): Dom
    {
        return $this->loadStr(file_get_contents($file), $options);
    }
539352
private function parseConfigFile($file)
    {
        Assertion::file($file, 'Can\'t parse config file. File does not exist: ' . $file);

        $config = Yaml::parse(file_get_contents($file));

        if (is_null($config)) {
            $config = array();
        }

        return $config;
    }
894850
function load(string $file = null)
    {
        if ($file == null) {
            $file = static::$configFile;
        }
        if (!file_exists($file)) {
            return false;
        }

        $a = json_decode(file_get_contents($file));

        if (isset($a->css)) {
            $this->css = $a->css;
        }

        if (isset($a->js)) {
            $this->js = $a->js;
        }
        
        if (isset($a->jss)) {
            $this->jss = $a->jss;
        }
        
        return true;
    }
1017421
public static function getFile( $file ) {
		$file = Storage::getFile( Route::DOCUMENT_ROOT() . 'app/config/' . $file . '.json' );
		$out  = Parser::json( $file );

		return $out;
	}
903058
public function loadConfig(string $file): self
    {
        if (file_exists($file) === false) {
            throw new \RuntimeException('No such config file.');
        }
        $data = json_decode(file_get_contents($file), true);
        if ($data === null) {
            throw new \RuntimeException('Invalid config file.');
        }
        return $this->setConfigs($data);
    }
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;
    }