From ad090404137e5429a90729efa9fbf51838a64ede Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 15:10:28 +0000 Subject: [PATCH] feat: Updated src/Snps/IO/Reader.php --- src/Snps/IO/Reader.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Snps/IO/Reader.php b/src/Snps/IO/Reader.php index cf2617c..6939d4a 100644 --- a/src/Snps/IO/Reader.php +++ b/src/Snps/IO/Reader.php @@ -62,7 +62,7 @@ public function read(): array // var_dump($file); if (is_string($file) && file_exists($file)) { if (strpos($file, ".zip") !== false) { - $zip = new ZipArchive(); + $zip = new ZipArchive(ZipArchive::RDONLY); if ($zip->open($file) === true) { $firstEntry = $zip->getNameIndex(0); $firstEntryFile = $zip->getStream($firstEntry); @@ -72,7 +72,7 @@ public function read(): array } } elseif (strpos($file, ".gz") !== false) { $fileContents = file_get_contents($file); - $fileContents = gzdecode($fileContents); + $fileContents = zlib_decode($fileContents); $read_data = $this->_extract_comments($fileContents); $compression = "gzip"; @@ -84,7 +84,7 @@ public function read(): array $fileContents = $file; $read_data = $this->_handle_bytes_data($fileContents); - $tempfile = tmpfile(); + $tempfile = fopen('php://temp', 'w+'); fwrite($tempfile, $fileContents); $meta_data = stream_get_meta_data($tempfile); $file_path = $meta_data['uri']; @@ -263,6 +263,7 @@ private function readHelper($source, $parser) { $phased = false; $build = 0; + $snps = []; if ($this->_only_detect_source) { $snps = array(); @@ -843,7 +844,7 @@ public function readGeneric(string $file, ?string $compression, int $skip = 1): $parser = function () use ($file, $compression, $skip) { $parse = function ($sep, $use_cols = false) use ($file, $skip, $compression) { // Stream filter for compressed file, if needed - $filter = $compression ? 'compress.zlib://' : ''; + $filter = $compression === "gzip" ? 'compress.zlib://' : ''; // CSV Reader setup