Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/Aggregation/Stage.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@
*/
abstract class Stage
{
/** @var Builder */
protected $builder;

public function __construct(Builder $builder)
public function __construct(protected Builder $builder)
{
$this->builder = $builder;
}

/**
Expand Down
14 changes: 4 additions & 10 deletions src/Aggregation/Stage/AbstractBucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
*/
abstract class AbstractBucket extends Stage
{
/** @var Bucket\AbstractOutput|null */
protected $output;
protected ?Bucket\AbstractOutput $output = null;

/** @var Expr|array<string, mixed>|string */
protected $groupBy;
protected Expr|array|string $groupBy;

public function __construct(Builder $builder, private DocumentManager $dm, private ClassMetadata $class)
{
Expand All @@ -41,7 +40,7 @@ public function __construct(Builder $builder, private DocumentManager $dm, priva
*
* @param array<string, mixed>|Expr|string $expression
*/
public function groupBy($expression): static
public function groupBy(array|Expr|string $expression): static
{
$this->groupBy = $expression;

Expand Down Expand Up @@ -71,12 +70,7 @@ abstract protected function getExtraPipelineFields(): array;
*/
abstract protected function getStageName(): string;

/**
* @param array|mixed|string $expression
*
* @return array|mixed|string
*/
private function convertExpression($expression)
private function convertExpression(mixed $expression): mixed
{
if (is_array($expression)) {
return array_map($this->convertExpression(...), $expression);
Expand Down
6 changes: 3 additions & 3 deletions src/Aggregation/Stage/AbstractReplace.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
abstract class AbstractReplace extends Operator
{
/** @param string|mixed[]|Expr|null $expression */
final public function __construct(Builder $builder, protected DocumentManager $dm, protected ClassMetadata $class, protected $expression = null)
final public function __construct(Builder $builder, protected DocumentManager $dm, protected ClassMetadata $class, protected string|array|Expr|null $expression = null)
{
Operator::__construct($builder);
}
Expand All @@ -30,7 +30,7 @@ private function getDocumentPersister(): DocumentPersister
}

/** @return array<string, mixed>|string */
protected function getReplaceExpression()
protected function getReplaceExpression(): array|string
{
return $this->expression !== null ? $this->convertExpression($this->expression) : $this->expr->getExpression();
}
Expand All @@ -40,7 +40,7 @@ protected function getReplaceExpression()
*
* @return mixed[]|string|mixed
*/
private function convertExpression($expression)
private function convertExpression(mixed $expression): mixed
{
if (is_array($expression)) {
return array_map($this->convertExpression(...), $expression);
Expand Down
10 changes: 3 additions & 7 deletions src/Aggregation/Stage/Bucket/AbstractOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ abstract class AbstractOutput extends Stage implements GroupAccumulatorOperators
{
use ProvidesGroupAccumulatorOperators;

/** @var Stage\AbstractBucket */
protected $bucket;

private Expr $expr;

public function __construct(Builder $builder, Stage\AbstractBucket $bucket)
public function __construct(Builder $builder, protected Stage\AbstractBucket $bucket)
{
parent::__construct($builder);

$this->bucket = $bucket;
$this->expr = $builder->expr();
}

Expand All @@ -47,7 +43,7 @@ public function getExpression(): array
*
* @return $this
*/
public function expression($value): static
public function expression(mixed $value): static
{
$this->expr->expression($value);

Expand All @@ -63,7 +59,7 @@ public function expression($value): static
*
* @return $this
*/
public function field($fieldName): static
public function field(string $fieldName): static
{
$this->expr->field($fieldName);

Expand Down
11 changes: 0 additions & 11 deletions src/Aggregation/Stage/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Doctrine\ODM\MongoDB\Aggregation\Stage;

use Doctrine\ODM\MongoDB\Aggregation\Builder;
use Doctrine\ODM\MongoDB\Aggregation\Expr;
use Doctrine\ODM\MongoDB\Aggregation\Operator\GroupAccumulatorOperators;
use Doctrine\ODM\MongoDB\Aggregation\Operator\ProvidesGroupAccumulatorOperators;
Expand All @@ -18,16 +17,6 @@ class Group extends Operator implements GroupAccumulatorOperators
{
use ProvidesGroupAccumulatorOperators;

/** @var Expr */
protected $expr;

public function __construct(Builder $builder)
{
parent::__construct($builder);

$this->expr = $builder->expr();
}

/** @phpstan-return GroupStageExpression */
public function getExpression(): array
{
Expand Down
37 changes: 18 additions & 19 deletions src/Aggregation/Stage/MatchStage.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*/
class MatchStage extends Stage
{
/** @var Expr */
protected $query;
protected Expr $query;

public function __construct(Builder $builder)
{
Expand All @@ -26,7 +25,7 @@ public function __construct(Builder $builder)
$this->query = $this->expr();
}

public function __clone()
public function __clone(): void
{
$this->query = clone $this->query;
}
Expand All @@ -43,7 +42,7 @@ public function __clone()
* @param mixed[]|Expr $expression
* @param mixed[]|Expr ...$expressions
*/
public function addAnd($expression, ...$expressions): static
public function addAnd(array|Expr $expression, array|Expr ...$expressions): static
{
$this->query->addAnd(...func_get_args());

Expand All @@ -62,7 +61,7 @@ public function addAnd($expression, ...$expressions): static
* @param mixed[]|Expr $expression
* @param mixed[]|Expr ...$expressions
*/
public function addNor($expression, ...$expressions): static
public function addNor(array|Expr $expression, array|Expr ...$expressions): static
{
$this->query->addNor(...func_get_args());

Expand All @@ -81,7 +80,7 @@ public function addNor($expression, ...$expressions): static
* @param mixed[]|Expr $expression
* @param mixed[]|Expr ...$expressions
*/
public function addOr($expression, ...$expressions): static
public function addOr(array|Expr $expression, array|Expr ...$expressions): static
{
$this->query->addOr(...func_get_args());

Expand Down Expand Up @@ -114,7 +113,7 @@ public function all(array $values): static
*
* @param mixed[]|Expr $expression
*/
public function elemMatch($expression): static
public function elemMatch(array|Expr $expression): static
{
$this->query->elemMatch($expression);

Expand All @@ -128,7 +127,7 @@ public function elemMatch($expression): static
*
* @param mixed $value
*/
public function equals($value): static
public function equals(mixed $value): static
{
$this->query->equals($value);

Expand Down Expand Up @@ -180,7 +179,7 @@ public function field(string $field): static
*
* @param array<string, mixed>|Geometry $geometry
*/
public function geoIntersects($geometry): static
public function geoIntersects(array|Geometry $geometry): static
{
$this->query->geoIntersects($geometry);

Expand Down Expand Up @@ -272,7 +271,7 @@ public function geoWithinCenterSphere(float $x, float $y, float $radius): static
* @param array{int|float, int|float} $point3 Third point of the polygon
* @param array{int|float, int|float} ...$points Additional points of the polygon
*/
public function geoWithinPolygon($point1, $point2, $point3, ...$points): static
public function geoWithinPolygon(array $point1, array $point2, array $point3, array ...$points): static
{
$this->query->geoWithinPolygon(...func_get_args());

Expand All @@ -298,7 +297,7 @@ public function getExpression(): ?array
*
* @param mixed $value
*/
public function gt($value): static
public function gt(mixed $value): static
{
$this->query->gt($value);

Expand All @@ -313,7 +312,7 @@ public function gt($value): static
*
* @param mixed $value
*/
public function gte($value): static
public function gte(mixed $value): static
{
$this->query->gte($value);

Expand Down Expand Up @@ -365,7 +364,7 @@ public function language(string $language): static
*
* @param mixed $value
*/
public function lt($value): static
public function lt(mixed $value): static
{
$this->query->lt($value);

Expand All @@ -380,7 +379,7 @@ public function lt($value): static
*
* @param mixed $value
*/
public function lte($value): static
public function lte(mixed $value): static
{
$this->query->lte($value);

Expand All @@ -396,7 +395,7 @@ public function lte($value): static
* @param float|int $divisor
* @param float|int $remainder
*/
public function mod($divisor, $remainder = 0): static
public function mod(float|int $divisor, float|int $remainder = 0): static
{
$this->query->mod($divisor, $remainder);

Expand All @@ -414,7 +413,7 @@ public function mod($divisor, $remainder = 0): static
*
* @param mixed[]|Expr $expression
*/
public function not($expression): static
public function not(array|Expr $expression): static
{
$this->query->not($expression);

Expand All @@ -429,7 +428,7 @@ public function not($expression): static
*
* @param mixed $value
*/
public function notEqual($value): static
public function notEqual(mixed $value): static
{
$this->query->notEqual($value);

Expand Down Expand Up @@ -462,7 +461,7 @@ public function notIn(array $values): static
* @param mixed $start
* @param mixed $end
*/
public function range($start, $end): static
public function range(mixed $start, mixed $end): static
{
$this->query->range($start, $end);

Expand Down Expand Up @@ -514,7 +513,7 @@ public function text(string $search): static
*
* @param int|string $type
*/
public function type($type): static
public function type(int|string $type): static
{
$this->query->type($type);

Expand Down
7 changes: 3 additions & 4 deletions src/Aggregation/Stage/Operator.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ abstract class Operator extends Stage implements
TrigonometryOperators,
TypeOperators
{
/** @var Expr */
protected $expr;
protected Expr $expr;

public function __construct(Builder $builder)
{
Expand Down Expand Up @@ -94,7 +93,7 @@ public function add($expression1, $expression2, ...$expressions): static
* @param mixed[]|Expr $expression
* @param mixed[]|Expr ...$expressions
*/
public function addAnd($expression, ...$expressions): static
public function addAnd(array|Expr $expression, array|Expr ...$expressions): static
{
$this->expr->addAnd(...func_get_args());

Expand All @@ -110,7 +109,7 @@ public function addAnd($expression, ...$expressions): static
* @param mixed[]|Expr $expression
* @param mixed[]|Expr ...$expressions
*/
public function addOr($expression, ...$expressions): static
public function addOr(array|Expr $expression, array|Expr ...$expressions): static
{
$this->expr->addOr(...func_get_args());

Expand Down
10 changes: 5 additions & 5 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,31 +67,31 @@ class Configuration
* it was generated by some process before deployment. Copied from
* \Doctrine\Common\Proxy\AbstractProxyFactory.
*/
public const AUTOGENERATE_NEVER = 0;
public const int AUTOGENERATE_NEVER = 0;

/**
* Always generates a new proxy/hydrator/persistent collection in every request.
*
* This is only sane during development.
* Copied from \Doctrine\Common\Proxy\AbstractProxyFactory.
*/
public const AUTOGENERATE_ALWAYS = 1;
public const int AUTOGENERATE_ALWAYS = 1;

/**
* Autogenerate the proxy/hydrator/persistent collection class when the file does not exist.
*
* This strategy causes a file exists call whenever any proxy/hydrator is used the
* first time in a request. Copied from \Doctrine\Common\Proxy\AbstractProxyFactory.
*/
public const AUTOGENERATE_FILE_NOT_EXISTS = 2;
public const int AUTOGENERATE_FILE_NOT_EXISTS = 2;

/**
* Generate the proxy/hydrator/persistent collection classes using eval().
*
* This strategy is only sane for development.
* Copied from \Doctrine\Common\Proxy\AbstractProxyFactory.
*/
public const AUTOGENERATE_EVAL = 3;
public const int AUTOGENERATE_EVAL = 3;

/**
* Autogenerate the proxy class when the proxy file does not exist or
Expand All @@ -101,7 +101,7 @@ class Configuration
* first time in a request. When the proxied file is changed, the proxy will
* be updated.
*/
public const AUTOGENERATE_FILE_NOT_EXISTS_OR_CHANGED = 4;
public const int AUTOGENERATE_FILE_NOT_EXISTS_OR_CHANGED = 4;

/**
* Array of attributes for this configuration instance.
Expand Down
Loading
Loading