Skip to content

Commit 5987555

Browse files
authored
Use typed properties (#2473)
1 parent a6c0f65 commit 5987555

File tree

99 files changed

+307
-590
lines changed

Some content is hidden

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

99 files changed

+307
-590
lines changed

lib/Doctrine/ODM/MongoDB/APM/Command.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
final class Command
1515
{
16-
/** @var CommandStartedEvent */
17-
private $startedEvent;
16+
private CommandStartedEvent $startedEvent;
1817

1918
/** @var CommandSucceededEvent|CommandFailedEvent */
2019
private $finishedEvent;

lib/Doctrine/ODM/MongoDB/APM/CommandLogger.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
final class CommandLogger implements Countable, CommandLoggerInterface
1717
{
1818
/** @var Command[] */
19-
private $commands = [];
19+
private array $commands = [];
2020

2121
/** @var CommandStartedEvent[] */
22-
private $startedCommands = [];
22+
private array $startedCommands = [];
2323

24-
/** @var bool */
25-
private $registered = false;
24+
private bool $registered = false;
2625

2726
public function register(): void
2827
{

lib/Doctrine/ODM/MongoDB/Aggregation/Aggregation.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,19 @@
1919

2020
final class Aggregation implements IteratorAggregate
2121
{
22-
/** @var DocumentManager */
23-
private $dm;
22+
private DocumentManager $dm;
2423

25-
/** @var ClassMetadata|null */
26-
private $classMetadata;
24+
private ?ClassMetadata $classMetadata;
2725

28-
/** @var Collection */
29-
private $collection;
26+
private Collection $collection;
3027

3128
/** @var array<string, mixed> */
32-
private $pipeline;
29+
private array $pipeline;
3330

3431
/** @var array<string, mixed> */
35-
private $options;
32+
private array $options;
3633

37-
/** @var bool */
38-
private $rewindable;
34+
private bool $rewindable;
3935

4036
/**
4137
* @param array<string, mixed> $pipeline

lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,26 @@ class Builder
3434
{
3535
/**
3636
* The DocumentManager instance for this query
37-
*
38-
* @var DocumentManager
3937
*/
40-
private $dm;
38+
private DocumentManager $dm;
4139

4240
/**
4341
* The ClassMetadata instance.
44-
*
45-
* @var ClassMetadata
4642
*/
47-
private $class;
43+
private ClassMetadata $class;
4844

49-
/**
50-
* @var string
51-
* @psalm-var class-string
52-
*/
53-
private $hydrationClass;
45+
/** @psalm-var class-string */
46+
private ?string $hydrationClass = null;
5447

5548
/**
5649
* The Collection instance.
57-
*
58-
* @var Collection
5950
*/
60-
private $collection;
51+
private Collection $collection;
6152

6253
/** @var Stage[] */
63-
private $stages = [];
54+
private array $stages = [];
6455

65-
/** @var bool */
66-
private $rewindable = true;
56+
private bool $rewindable = true;
6757

6858
/**
6959
* Create a new aggregation builder.

lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,20 @@
2525
*/
2626
class Expr
2727
{
28-
/** @var DocumentManager */
29-
private $dm;
28+
private DocumentManager $dm;
3029

31-
/** @var ClassMetadata */
32-
private $class;
30+
private ClassMetadata $class;
3331

3432
/** @var array<string, mixed> */
35-
private $expr = [];
33+
private array $expr = [];
3634

3735
/**
3836
* The current field we are operating on.
39-
*
40-
* @var string
4137
*/
42-
private $currentField;
38+
private ?string $currentField = null;
4339

4440
/** @var array{case: mixed|self, then?: mixed|self}|null */
45-
private $switchBranch;
41+
private ?array $switchBranch = null;
4642

4743
public function __construct(DocumentManager $dm, ClassMetadataInterface $class)
4844
{

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/AbstractBucket.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
*/
2525
abstract class AbstractBucket extends Stage
2626
{
27-
/** @var DocumentManager */
28-
private $dm;
27+
private DocumentManager $dm;
2928

30-
/** @var ClassMetadata */
31-
private $class;
29+
private ClassMetadata $class;
3230

3331
/** @var Bucket\AbstractOutput|null */
3432
protected $output;

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class Bucket extends AbstractBucket
1313
{
1414
/** @var mixed[] */
15-
private $boundaries;
15+
private array $boundaries;
1616

1717
/** @var mixed */
1818
private $default;
@@ -70,7 +70,8 @@ public function output(): Bucket\BucketOutput
7070
*/
7171
protected function getExtraPipelineFields(): array
7272
{
73-
$fields = ['boundaries' => $this->boundaries];
73+
/** @psalm-suppress RedundantPropertyInitializationCheck because the property might not be set yet */
74+
$fields = ['boundaries' => $this->boundaries ?? null];
7475
if ($this->default !== null) {
7576
$fields['default'] = $this->default;
7677
}

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/AbstractOutput.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ abstract class AbstractOutput extends Stage
1818
/** @var Stage\AbstractBucket */
1919
protected $bucket;
2020

21-
/** @var Expr */
22-
private $expr;
21+
private Expr $expr;
2322

2423
public function __construct(Builder $builder, Stage\AbstractBucket $bucket)
2524
{

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/BucketAuto.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
*/
1212
class BucketAuto extends AbstractBucket
1313
{
14-
/** @var int */
15-
private $buckets;
14+
private ?int $buckets = null;
1615

17-
/** @var string|null */
18-
private $granularity;
16+
private ?string $granularity = null;
1917

2018
/**
2119
* A positive 32-bit integer that specifies the number of buckets into which

lib/Doctrine/ODM/MongoDB/Aggregation/Stage/CollStats.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ class CollStats extends Stage
1616
public const LATENCY_STATS_SIMPLE = 1;
1717
public const LATENCY_STATS_HISTOGRAMS = 2;
1818

19-
/** @var int */
20-
private $latencyStats = self::LATENCY_STATS_NONE;
19+
private int $latencyStats = self::LATENCY_STATS_NONE;
2120

22-
/** @var bool */
23-
private $storageStats = false;
21+
private bool $storageStats = false;
2422

2523
public function __construct(Builder $builder)
2624
{

0 commit comments

Comments
 (0)