Normalize the file info.

@param IFileInfo $file
@return array
557216
protected function normalizeFileInfo(IFileInfo $file)
    {
        $normalized = [
            'type' => $file->isDirectory() ? 'dir' : 'file',
            'path' => ltrim($this->getFilePath($file), $this->pathSeparator),
            'timestamp' => $file->getMTime()
        ];

        if (!$file->isDirectory()) {
            $normalized['size'] = $file->getSize();
        }

        return $normalized;
    }
1306587
private function getConfigurationNesting(SplFileInfo $file)
    {
        $directory = $this->normalizePath(dirname($file->getRealPath()));
        $directory = ltrim($directory, $this->userConfigurationPath);

        if ($tree = trim(str_replace(config_path(), '', $directory), DIRECTORY_SEPARATOR))
        {
            $tree = str_replace(DIRECTORY_SEPARATOR, '.', $tree).'.';
        }

        return $tree;
    }
1299034
public function parse(string $file): array
    {
        if (false === file_exists($file)) {
            throw InvalidArgumentExceptionFactory::createForFileCouldNotBeFound($file);
        }

        $data = include $file;

        if (false === is_array($data)) {
            throw TypeErrorFactory::createForInvalidFixtureFileReturnedData($file);
        }

        return $data;
    }
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;
    }
1142899
protected function normalizeFileInfo(array &$file, $localizer)
    {
        if (strtolower(array_get($file, 'type')) !== 'file') {
            throw new InternalServerErrorException('Fatal error. Invalid file info provided for normalization.');
        }

        unset($file['visibility']);
        $path = array_get($file, 'path');
        $timestamp = $this->adapter->getTimestamp($path);
        $file['name'] = trim(substr($path, strlen($localizer)), '/');
        if (empty($file['name'])) {
            $file['name'] = basename($path);
        }
        $file['last_modified'] = gmdate('D, d M Y H:i:s \G\M\T', array_get($timestamp, 'timestamp', 0));
        $file['content_type'] = array_get($this->adapter->getMimetype($path), 'mimetype');
        $file['content_length'] = array_get($file, 'size');
        unset($file['size']);
    }
203613
protected function getExtensions($file)
    {
        $basename = strtolower(pathinfo($file, PATHINFO_BASENAME));

        // normalize
        foreach ($this->composedExtensions as $composedExtension => $canonicalExtension) {
            $basename = preg_replace('/\.'.preg_quote($composedExtension).'(\.|$)/', '.'.$canonicalExtension.'\\1', $basename);
        }

        $extensions = explode('.', $basename);
        $extensions = array_reverse(array_slice($extensions, 1));

        $recognizedExtensions = [];

        $i = 0;
        $extensionsNumber = count($extensions);

        while ($i < $extensionsNumber && array_key_exists($extensions[$i], $this->extensionMap)) {
            $recognizedExtensions[] = $extensions[$i];
            $i++;
        }

        return array_reverse($recognizedExtensions);
    }
187719
public function parseFile($file)
    {
        $bundleConfig = Yaml::parse(file_get_contents(realpath($file)));

        if (!is_array($bundleConfig)) {
            return array();
        }

        return $bundleConfig;
    }
261719
public function listVersionsToOriginal(File $file)
    {
        if(!$this->containsFile($file)){
            return array();
        }

        if($this->isVersion($file)){
            return array();
        }

        return array_filter($file->getParentFolder()->listFolder(Folder::LIST_FOLDER_FILES), function(File $f) use ($file){
            return $this->isVersion($f) && strpos($f->getBasename(), $file->getBasename()) === 0;
        });
    }
507105
private function getRelatedFiles(FileInterface $file)
    {
        // Match foo(_local).*(.dist)
        $base = $file->getFilename();
        $ext = Path::getExtension($base);
        $base = Path::getFilenameWithoutExtension($base);
        $base = Str::replaceLast($base, '_local', '');

        $dir = $file->getParent();
        $related = [];
        foreach ([".$ext", "_local.$ext"] as $tail) {
            $f = $dir->getFile($base . $tail);
            if ($f->getFilename() !== $file->getFilename() && $f->exists()) {
                $related[] = $f;
            }
        }

        return $related;
    }
1250906
protected function parse(\SplFileInfo $file): array
    {
        libxml_use_internal_errors(true);

        $xml = simplexml_load_file($file->getRealPath());
        if (!$xml instanceof \SimpleXMLElement) {
            $errors = array_map(function (\LibXMLError $error) {
                return trim($error->message);
            }, libxml_get_errors());
            libxml_clear_errors();

            throw new ConfigurationParseException('Unable to parse config file: ' . implode(', ', $errors));
        }

        $config = json_decode(json_encode($xml), true);

        return $config;
    }
1129569
protected function getFilePieces(\SplFileInfo $file)
    {
        $key = $file->getBasename();
        if (!array_key_exists($key, $this->filePieces)) {
            $pieces = explode('.', $file->getBasename());
            if (count($pieces) < 3) {
                return true;
            }
            $extension = array_pop($pieces);
            $locale = array_pop($pieces);
            $domain = implode('.', $pieces);

            $this->filePieces[$key] = [
                self::FILE_PIECE_DOMAIN => $domain,
                self::FILE_PIECE_LOCALE => $locale,
                self::FILE_PIECE_EXTENSION => $extension,
            ];
        }

        return $this->filePieces[$key];
    }
49976
protected function getTranslations(string $file) : array
    {
        return $this->files->exists($file) ? (array) json_decode($this->files->get($file)) : [];
    }
1335453
public function parseMultiFile($file)
    {
        if (!file_exists($file)) {
            return false;
        }
        $ret = array();
        $fh = fopen($file, 'r');
        if (!$fh) {
            return false;
        }
        while (!feof($fh)) {
            $ret[] = $this->parseHandle($fh);
        }
        fclose($fh);
        return $ret;
    }
894701
public static function parseYamlFile($file): array
    {
        if (file_exists($file)) {
            $data = file_get_contents($file);
            if (!empty($data)) {
                $data = static::replaceEnvVariables($data);
                return Yaml::parse($data);
            }
        }

        return [];
    }
262383
protected function loadMappingFile($file)
    {
        $result     = [];
        $xmlElement = simplexml_load_file($file);

        if (isset($xmlElement->entity)) {
            foreach ($xmlElement->entity as $entityElement) {
                $entityName          = (string) $entityElement['name'];
                $result[$entityName] = $entityElement;
            }
        }

        return $result;
    }
770203
public function resolve($file)
    {
        $info = null;

        $this->rewind();
        foreach (clone $this as $path) {
            $info = new SplFileInfo(rtrim($path, '/') . '/' . ltrim($file, '/'));

            if ($info->isDir() || $info->isFile() || $info->isLink()) {
                break;
            }
        }

        return ($info)? $info->getPathname() : null;
    }
427871
public static function file2array($file)
    {
        $aFile = [];
        if ($file instanceof UploadedFile) {
            $aFile = file($file->getRealPath());
        } elseif (is_array($file) && isset($file[0]) && is_string($file[0])) {
            $aFile = $file;
        } elseif (is_string($file) && is_file($file) && file_exists($file)) {
            $aFile = file($file);
        } elseif (is_string($file) && strstr($file, PHP_EOL) !== false) {
            $file_content = explode(PHP_EOL, $file);
            if (empty(end($file_content))) {
                array_pop($file_content);
            }
            reset($file_content);
            $aFile = $file_content;
        }

        return array_map('\ForceUTF8\Encoding::toUTF8', $aFile);
    }