Skip to content

Commit 27fcf44

Browse files
committed
Fix PHPStan error
1 parent 9de2244 commit 27fcf44

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

src/StreamReader.php

+11-18
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ public function getIterator(): Iterator
7777
throw new RuntimeException('Unable to create temporary stream.');
7878
}
7979

80-
// Empty content means nothing to transport, nothing to seek
81-
if (!$contentSize) {
82-
return $stream;
83-
}
84-
8580
$bytes = stream_copy_to_stream($this->stream, $stream, $contentSize);
8681

8782
if ($bytes !== $contentSize) {
@@ -127,19 +122,17 @@ public function getIterator(): Iterator
127122
if (!$usage->used()) {
128123
$usage->use();
129124
$content->close();
130-
if ($contentSize) {
131-
// Skip unused content
132-
$bytes = fseek($this->stream, $contentSize + $contentPadding, SEEK_CUR);
133-
134-
if ($bytes === -1) {
135-
throw new InvalidArchiveFormatException(
136-
sprintf(
137-
'Invalid TAR archive format: Unexpected end of file at position: %s, expected %d bytes of content and block padding',
138-
$blockStart,
139-
$contentSize + $contentPadding,
140-
)
141-
);
142-
}
125+
// Skip unused content
126+
$bytes = fseek($this->stream, $contentSize + $contentPadding, SEEK_CUR);
127+
128+
if ($bytes === -1) {
129+
throw new InvalidArchiveFormatException(
130+
sprintf(
131+
'Invalid TAR archive format: Unexpected end of file at position: %s, expected %d bytes of content and block padding',
132+
$blockStart,
133+
$contentSize + $contentPadding,
134+
)
135+
);
143136
}
144137
}
145138
}

0 commit comments

Comments
 (0)