-
Notifications
You must be signed in to change notification settings - Fork 266
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
Remove unreachable code #1079
Conversation
@@ -272,8 +271,6 @@ private function fileCollectionInsert() | |||
|
|||
throw $e; | |||
} | |||
|
|||
return $this->file['_id']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returned value never used.
There was a problem hiding this comment.
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.
src/GridFS/Bucket.php
Outdated
@@ -181,7 +178,6 @@ public function __construct(Manager $manager, string $databaseName, array $optio | |||
$this->databaseName = $databaseName; | |||
$this->bucketName = $options['bucketName']; | |||
$this->chunkSizeBytes = $options['chunkSizeBytes']; | |||
$this->disableMD5 = $options['disableMD5']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a bug.
The option was introduced in f169616 for PHPLIB-319. The GridFS spec notes that it's relevant so long as a driver still supports MD5 hashes, which PHPLIB does.
It looks like openUploadStream()
never inherits the Bucket's default value like it does for chunkSizeBytes
. I believe all of the existing spec tests only set the option when invoking the operation, so the Bucket inheritance is never tested.
Would you mind reporting a new issue for this and marking it linking it to PHPLIB-319 and this comment thread for context?
@@ -159,13 +159,4 @@ private function createOptions(): array | |||
|
|||
return $options; | |||
} | |||
|
|||
private function isFindAndModify(Explainable $explainable): bool |
There was a problem hiding this comment.
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.
@@ -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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the disableMD5
change reverted (and a new issue created).
Thanks for digging into this.
Thanks for the review in deep. I reverted |
Remove private properties and method never accessed. Found thanks to
./vendor/bin/psalm --find-dead-code
.This code should be safe to remove, unless it's used for introspection, using reflection or by the C driver.