From 0aa6da895e1859ee56641a195eabeab6539b1faa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 09:35:03 -0500 Subject: [PATCH 1/2] Bump tests/specifications from `ce9b56b` to `787bbe6` (#1553) Bumps [tests/specifications](https://github.com/mongodb/specifications) from `ce9b56b` to `787bbe6`. - [Release notes](https://github.com/mongodb/specifications/releases) - [Commits](https://github.com/mongodb/specifications/compare/ce9b56ba3ed76cb4ebca9d4b760260548007dce6...787bbe67bdffb614270654372112e93fc2cd3eb3) --- updated-dependencies: - dependency-name: tests/specifications dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- tests/specifications | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/specifications b/tests/specifications index ce9b56ba3..787bbe67b 160000 --- a/tests/specifications +++ b/tests/specifications @@ -1 +1 @@ -Subproject commit ce9b56ba3ed76cb4ebca9d4b760260548007dce6 +Subproject commit 787bbe67bdffb614270654372112e93fc2cd3eb3 From 75f956628de5554dff33d9691196ac0f5c39785f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Wed, 11 Dec 2024 09:47:08 -0500 Subject: [PATCH 2/2] PHPLIB-1600 Accept `stdClass` objects in `BSONDocument` constructor (#1551) --- src/Model/BSONDocument.php | 4 ++-- tests/Model/BSONDocumentTest.php | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Model/BSONDocument.php b/src/Model/BSONDocument.php index b9a9c0d80..1ff8bc1e6 100644 --- a/src/Model/BSONDocument.php +++ b/src/Model/BSONDocument.php @@ -52,10 +52,10 @@ public function __clone() * by default. * * @see https://php.net/arrayobject.construct - * @param array $input + * @param array|stdClass $input * @psalm-param class-string>|class-string> $iteratorClass */ - public function __construct(array $input = [], int $flags = ArrayObject::ARRAY_AS_PROPS, string $iteratorClass = ArrayIterator::class) + public function __construct(array|stdClass $input = [], int $flags = ArrayObject::ARRAY_AS_PROPS, string $iteratorClass = ArrayIterator::class) { parent::__construct($input, $flags, $iteratorClass); } diff --git a/tests/Model/BSONDocumentTest.php b/tests/Model/BSONDocumentTest.php index 4d832d591..2000aef63 100644 --- a/tests/Model/BSONDocumentTest.php +++ b/tests/Model/BSONDocumentTest.php @@ -23,6 +23,13 @@ public function testConstructorDefaultsToPropertyAccess(): void $this->assertSame('bar', $document->foo); } + public function testConstructorWithStandardObject(): void + { + $object = (object) ['foo' => 'bar']; + $document = new BSONDocument($object); + $this->assertEquals($object, $document->bsonSerialize()); + } + public function testBsonSerializeCastsToObject(): void { $data = [0 => 'foo', 2 => 'bar'];