From a6e1ffa6c825d625b46701be7deb612e4f303660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20M=C3=A4nnchen?= Date: Mon, 22 Jan 2024 10:16:25 +0100 Subject: [PATCH] CI Fixes --- src/File.php | 6 +++--- src/ZipStream.php | 7 ++++--- test/ResourceStream.php | 2 +- test/Util.php | 2 +- test/ZipStreamTest.php | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/File.php b/src/File.php index 3f35de4..eeaed34 100644 --- a/src/File.php +++ b/src/File.php @@ -95,7 +95,7 @@ public function process(): string if ($this->enableZeroHeader) { // No calculation required - } elseif ($this->isSimulation() && $forecastSize) { + } elseif ($this->isSimulation() && $forecastSize !== null) { $this->uncompressedSize = $forecastSize; $this->compressedSize = $forecastSize; } else { @@ -158,7 +158,7 @@ private function forecastSize(): ?int if ($this->compressionMethod !== CompressionMethod::STORE) { return null; } - if ($this->exactSize) { + if ($this->exactSize !== null) { return $this->exactSize; } $fstat = fstat($this->unpackStream()); @@ -350,7 +350,7 @@ private function readStream(bool $send): void } } - if ($this->exactSize && $this->uncompressedSize !== $this->exactSize) { + if ($this->exactSize !== null && $this->uncompressedSize !== $this->exactSize) { throw new FileSizeIncorrectException(expectedSize: $this->exactSize, actualSize: $this->uncompressedSize); } diff --git a/src/ZipStream.php b/src/ZipStream.php index 195a4bf..8a06fec 100644 --- a/src/ZipStream.php +++ b/src/ZipStream.php @@ -330,7 +330,8 @@ public function addFileFromPath( throw new FileNotReadableException($path); } - if ($fileTime = filemtime($path)) { + $fileTime = filemtime($path); + if ($fileTime !== false) { $lastModificationDateTime ??= (new DateTimeImmutable())->setTimestamp($fileTime); } @@ -581,7 +582,7 @@ public function addFileFromCallback( if ($maxSize !== null && fwrite($stream, $data, $maxSize) === false) { // @codeCoverageIgnoreStart throw new ResourceActionException('fwrite', $stream); - // @codeCoverageIgnoreEnd + // @codeCoverageIgnoreEnd } elseif (fwrite($stream, $data) === false) { // @codeCoverageIgnoreStart throw new ResourceActionException('fwrite', $stream); @@ -823,7 +824,7 @@ private function sendHttpHeaders(): void // grab content disposition $disposition = $this->contentDisposition; - if ($this->outputName) { + if ($this->outputName !== null) { // Various different browsers dislike various characters here. Strip them all for safety. $safeOutput = trim(str_replace(['"', "'", '\\', ';', "\n", "\r"], '', $this->outputName)); diff --git a/test/ResourceStream.php b/test/ResourceStream.php index c33d02b..752a1a3 100644 --- a/test/ResourceStream.php +++ b/test/ResourceStream.php @@ -58,7 +58,7 @@ public function seek(int $offset, int $whence = SEEK_SET): void public function isSeekable(): bool { - return (bool)$this->getMetadata('seekable'); + return (bool) $this->getMetadata('seekable'); } public function getMetadata(?string $key = null) diff --git a/test/Util.php b/test/Util.php index 2fd3517..e39f5bf 100644 --- a/test/Util.php +++ b/test/Util.php @@ -106,7 +106,7 @@ protected function getTmpDir(): string protected function getRecursiveFileList(string $path, bool $includeDirectories = false): array { $data = []; - $path = (string)realpath($path); + $path = (string) realpath($path); $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); $pathLen = strlen($path); diff --git a/test/ZipStreamTest.php b/test/ZipStreamTest.php index fbbe533..c5fc6e9 100644 --- a/test/ZipStreamTest.php +++ b/test/ZipStreamTest.php @@ -1161,7 +1161,7 @@ private function addLargeFileFileFromPath(CompressionMethod $compressionMethod, [$tmpExample, $streamExample] = $this->getTmpFileStream(); for ($i = 0; $i <= 10000; $i++) { - fwrite($streamExample, sha1((string)$i)); + fwrite($streamExample, sha1((string) $i)); if ($i % 100 === 0) { fwrite($streamExample, "\n"); }