Skip to content

Remove unreachable code #1079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/GridFS/StreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ class StreamWrapper
/** @var resource|null Stream context (set by PHP) */
public $context;

/** @var string|null */
private $mode;

/** @var string|null */
private $protocol;

Expand Down Expand Up @@ -127,7 +124,6 @@ public function stream_eof(): bool
public function stream_open(string $path, string $mode, int $options, ?string &$openedPath): bool
{
$this->initProtocol($path);
$this->mode = $mode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduced in e2bf1d4#diff-87d70a08d4e98fae61febf5131732ba9564f41ce431a1ea8f4bd759df70c2365R95 and never removed in bc98d9c when stream_stat() was refactored.


if ($mode === 'r') {
return $this->initReadableStream();
Expand Down
5 changes: 1 addition & 4 deletions src/GridFS/WritableStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ private function abort(): void
$this->isClosed = true;
}

/** @return mixed */
private function fileCollectionInsert()
private function fileCollectionInsert(): void
{
$this->file['length'] = $this->length;
$this->file['uploadDate'] = new UTCDateTime();
Expand All @@ -272,8 +271,6 @@ private function fileCollectionInsert()

throw $e;
}

return $this->file['_id'];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returned value never used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this dates back to some early GridFS code which was refactored long ago. This looks good to remove.

}

private function insertChunkFromBuffer(): void
Expand Down
9 changes: 0 additions & 9 deletions src/Operation/Explain.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,4 @@ private function createOptions(): array

return $options;
}

private function isFindAndModify(Explainable $explainable): bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was originally introduced in c6a2df9 and I missed removing it in 103c1f2#diff-fc0bd4b2f7c5d5615660cecd2acc184702ebfbd7153723cc4d0954bc6696bc08L121 when cleaning up code for pre-3.6 servers.

{
if ($explainable instanceof FindAndModify || $explainable instanceof FindOneAndDelete || $explainable instanceof FindOneAndReplace || $explainable instanceof FindOneAndUpdate) {
return true;
}

return false;
}
}