From 6fa409552cd839b9eb2689469dd2910785471bd2 Mon Sep 17 00:00:00 2001 From: Alice Neubauer Date: Sun, 6 Oct 2024 19:48:44 -0300 Subject: [PATCH] refactor: changed types and annotations --- src/LegacyRecord.php | 4 +++- src/Model/AbstractModel.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/LegacyRecord.php b/src/LegacyRecord.php index 6fe55a77..a6306564 100644 --- a/src/LegacyRecord.php +++ b/src/LegacyRecord.php @@ -3,6 +3,7 @@ namespace Mongolid; use Illuminate\Contracts\Container\BindingResolutionException; +use MongoDB\BSON\Document; use MongoDB\Collection; use MongoDB\Driver\WriteConcern; use MongoDB\Exception\BadMethodCallException; @@ -17,6 +18,7 @@ use Mongolid\Schema\DynamicSchema; use Mongolid\Schema\HasSchemaInterface; use Mongolid\Schema\Schema; +use stdClass; /** * This class was created to keep v2 compatibility. @@ -257,7 +259,7 @@ public function getCollection(): Collection /** * @throws BindingResolutionException */ - public function bsonSerialize(): object|array + public function bsonSerialize(): array|Document|stdClass { return Container::make(ModelMapper::class) ->map( diff --git a/src/Model/AbstractModel.php b/src/Model/AbstractModel.php index 2e1dac89..bb22d631 100644 --- a/src/Model/AbstractModel.php +++ b/src/Model/AbstractModel.php @@ -3,6 +3,7 @@ namespace Mongolid\Model; use Illuminate\Contracts\Container\BindingResolutionException; +use MongoDB\BSON\Document; use MongoDB\Collection; use MongoDB\Driver\WriteConcern; use Mongolid\Connection\Connection; @@ -12,6 +13,7 @@ use Mongolid\Model\Exception\NoCollectionNameException; use Mongolid\Query\Builder; use Mongolid\Query\ModelMapper; +use stdClass; /** * The Mongolid\Model\Model base class will ensure to enable your model to @@ -149,7 +151,7 @@ public function setWriteConcern(int $writeConcern): void /** * @throws BindingResolutionException */ - public function bsonSerialize(): object|array + public function bsonSerialize(): array|Document|stdClass { return Container::make(ModelMapper::class) ->map(