Skip to content

Commit

Permalink
Specify iterator types in Query namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Apr 26, 2022
1 parent a93fe94 commit e13fef3
Show file tree
Hide file tree
Showing 31 changed files with 277 additions and 208 deletions.
5 changes: 4 additions & 1 deletion lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Expr
/** @var ClassMetadata */
private $class;

/** @var array */
/** @var array<string, mixed> */
private $expr = [];

/**
Expand Down Expand Up @@ -537,6 +537,9 @@ public function floor($number): self
return $this->operator('$floor', $number);
}

/**
* @return array<string, mixed>
*/
public function getExpression(): array
{
return $this->expr;
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public function __construct(Builder $builder)

/**
* Assembles the aggregation stage
*
* @return array<string, mixed>
*/
abstract public function getExpression(): array;

Expand Down
16 changes: 8 additions & 8 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/MatchStage.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public function __clone()
* @see Expr::addAnd()
* @see https://docs.mongodb.com/manual/reference/operator/and/
*
* @param array|Expr $expression
* @param array|Expr ...$expressions
* @param mixed[]|Expr $expression
* @param mixed[]|Expr ...$expressions
*
* @return static
*/
Expand All @@ -64,8 +64,8 @@ public function addAnd($expression, ...$expressions): self
* @see Expr::addNor()
* @see https://docs.mongodb.com/manual/reference/operator/nor/
*
* @param array|Expr $expression
* @param array|Expr ...$expressions
* @param mixed[]|Expr $expression
* @param mixed[]|Expr ...$expressions
*
* @return static
*/
Expand All @@ -85,8 +85,8 @@ public function addNor($expression, ...$expressions): self
* @see Expr::addOr()
* @see https://docs.mongodb.com/manual/reference/operator/or/
*
* @param array|Expr $expression
* @param array|Expr ...$expressions
* @param mixed[]|Expr $expression
* @param mixed[]|Expr ...$expressions
*
* @return static
*/
Expand Down Expand Up @@ -121,7 +121,7 @@ public function all(array $values): self
* @see Expr::elemMatch()
* @see https://docs.mongodb.com/manual/reference/operator/elemMatch/
*
* @param array|Expr $expression
* @param mixed[]|Expr $expression
*
* @return static
*/
Expand Down Expand Up @@ -452,7 +452,7 @@ public function mod($divisor, $remainder = 0): self
* @see Expr::not()
* @see https://docs.mongodb.com/manual/reference/operator/not/
*
* @param array|Expr $expression
* @param mixed[]|Expr $expression
*
* @return static
*/
Expand Down
13 changes: 8 additions & 5 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public function __construct(Builder $builder)
$this->expr = $builder->expr();
}

/**
* @param mixed[] $args
*/
public function __call(string $method, array $args): self
{
$this->expr->$method(...$args);
Expand Down Expand Up @@ -86,8 +89,8 @@ public function add($expression1, $expression2, ...$expressions): self
* @see https://docs.mongodb.com/manual/reference/operator/aggregation/and/
* @see Expr::addAnd
*
* @param array|Expr $expression
* @param array|Expr ...$expressions
* @param mixed[]|Expr $expression
* @param mixed[]|Expr ...$expressions
*
* @return static
*/
Expand All @@ -104,8 +107,8 @@ public function addAnd($expression, ...$expressions): self
* @see https://docs.mongodb.com/manual/reference/operator/aggregation/or/
* @see Expr::addOr
*
* @param array|Expr $expression
* @param array|Expr ...$expressions
* @param mixed[]|Expr $expression
* @param mixed[]|Expr ...$expressions
*
* @return static
*/
Expand Down Expand Up @@ -145,7 +148,7 @@ public function allElementsTrue($expression): self
* @see https://docs.mongodb.com/manual/reference/operator/aggregation/anyElementTrue/
* @see Expr::anyElementTrue
*
* @param array|Expr $expression
* @param mixed[]|Expr $expression
*
* @return static
*/
Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public function avg($expression1, ...$expressions): self

/**
* Shorthand method to define which fields to be included.
*
* @param string[] $fields
*/
public function includeFields(array $fields): self
{
Expand All @@ -55,6 +57,8 @@ public function includeFields(array $fields): self
*
* If you specify the exclusion of a field other than _id, you cannot employ
* any other $project specification forms.
*
* @param string[] $fields
*/
public function excludeFields(array $fields): self
{
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/ReplaceRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class ReplaceRoot extends Operator
/** @var ClassMetadata */
private $class;

/** @var string|array|Expr|null */
/** @var string|mixed[]|Expr|null */
private $expression;

/**
* @param string|array|Expr|null $expression
* @param string|mixed[]|Expr|null $expression
*/
public function __construct(Builder $builder, DocumentManager $documentManager, ClassMetadata $class, $expression = null)
{
Expand All @@ -51,9 +51,9 @@ public function getExpression(): array
}

/**
* @param array|string|mixed $expression
* @param mixed[]|string|mixed $expression
*
* @return array|string|mixed
* @return mixed[]|string|mixed
*/
private function convertExpression($expression)
{
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Sort.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
*/
class Sort extends Stage
{
/** @var array */
/** @var array<string, -1|1|array{"$meta": string}> */
private $sort = [];

/**
* @param array|string $fieldName Field name or array of field/order pairs
* @param int|string $order Field order (if one field is specified)
* @param array<string, int|string>|string $fieldName Field name or array of field/order pairs
* @param int|string $order Field order (if one field is specified)
*/
public function __construct(Builder $builder, $fieldName, $order = null)
{
Expand Down
Loading

0 comments on commit e13fef3

Please sign in to comment.