Skip to content

Commit 022367a

Browse files
committed
Add missing types
1 parent 3568ecf commit 022367a

Some content is hidden

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

43 files changed

+319
-614
lines changed

src/Aggregation/Stage.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@
1818
*/
1919
abstract class Stage
2020
{
21-
/** @var Builder */
22-
protected $builder;
23-
24-
public function __construct(Builder $builder)
21+
public function __construct(protected Builder $builder)
2522
{
26-
$this->builder = $builder;
2723
}
2824

2925
/**

src/Aggregation/Stage/AbstractBucket.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@
2424
*/
2525
abstract class AbstractBucket extends Stage
2626
{
27-
/** @var Bucket\AbstractOutput|null */
28-
protected $output;
27+
protected ?Bucket\AbstractOutput $output = null;
2928

3029
/** @var Expr|array<string, mixed>|string */
31-
protected $groupBy;
30+
protected Expr|array|string $groupBy;
3231

3332
public function __construct(Builder $builder, private DocumentManager $dm, private ClassMetadata $class)
3433
{
@@ -41,7 +40,7 @@ public function __construct(Builder $builder, private DocumentManager $dm, priva
4140
*
4241
* @param array<string, mixed>|Expr|string $expression
4342
*/
44-
public function groupBy($expression): static
43+
public function groupBy(array|Expr|string $expression): static
4544
{
4645
$this->groupBy = $expression;
4746

@@ -71,12 +70,7 @@ abstract protected function getExtraPipelineFields(): array;
7170
*/
7271
abstract protected function getStageName(): string;
7372

74-
/**
75-
* @param array|mixed|string $expression
76-
*
77-
* @return array|mixed|string
78-
*/
79-
private function convertExpression($expression)
73+
private function convertExpression(mixed $expression): mixed
8074
{
8175
if (is_array($expression)) {
8276
return array_map($this->convertExpression(...), $expression);

src/Aggregation/Stage/AbstractReplace.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
abstract class AbstractReplace extends Operator
2020
{
2121
/** @param string|mixed[]|Expr|null $expression */
22-
final public function __construct(Builder $builder, protected DocumentManager $dm, protected ClassMetadata $class, protected $expression = null)
22+
final public function __construct(Builder $builder, protected DocumentManager $dm, protected ClassMetadata $class, protected string|array|Expr|null $expression = null)
2323
{
2424
Operator::__construct($builder);
2525
}
@@ -30,7 +30,7 @@ private function getDocumentPersister(): DocumentPersister
3030
}
3131

3232
/** @return array<string, mixed>|string */
33-
protected function getReplaceExpression()
33+
protected function getReplaceExpression(): array|string
3434
{
3535
return $this->expression !== null ? $this->convertExpression($this->expression) : $this->expr->getExpression();
3636
}
@@ -40,7 +40,7 @@ protected function getReplaceExpression()
4040
*
4141
* @return mixed[]|string|mixed
4242
*/
43-
private function convertExpression($expression)
43+
private function convertExpression(mixed $expression): mixed
4444
{
4545
if (is_array($expression)) {
4646
return array_map($this->convertExpression(...), $expression);

src/Aggregation/Stage/Bucket/AbstractOutput.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,12 @@ abstract class AbstractOutput extends Stage implements GroupAccumulatorOperators
1919
{
2020
use ProvidesGroupAccumulatorOperators;
2121

22-
/** @var Stage\AbstractBucket */
23-
protected $bucket;
24-
2522
private Expr $expr;
2623

27-
public function __construct(Builder $builder, Stage\AbstractBucket $bucket)
24+
public function __construct(Builder $builder, protected Stage\AbstractBucket $bucket)
2825
{
2926
parent::__construct($builder);
3027

31-
$this->bucket = $bucket;
3228
$this->expr = $builder->expr();
3329
}
3430

@@ -47,7 +43,7 @@ public function getExpression(): array
4743
*
4844
* @return $this
4945
*/
50-
public function expression($value): static
46+
public function expression(mixed $value): static
5147
{
5248
$this->expr->expression($value);
5349

@@ -63,7 +59,7 @@ public function expression($value): static
6359
*
6460
* @return $this
6561
*/
66-
public function field($fieldName): static
62+
public function field(string $fieldName): static
6763
{
6864
$this->expr->field($fieldName);
6965

src/Aggregation/Stage/Group.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Doctrine\ODM\MongoDB\Aggregation\Stage;
66

7-
use Doctrine\ODM\MongoDB\Aggregation\Builder;
87
use Doctrine\ODM\MongoDB\Aggregation\Expr;
98
use Doctrine\ODM\MongoDB\Aggregation\Operator\GroupAccumulatorOperators;
109
use Doctrine\ODM\MongoDB\Aggregation\Operator\ProvidesGroupAccumulatorOperators;
@@ -18,16 +17,6 @@ class Group extends Operator implements GroupAccumulatorOperators
1817
{
1918
use ProvidesGroupAccumulatorOperators;
2019

21-
/** @var Expr */
22-
protected $expr;
23-
24-
public function __construct(Builder $builder)
25-
{
26-
parent::__construct($builder);
27-
28-
$this->expr = $builder->expr();
29-
}
30-
3120
/** @phpstan-return GroupStageExpression */
3221
public function getExpression(): array
3322
{

src/Aggregation/Stage/MatchStage.php

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
*/
1717
class MatchStage extends Stage
1818
{
19-
/** @var Expr */
20-
protected $query;
19+
protected Expr $query;
2120

2221
public function __construct(Builder $builder)
2322
{
@@ -26,7 +25,7 @@ public function __construct(Builder $builder)
2625
$this->query = $this->expr();
2726
}
2827

29-
public function __clone()
28+
public function __clone(): void
3029
{
3130
$this->query = clone $this->query;
3231
}
@@ -43,7 +42,7 @@ public function __clone()
4342
* @param mixed[]|Expr $expression
4443
* @param mixed[]|Expr ...$expressions
4544
*/
46-
public function addAnd($expression, ...$expressions): static
45+
public function addAnd(array|Expr $expression, array|Expr ...$expressions): static
4746
{
4847
$this->query->addAnd(...func_get_args());
4948

@@ -62,7 +61,7 @@ public function addAnd($expression, ...$expressions): static
6261
* @param mixed[]|Expr $expression
6362
* @param mixed[]|Expr ...$expressions
6463
*/
65-
public function addNor($expression, ...$expressions): static
64+
public function addNor(array|Expr $expression, array|Expr ...$expressions): static
6665
{
6766
$this->query->addNor(...func_get_args());
6867

@@ -81,7 +80,7 @@ public function addNor($expression, ...$expressions): static
8180
* @param mixed[]|Expr $expression
8281
* @param mixed[]|Expr ...$expressions
8382
*/
84-
public function addOr($expression, ...$expressions): static
83+
public function addOr(array|Expr $expression, array|Expr ...$expressions): static
8584
{
8685
$this->query->addOr(...func_get_args());
8786

@@ -114,7 +113,7 @@ public function all(array $values): static
114113
*
115114
* @param mixed[]|Expr $expression
116115
*/
117-
public function elemMatch($expression): static
116+
public function elemMatch(array|Expr $expression): static
118117
{
119118
$this->query->elemMatch($expression);
120119

@@ -128,7 +127,7 @@ public function elemMatch($expression): static
128127
*
129128
* @param mixed $value
130129
*/
131-
public function equals($value): static
130+
public function equals(mixed $value): static
132131
{
133132
$this->query->equals($value);
134133

@@ -180,7 +179,7 @@ public function field(string $field): static
180179
*
181180
* @param array<string, mixed>|Geometry $geometry
182181
*/
183-
public function geoIntersects($geometry): static
182+
public function geoIntersects(array|Geometry $geometry): static
184183
{
185184
$this->query->geoIntersects($geometry);
186185

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

@@ -298,7 +297,7 @@ public function getExpression(): ?array
298297
*
299298
* @param mixed $value
300299
*/
301-
public function gt($value): static
300+
public function gt(mixed $value): static
302301
{
303302
$this->query->gt($value);
304303

@@ -313,7 +312,7 @@ public function gt($value): static
313312
*
314313
* @param mixed $value
315314
*/
316-
public function gte($value): static
315+
public function gte(mixed $value): static
317316
{
318317
$this->query->gte($value);
319318

@@ -365,7 +364,7 @@ public function language(string $language): static
365364
*
366365
* @param mixed $value
367366
*/
368-
public function lt($value): static
367+
public function lt(mixed $value): static
369368
{
370369
$this->query->lt($value);
371370

@@ -380,7 +379,7 @@ public function lt($value): static
380379
*
381380
* @param mixed $value
382381
*/
383-
public function lte($value): static
382+
public function lte(mixed $value): static
384383
{
385384
$this->query->lte($value);
386385

@@ -396,7 +395,7 @@ public function lte($value): static
396395
* @param float|int $divisor
397396
* @param float|int $remainder
398397
*/
399-
public function mod($divisor, $remainder = 0): static
398+
public function mod(float|int $divisor, float|int $remainder = 0): static
400399
{
401400
$this->query->mod($divisor, $remainder);
402401

@@ -414,7 +413,7 @@ public function mod($divisor, $remainder = 0): static
414413
*
415414
* @param mixed[]|Expr $expression
416415
*/
417-
public function not($expression): static
416+
public function not(array|Expr $expression): static
418417
{
419418
$this->query->not($expression);
420419

@@ -429,7 +428,7 @@ public function not($expression): static
429428
*
430429
* @param mixed $value
431430
*/
432-
public function notEqual($value): static
431+
public function notEqual(mixed $value): static
433432
{
434433
$this->query->notEqual($value);
435434

@@ -462,7 +461,7 @@ public function notIn(array $values): static
462461
* @param mixed $start
463462
* @param mixed $end
464463
*/
465-
public function range($start, $end): static
464+
public function range(mixed $start, mixed $end): static
466465
{
467466
$this->query->range($start, $end);
468467

@@ -514,7 +513,7 @@ public function text(string $search): static
514513
*
515514
* @param int|string $type
516515
*/
517-
public function type($type): static
516+
public function type(int|string $type): static
518517
{
519518
$this->query->type($type);
520519

src/Aggregation/Stage/Operator.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ abstract class Operator extends Stage implements
4747
TrigonometryOperators,
4848
TypeOperators
4949
{
50-
/** @var Expr */
51-
protected $expr;
50+
protected Expr $expr;
5251

5352
public function __construct(Builder $builder)
5453
{
@@ -94,7 +93,7 @@ public function add($expression1, $expression2, ...$expressions): static
9493
* @param mixed[]|Expr $expression
9594
* @param mixed[]|Expr ...$expressions
9695
*/
97-
public function addAnd($expression, ...$expressions): static
96+
public function addAnd(array|Expr $expression, array|Expr ...$expressions): static
9897
{
9998
$this->expr->addAnd(...func_get_args());
10099

@@ -110,7 +109,7 @@ public function addAnd($expression, ...$expressions): static
110109
* @param mixed[]|Expr $expression
111110
* @param mixed[]|Expr ...$expressions
112111
*/
113-
public function addOr($expression, ...$expressions): static
112+
public function addOr(array|Expr $expression, array|Expr ...$expressions): static
114113
{
115114
$this->expr->addOr(...func_get_args());
116115

src/Configuration.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,31 @@ class Configuration
6767
* it was generated by some process before deployment. Copied from
6868
* \Doctrine\Common\Proxy\AbstractProxyFactory.
6969
*/
70-
public const AUTOGENERATE_NEVER = 0;
70+
public const int AUTOGENERATE_NEVER = 0;
7171

7272
/**
7373
* Always generates a new proxy/hydrator/persistent collection in every request.
7474
*
7575
* This is only sane during development.
7676
* Copied from \Doctrine\Common\Proxy\AbstractProxyFactory.
7777
*/
78-
public const AUTOGENERATE_ALWAYS = 1;
78+
public const int AUTOGENERATE_ALWAYS = 1;
7979

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

8888
/**
8989
* Generate the proxy/hydrator/persistent collection classes using eval().
9090
*
9191
* This strategy is only sane for development.
9292
* Copied from \Doctrine\Common\Proxy\AbstractProxyFactory.
9393
*/
94-
public const AUTOGENERATE_EVAL = 3;
94+
public const int AUTOGENERATE_EVAL = 3;
9595

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

106106
/**
107107
* Array of attributes for this configuration instance.

0 commit comments

Comments
 (0)