Skip to content

Commit

Permalink
Use decode() instead of decodeIfSupported()
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus committed Aug 4, 2023
1 parent c3a3164 commit 8f634dd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ChangeStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function current()
return $value;
}

return $this->codec->decodeIfSupported($value);
return $this->codec->decode($value);

Check failure on line 117 in src/ChangeStream.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidArgument

src/ChangeStream.php:117:37: InvalidArgument: Argument 1 of MongoDB\Codec\DocumentCodec::decode expects MongoDB\BSON\Document, but array<array-key, mixed>|null|object provided (see https://psalm.dev/004)
}

/** @return CursorId */
Expand Down
3 changes: 1 addition & 2 deletions src/Operation/FindAndModify.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ public function execute(Server $server)
$result = current($cursor->toArray());
assert($result instanceof Document);

$decoded = $this->options['codec']->decodeIfSupported($result->get('value'));
assert($decoded === null || is_object($decoded));
$decoded = $this->options['codec']->decode($result->get('value'));

Check failure on line 265 in src/Operation/FindAndModify.php

View workflow job for this annotation

GitHub Actions / phpcs

Useless variable $decoded.

Check failure on line 265 in src/Operation/FindAndModify.php

View workflow job for this annotation

GitHub Actions / Psalm

MixedAssignment

src/Operation/FindAndModify.php:265:13: MixedAssignment: Unable to determine the type that $decoded is being assigned to (see https://psalm.dev/032)

Check failure on line 265 in src/Operation/FindAndModify.php

View workflow job for this annotation

GitHub Actions / Psalm

MixedMethodCall

src/Operation/FindAndModify.php:265:49: MixedMethodCall: Cannot determine the type of $this->options['codec'] when calling method decode (see https://psalm.dev/015)

return $decoded;

Check failure on line 267 in src/Operation/FindAndModify.php

View workflow job for this annotation

GitHub Actions / Psalm

MixedReturnStatement

src/Operation/FindAndModify.php:267:20: MixedReturnStatement: Could not infer a return type (see https://psalm.dev/138)
}
Expand Down

0 comments on commit 8f634dd

Please sign in to comment.