Skip to content

Commit

Permalink
Support new aggregation pipeline stages in builder (#2513)
Browse files Browse the repository at this point in the history
* Add $densify stage to aggregation pipeline builder

* Add $fill stage to aggregation pipeline builder

* Add $merge stage to aggregation pipeline builder

* Add $replaceWith stage to aggregation pipeline builder

* Add $set stage to aggregation pipeline builder

* Add $unset stage to aggregation pipeline builder

* Add $unionWith stage to aggregation pipeline builder

* Use templates for Builder::addStage

* Add template covariance error to psalm baseline

* Remove unnecessary abstraction for $addFields and $set

* Use array_fields for lists in variadic arguments

* Improve wording when field name is required in Expr classes

* Add missing type to whenMatched option

* Update type for let option

* Use ? syntax for nullable type

* Rename test methods to hide copy/paste

* Test all range options for $densify

* Test complex values and sort for $fill

* Test reusing same builder for $merge

* Simplify creation of UTCDateTime instances in tests

* Allow expressions as partition in $fill stage

* Define psalm types for most pipeline stages

* Improve handling of required options as typed arguments
  • Loading branch information
alcaeus authored Mar 24, 2023
1 parent daa27d7 commit 8b3f57a
Show file tree
Hide file tree
Showing 62 changed files with 2,729 additions and 595 deletions.
7 changes: 6 additions & 1 deletion lib/Doctrine/ODM/MongoDB/Aggregation/Aggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use function array_merge;
use function assert;

/** @psalm-import-type PipelineExpression from Builder */
final class Aggregation implements IteratorAggregate
{
private DocumentManager $dm;
Expand All @@ -25,7 +26,10 @@ final class Aggregation implements IteratorAggregate

private Collection $collection;

/** @var array<string, mixed> */
/**
* @var array<string, mixed>
* @psalm-var PipelineExpression
*/
private array $pipeline;

/** @var array<string, mixed> */
Expand All @@ -36,6 +40,7 @@ final class Aggregation implements IteratorAggregate
/**
* @param array<string, mixed> $pipeline
* @param array<string, mixed> $options
* @psalm-param PipelineExpression $pipeline
*/
public function __construct(DocumentManager $dm, ?ClassMetadata $classMetadata, Collection $collection, array $pipeline, array $options = [], bool $rewindable = true)
{
Expand Down
Loading

0 comments on commit 8b3f57a

Please sign in to comment.