Skip to content

Commit 178ab43

Browse files
committed
Use BSON Type class instead of UTCDateTime
1 parent 5b453a1 commit 178ab43

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/Builder/BuilderEncoder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace MongoDB\Builder;
66

77
use DateTimeInterface;
8-
use MongoDB\BSON\UTCDateTime;
8+
use MongoDB\BSON\Type;
99
use MongoDB\Builder\Encoder\CombinedFieldQueryEncoder;
1010
use MongoDB\Builder\Encoder\DateTimeEncoder;
1111
use MongoDB\Builder\Encoder\DictionaryEncoder;
@@ -34,10 +34,10 @@
3434
use function array_key_exists;
3535
use function is_object;
3636

37-
/** @template-implements Encoder<stdClass|array|string|int, Pipeline|StageInterface|ExpressionInterface|QueryInterface> */
37+
/** @template-implements Encoder<Type|stdClass|array|string|int, Pipeline|StageInterface|ExpressionInterface|QueryInterface> */
3838
final class BuilderEncoder implements Encoder
3939
{
40-
/** @template-use EncodeIfSupported<stdClass|array|string|int, Pipeline|StageInterface|ExpressionInterface|QueryInterface> */
40+
/** @template-use EncodeIfSupported<Type|stdClass|array|string|int, Pipeline|StageInterface|ExpressionInterface|QueryInterface> */
4141
use EncodeIfSupported;
4242

4343
/** @var array<class-string, class-string<ExpressionEncoder>> */
@@ -71,7 +71,7 @@ public function canEncode(mixed $value): bool
7171
return (bool) $this->getEncoderFor($value)?->canEncode($value);
7272
}
7373

74-
public function encode(mixed $value): stdClass|array|string|int|UTCDateTime
74+
public function encode(mixed $value): Type|stdClass|array|string|int
7575
{
7676
$encoder = $this->getEncoderFor($value);
7777

src/Builder/Encoder/AbstractExpressionEncoder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
namespace MongoDB\Builder\Encoder;
66

7-
use MongoDB\BSON\UTCDateTime;
7+
use MongoDB\BSON\Type;
88
use MongoDB\Builder\BuilderEncoder;
99
use stdClass;
1010

1111
use function get_object_vars;
1212
use function is_array;
1313

1414
/**
15-
* @template BSONType of stdClass|array|string|int|UTCDateTime
15+
* @template BSONType of Type|stdClass|array|string|int
1616
* @template NativeType
1717
* @template-implements ExpressionEncoder<BSONType, NativeType>
1818
* @internal
@@ -26,6 +26,7 @@ final public function __construct(protected readonly BuilderEncoder $encoder)
2626
/**
2727
* Nested arrays and objects must be encoded recursively.
2828
*
29+
* @psalm-template T
2930
* @psalm-param T $value
3031
*
3132
* @psalm-return (T is stdClass ? stdClass : (T is array ? array : mixed))

src/Builder/Encoder/ExpressionEncoder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
namespace MongoDB\Builder\Encoder;
66

7+
use MongoDB\BSON\Type;
78
use MongoDB\Builder\BuilderEncoder;
89
use MongoDB\Codec\Encoder;
910
use stdClass;
1011

1112
/**
12-
* @template BSONType of stdClass|array|string|int
13+
* @template BSONType of Type|stdClass|array|string|int
1314
* @template NativeType
1415
* @template-extends Encoder<BSONType, NativeType>
1516
* @internal

0 commit comments

Comments
 (0)