Skip to content

Commit 7c3bc10

Browse files
Merge v1.x into v2.x (#1555)
2 parents 4a3044b + 75f9566 commit 7c3bc10

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Model/BSONDocument.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public function __clone()
5151
* by default.
5252
*
5353
* @see https://php.net/arrayobject.construct
54-
* @param array<string, mixed> $input
54+
* @param array<string, mixed>|stdClass $input
5555
* @psalm-param class-string<ArrayIterator<string,mixed>>|class-string<ArrayObject<string,mixed>> $iteratorClass
5656
*/
57-
public function __construct(array $input = [], int $flags = ArrayObject::ARRAY_AS_PROPS, string $iteratorClass = ArrayIterator::class)
57+
public function __construct(array|stdClass $input = [], int $flags = ArrayObject::ARRAY_AS_PROPS, string $iteratorClass = ArrayIterator::class)
5858
{
5959
parent::__construct($input, $flags, $iteratorClass);
6060
}

tests/Model/BSONDocumentTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ public function testConstructorDefaultsToPropertyAccess(): void
2323
$this->assertSame('bar', $document->foo);
2424
}
2525

26+
public function testConstructorWithStandardObject(): void
27+
{
28+
$object = (object) ['foo' => 'bar'];
29+
$document = new BSONDocument($object);
30+
$this->assertEquals($object, $document->bsonSerialize());
31+
}
32+
2633
public function testBsonSerializeCastsToObject(): void
2734
{
2835
$data = [0 => 'foo', 2 => 'bar'];

0 commit comments

Comments
 (0)