Repository: symfony/symfony
File: src/Symfony/Component/Translation/Bridge/Lokalise/LokaliseProvider.php (PHP)

Code before:
                }
            } finally {
                $zip->close();
            }

            $fileContents = $this->getFileContents($extractPath);

            // Lokalise returns languages with "-" separator, we need to reformat them to "_" separator.
            /** @var array<array-key, array-key> $reformattedLanguages */
            $reformattedLanguages = array_map(static fn ($language) => str_replace('-', '_', $language), array_keys($fileContents));

            return array_combine($reformattedLanguages, $fileContents);
        } finally {
            unlink($newfile);
            $this->removeDir($extractPath);
        }
    }

    private function getFileContents(string $dir, string $baseDir = ''): array
    {
        $fileContents = [];
        foreach (scandir($dir) as $filename) {
            if (\in_array($filename, ['.', '..'])) {
                continue;
            }
            $path = \sprintf('%s%s%s', $dir, \DIRECTORY_SEPARATOR, $filename);
            if (is_dir($path)) {
                $fileContents = array_merge($fileContents, $this->getFileContents($path, $filename));
                continue;
            }
            $fileContents[$baseDir][$filename]['content'] = file_get_contents($path);
        }

        return $fileContents;
    }

    private function removeDir(string $dir): void
    {
        $it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
        $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
        foreach ($files as $file) {
            if ($file->isDir()) {
                rmdir($file->getPathname());
            } else {
                unlink($file->getPathname());
            }
        }
        rmdir($dir);
    }

    private function createKeys(array $keys, string $domain): array

Review comment (suggestion):
```suggestion
            $path = $dir.'/'.$filename;
```

Code after:
            } finally {
                $zip->close();
            }

            return $this->getZipContents($extractPath);
        } finally {
            if (is_resource($h)) {
                fclose($h);
            }
            @unlink($zipFile);
            $this->removeDir($extractPath);
        }
    }

    private function getZipContents(string $dir): array
    {
        $contents = [];
        foreach (scandir($dir) as $lang) {
            if (\in_array($lang, ['.', '..'], true)) {
                continue;
            }
            $path = $dir.'/'.$lang;
            // Lokalise returns languages with "-" separator, we need to reformat them to "_" separator.
            $lang = str_replace('-', '_', $lang);
            foreach (scandir($path) as $name) {
                if (!\in_array($name, ['.', '..'], true)) {
                    $contents[$lang][$name]['content'] = file_get_contents($path.'/'.$name);
                }
            }
        }

        return $contents;
    }

    private function removeDir(string $dir): void
    {
        if (!is_dir($dir)) {
            return;
        }
        $it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
        $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
        foreach ($files as $file) {
            if ($file->isDir()) {
                rmdir($file->getPathname());
            } else {
                unlink($file->getPathname());
            }
        }
        rmdir($dir);
    }