Skip to content

PHPLIB-1627: BulkWriteCommand API #1630

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

Open
wants to merge 33 commits into
base: v2.x
Choose a base branch
from
Open

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Mar 4, 2025

@jmikola jmikola force-pushed the 2.x-bulkwrite branch 4 times, most recently from d9351cc to 33952f7 Compare March 24, 2025 15:50
@jmikola jmikola force-pushed the 2.x-bulkwrite branch 3 times, most recently from f2cae41 to c4c0deb Compare April 1, 2025 20:07
public function insertOne(array|object $document, mixed &$id = null): self
{
if ($this->codec) {
$document = $this->codec->encode($document);

Check notice

Code scanning / Psalm

PossiblyInvalidArgument Note

Argument 1 of MongoDB\Codec\DocumentCodec::encode expects object, but possibly different type array<array-key, mixed>|object provided
Copy link
Member

Choose a reason for hiding this comment

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

The type in DocumentCodec should be relaxed to @psalm-template ObjectType of object|array

* @psalm-template ObjectType of object

Copy link
Member

Choose a reason for hiding this comment

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

Apply the same change as #1687

$filter = $this->builderEncoder->encodeIfSupported($filter);

if ($this->codec) {
$replacement = $this->codec->encode($replacement);

Check notice

Code scanning / Psalm

PossiblyInvalidArgument Note

Argument 1 of MongoDB\Codec\DocumentCodec::encode expects object, but possibly different type array<array-key, mixed>|object provided
*/
public function execute(Server $server): BulkWriteCommandResult
{
$inTransaction = isset($this->options['session']) && $this->options['session']->isInTransaction();

Check notice

Code scanning / Psalm

MixedMethodCall Note

Cannot determine the type of $this->options['session'] when calling method isInTransaction

$options = array_filter($this->options, fn ($value) => isset($value));

return $server->executeBulkWriteCommand($this->bulkWriteCommand, $options);

Check notice

Code scanning / Psalm

MixedReturnStatement Note

Could not infer a return type
public function insertOne(array|object $document, mixed &$id = null): self
{
if ($this->codec) {
$document = $this->codec->encode($document);
Copy link
Member

Choose a reason for hiding this comment

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

The type in DocumentCodec should be relaxed to @psalm-template ObjectType of object|array

* @psalm-template ObjectType of object

@GromNaN GromNaN marked this pull request as ready for review May 9, 2025 11:38
@GromNaN GromNaN requested a review from a team as a code owner May 9, 2025 11:38
@GromNaN GromNaN self-requested a review May 9, 2025 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants