diff --git a/src/Model/BSONDocument.php b/src/Model/BSONDocument.php index 57b1fc35e..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 object|array $input + * @param array|stdClass $input * @psalm-param class-string>|class-string> $iteratorClass */ - public function __construct(array|object $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 f16ccfdad..33d616c14 100644 --- a/tests/Model/BSONDocumentTest.php +++ b/tests/Model/BSONDocumentTest.php @@ -25,18 +25,11 @@ public function testConstructorDefaultsToPropertyAccess(): void public function testConstructorWithStandardObject(): void { - $document = new BSONDocument((object) ['foo' => 'bar']); - $this->assertSame('bar', $document->foo); - } - - public function testConstructorWithClassObject(): void - { - $document = new BSONDocument(new class () { - public string $foo = 'bar'; - protected string $baz = 'qux'; - }); + $object = (object) ['foo' => 'bar']; + $document = new BSONDocument($object); + $this->assertEquals(ArrayObject::ARRAY_AS_PROPS, $document->getFlags()); $this->assertSame('bar', $document->foo); - $this->assertObjectNotHasProperty('baz', $document); + $this->assertEquals($object, $document->bsonSerialize()); } public function testBsonSerializeCastsToObject(): void