Skip to content

Commit dd77c8d

Browse files
authored
PHPLIB-1634: Support encoding DateTimeInterface instances in aggregation builder (#1610)
* PHPLIB-1634: Support encoding DateTimeInterface instances in aggregation builder * Sort types correctly * Accept DateTimeInterface for query objects * Add missing psalm annotation * Use BSON Type class instead of UTCDateTime * Update psalm baseline
1 parent 85447eb commit dd77c8d

File tree

114 files changed

+1006
-776
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1006
-776
lines changed

generator/config/expressions.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace MongoDB\Builder\Expression;
88

9+
use DateTimeInterface;
910
use MongoDB\BSON;
1011
use MongoDB\Builder\Pipeline;
1112
use MongoDB\Builder\Type;
@@ -26,7 +27,7 @@
2627
'binData' => ['string', BSON\Binary::class],
2728
'objectId' => [BSON\ObjectId::class],
2829
'bool' => ['bool'],
29-
'date' => [BSON\UTCDateTime::class],
30+
'date' => [BSON\UTCDateTime::class, DateTimeInterface::class],
3031
'null' => ['null'],
3132
'regex' => [BSON\Regex::class],
3233
'javascript' => ['string', BSON\Javascript::class],
@@ -37,7 +38,7 @@
3738
];
3839

3940
// "any" accepts all the BSON types. No generic "object" or "mixed"
40-
$bsonTypes['any'] = ['bool', 'int', 'float', 'string', 'array', 'null', stdClass::class, BSON\Type::class];
41+
$bsonTypes['any'] = ['bool', 'int', 'float', 'string', 'array', 'null', stdClass::class, BSON\Type::class, DateTimeInterface::class];
4142

4243
// "number" accepts all the numeric types
4344
$bsonTypes['number'] = ['int', 'float', BSON\Int64::class, BSON\Decimal128::class];

psalm-baseline.xml

+2
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@
248248
<code><![CDATA[($value is NativeType ? BSONType : $value)]]></code>
249249
<code><![CDATA[($value is NativeType ? BSONType : $value)]]></code>
250250
<code><![CDATA[($value is NativeType ? BSONType : $value)]]></code>
251+
<code><![CDATA[($value is NativeType ? BSONType : $value)]]></code>
252+
<code><![CDATA[($value is NativeType ? BSONType : $value)]]></code>
251253
</InvalidReturnType>
252254
<MixedArgumentTypeCoercion>
253255
<code><![CDATA[$value]]></code>

src/Builder/Accumulator/AddToSetAccumulator.php

+7-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/BottomAccumulator.php

+5-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/BottomNAccumulator.php

+5-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/DerivativeAccumulator.php

+5-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)