@param string $file

@return MutableBag|MutableBag[]
519243
protected function parse(string $file): MutableBag
    {
        $data = Yaml::parse(file_get_contents($file));

        return MutableBag::fromRecursive($data);
    }
661417
public function file($file)
    {
        if (\in_array($file, ['global', 'system', 'local'])) {
            $this->arguments[] = '--' . $file;
        } else {
            $this->arguments[] = '--file';
            $this->arguments[] = $file;
        }
        return $this;
    }
1022183
public static function fileToArray($file)
    {
        if (! is_file($file) && ! filter_var($file, FILTER_VALIDATE_URL)) {
            self::arrayToFile([], $file);
        }

        $json = @file_get_contents($file);
        $array = json_decode($json, true);
        $lastError = JsonLastError::check();

        return $array === null || !is_null($lastError) ? false : $array;
    }
1031285
protected function read(string $file):array{

		if(!is_readable($file) || !is_file($file)){
			throw new \Exception('invalid file: '.$file);
		}

		// Read file into an array of lines with auto-detected line endings
		$autodetect = ini_get('auto_detect_line_endings');
		ini_set('auto_detect_line_endings', '1');
		$lines = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
		ini_set('auto_detect_line_endings', $autodetect);

		if(!is_array($lines) || empty($lines)){
			throw new \Exception('error while reading file: '.$file);
		}

		return array_map('trim', $lines);
	}
766356
public function analyze_js(string $file): array
  {
    $res = [];
    $js = file_get_contents($file);
    if ( $tmp = \Gettext\Translations::fromJsCodeString($js, [
      'functions' => [
        '_' => 'gettext',
        'bbn._' => 'gettext'
      ],
      'file' => $file
      ]) ){
      foreach ( $tmp->getIterator() as $r => $tr ){
        $res[] = $tr->getOriginal();
      }
      $this->parser->mergeWith($tmp);
    }
    return array_unique($res);
  }
169677
public static function getLines($file)
    {
        return !is_file($file) || !is_readable($file) || !($lines = @file($file, FILE_SKIP_EMPTY_LINES)) ? [] : $lines;
    }
181766
public static function rmfile($file)
    {
        if (is_file($file)) {
            return chmod($file, 0777) && unlink($file);
        } else {
            throw new RuntimeException(sprintf(
                'Invalid file path supplied "%s"', $file
            ));
        }
    }
916275
private function findMediaObjectsForMediaFile(string $file): array
    {
        return DB::table('media')
            ->join('media_file', static function (JoinClause $join): void {
                $join
                    ->on('media_file.m_file', '=', 'media.m_file')
                    ->on('media_file.m_id', '=', 'media.m_id');
            })
            ->join('gedcom_setting', 'media.m_file', '=', 'gedcom_setting.gedcom_id')
            ->where(DB::raw('setting_value || multimedia_file_refn'), '=', $file)
            ->select(['media.*'])
            ->distinct()
            ->get()
            ->map(Media::rowMapper())
            ->all();
    }
727157
protected function getSize($file)
    {
        if (! file_exists($file)) {
            return [];
        }

        $info = pathinfo($file);
        $image = null;
        switch (strtolower($info['extension'])) {
            case 'gif':
                $image = imagecreatefromgif($file);
                break;
            case 'jpg':
            case 'jpeg':
                $image = imagecreatefromjpeg($file);
                break;
            case 'png':
                $image = imagecreatefrompng($file);
                break;
            default:
                break;
        }
        if ($image == null) {
            return [];
        } else {
            return [imagesx($image), imagesy($image)];
        }
    }
1344147
private static function loadDefinitionsFromFile(string $file): array
    {
        if (!\is_file($file) || !\is_readable($file)) {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException(\sprintf('"%s" must be a readable file', $file));
            // @codeCoverageIgnoreEnd
        }

        $definitions = require $file;

        if (!\is_array($definitions)) {
            throw new \RuntimeException(
                \sprintf('Definitions file should return an array. "%s" returned', \gettype($definitions))
            );
        }

        return $definitions;
    }
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'];
    }
250001
protected function loadDefinitionFromFile(/*# string */ $file)/*# : array */
    {
        // check first
        $this->checkFileExistence($file);

        // get definition type and loader class base on suffix
        list($type, $class) = $this->getFileTypeClass($file);

        // load into an array
        $data = $class::loadFromFile($file);

        // associate with definition type
        return $type ? [$type => $data] : $data;
    }
887606
protected function handleMultipleFile($file) : array
    {
        $fileBag = [];

        foreach ($file['name'] as $idx => $name) {
            $uploadedFile = null;

            //The current file was uploaded successfully?
            if (!$file[$idx]['error']) {
                $uploadedFile = new UploadedFile(
                    $file[$idx]['tmp_name'],
                    $file[$idx]['name'],
                    $file[$idx]['type']
                );
            }

            $fileBag[$idx] = $uploadedFile;
        }

        return $fileBag;
    }
1332695
protected function parseFromFile(string $file) : array
    {
        if (function_exists('yaml_parse_file')) {
            try {
                set_error_handler(function ($code, $message) {
                    throw new \RuntimeException(
                        $message,
                        $code
                    );
                });

                $array = yaml_parse_file($file);
                restore_error_handler();
                if (!is_array($array)) {
                    throw new \RuntimeException(
                        sprintf(
                            'Configuration file in : %s does not return array',
                            $file
                        )
                    );
                }
                return $array;
            } catch (\Throwable $e) {
                restore_error_handler();
                throw  $e;
            }
        }

        $array =  SymfonyYAML::parse(file_get_contents($file));
        if (!is_array($array)) {
            throw new \RuntimeException(
                sprintf(
                    'Configuration file in : %s does not return array',
                    $file
                )
            );
        }

        return $array;
    }
1339081
public static function extractFromFile($file)
    {
        $contents = file_get_contents($file->originalFilePath());
        
        preg_match(self::HEADER_PATTERN, $contents, $m);
        if (!$m) {
            return [[], $contents];
        }
        
        unset($contents);
        $lines      = file($file->originalFilePath(), FILE_IGNORE_NEW_LINES);
        $directives = [];
        
        foreach (preg_split('/\v/', $m[0]) as $lineNum => $line) {
            if (preg_match(self::DIRECTIVE_PATTERN, $line, $m)) {
                $dirValue = array_filter(explode(' ', $m[1]));
                $directives[] = [
                    'command'  => $dirValue[0],
                    'argument' => isset($dirValue[1]) ? $dirValue[1] : null,
                    'line'     => $lineNum + 1
                ];
                
                unset($lines[$lineNum]);
            }
        }
        
        return [$directives, implode("\n", $lines)];
    }
1371449
public function upload($file) {

        if (is_array($file['name'])) {
            $files = $this->reArrayFiles($file);

            $results = [];

            foreach ($files as $singleFile) {
                $result = $this->uploadSingle($singleFile);

                $results[] = $result;
            }

            return $results;

        } else {

            return Array($this->uploadSingle($file));

        }
    }
1319221
public function add($file)
    {
        if ($file instanceof SplFileInfo) {
            throw InvalidArgumentException::create(
                sprintf(
                    '%1$s/FileBag|%1$s/File[]|%1$s/File',
                    __NAMESPACE__
                ),
                $file
            );
        }

        return parent::add($file);
    }