Skip to content

Commit

Permalink
Fixes by PhpStan & ECS inspections
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubboucek committed Apr 5, 2021
1 parent 03627f8 commit b68df06
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/Parser/ArchiveIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ public function next(): void
$position = ftell($this->handle);

$headerData = fread($this->handle, 512);
if (strlen($headerData) < 512) {
if ($headerData === false || strlen($headerData) < 512) {
throw new InvalidArchiveFormatException(
sprintf(
'Invalid TAR archive format: Unexpected end of file, returned non-block size: %d bytes',
strlen($headerData)
$headerData === false ? 0 : strlen($headerData)
)
);
}
Expand Down Expand Up @@ -91,11 +91,11 @@ public function next(): void
if ($contentBlockSize > 0) {
if ($this->readContent) {
$blockContent = fread($this->handle, $contentBlockSize);
if (strlen($blockContent) < $contentBlockSize) {
if ($blockContent === false || strlen($blockContent) < $contentBlockSize) {
throw new InvalidArchiveFormatException(
sprintf(
'Invalid TAR archive format: Unexpected end of file, returned non-block size: %d bytes',
strlen($blockContent)
$blockContent === false ? 0 : strlen($blockContent)
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(string $content)
{
$length = strlen($content);
if ($length !== 512) {
new InvalidArgumentException(sprintf('Tar header must be 512 bytes length, %d bytes got', $length));
throw new InvalidArgumentException(sprintf('Tar header must be 512 bytes length, %d bytes got', $length));
}

$this->content = $content;
Expand Down

0 comments on commit b68df06

Please sign in to comment.