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"); }