Skip to content

Commit a693b5f

Browse files
committed
Add more types
1 parent 3ecee52 commit a693b5f

28 files changed

+88
-202
lines changed

src/APM/Command.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ public static function createForFailedCommand(CommandStartedEvent $startedEvent,
4141
return $instance;
4242
}
4343

44-
/** @param CommandSucceededEvent|CommandFailedEvent $finishedEvent */
45-
private static function checkRequestIds(CommandStartedEvent $startedEvent, $finishedEvent): void
44+
private static function checkRequestIds(CommandStartedEvent $startedEvent, CommandSucceededEvent|CommandFailedEvent $finishedEvent): void
4645
{
4746
if ($startedEvent->getRequestId() !== $finishedEvent->getRequestId()) {
4847
throw new LogicException('Cannot create APM command for events with different request IDs');

src/DocumentManager.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ public function detach(object $object): void
538538
* @throws LockException
539539
* @throws InvalidArgumentException If the $object param is not an object.
540540
*/
541-
public function merge(object $object)
541+
public function merge(object $object): object
542542
{
543543
$this->errorIfClosed();
544544

@@ -669,15 +669,12 @@ public function getPartialReference(string $documentName, mixed $identifier): ob
669669
* This is just a convenient shortcut for getRepository($documentName)->find($id).
670670
*
671671
* @param class-string<T> $className
672-
* @param mixed $id
673-
* @param int $lockMode
674-
* @param int $lockVersion
675672
*
676673
* @return T|null
677674
*
678675
* @template T of object
679676
*/
680-
public function find($className, $id, $lockMode = LockMode::NONE, $lockVersion = null): ?object
677+
public function find(string $className, mixed $id, int $lockMode = LockMode::NONE, ?int $lockVersion = null): ?object
681678
{
682679
$repository = $this->getRepository($className);
683680
if ($repository instanceof DocumentRepository) {

src/Event/DocumentNotFoundEventArgs.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ final class DocumentNotFoundEventArgs extends LifecycleEventArgs
1313
{
1414
private bool $disableException = false;
1515

16-
public function __construct(object $document, DocumentManager $dm, private mixed $identifier)
16+
public function __construct(object $document, DocumentManager $dm, private readonly mixed $identifier)
1717
{
1818
parent::__construct($document, $dm);
1919
}
2020

2121
/**
2222
* Retrieve associated identifier.
23-
*
24-
* @return mixed
2523
*/
26-
public function getIdentifier()
24+
public function getIdentifier(): mixed
2725
{
2826
return $this->identifier;
2927
}

src/Event/PreUpdateEventArgs.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ public function __construct(
2727
?Session $session = null,
2828
) {
2929
parent::__construct($document, $dm, $session);
30-
31-
$this->changeSet = $changeSet;
3230
}
3331

3432
/** @return array<string, ChangeSet> */
@@ -44,10 +42,8 @@ public function hasChangedField(string $field): bool
4442

4543
/**
4644
* Gets the old value of the changeset of the changed field.
47-
*
48-
* @return mixed
4945
*/
50-
public function getOldValue(string $field)
46+
public function getOldValue(string $field): mixed
5147
{
5248
$this->assertValidField($field);
5349

@@ -56,10 +52,8 @@ public function getOldValue(string $field)
5652

5753
/**
5854
* Gets the new value of the changeset of the changed field.
59-
*
60-
* @return mixed
6155
*/
62-
public function getNewValue(string $field)
56+
public function getNewValue(string $field): mixed
6357
{
6458
$this->assertValidField($field);
6559

@@ -68,10 +62,8 @@ public function getNewValue(string $field)
6862

6963
/**
7064
* Sets the new value of this field.
71-
*
72-
* @param mixed $value
7365
*/
74-
public function setNewValue(string $field, $value): void
66+
public function setNewValue(string $field, mixed $value): void
7567
{
7668
$this->assertValidField($field);
7769

src/Hydrator/HydratorException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ public static function associationTypeMismatch(string $className, string $fieldN
3939
));
4040
}
4141

42-
/** @param int|string $key */
43-
public static function associationItemTypeMismatch(string $className, string $fieldName, $key, string $expectedType, string $actualType): self
42+
public static function associationItemTypeMismatch(string $className, string $fieldName, int|string $key, string $expectedType, string $actualType): self
4443
{
4544
return new self(sprintf(
4645
'Expected association item with key "%s" for field "%s" in document of type "%s" to be of type "%s", "%s" received.',

src/Iterator/CachingIterator.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Countable;
88
use Iterator as SPLIterator;
99
use IteratorIterator;
10-
use ReturnTypeWillChange;
1110
use RuntimeException;
1211
use Traversable;
1312

@@ -77,15 +76,12 @@ public function toArray(): array
7776
}
7877

7978
/** @return TValue|false */
80-
#[ReturnTypeWillChange]
81-
public function current()
79+
public function current(): mixed
8280
{
8381
return current($this->items);
8482
}
8583

86-
/** @return mixed */
87-
#[ReturnTypeWillChange]
88-
public function key()
84+
public function key(): string|int|null
8985
{
9086
return key($this->items);
9187
}

src/Iterator/HydratingIterator.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Doctrine\ODM\MongoDB\UnitOfWork;
99
use Iterator;
1010
use IteratorIterator;
11-
use ReturnTypeWillChange;
1211
use RuntimeException;
1312
use Traversable;
1413

@@ -44,15 +43,12 @@ public function __destruct()
4443
}
4544

4645
/** @return TDocument|null */
47-
#[ReturnTypeWillChange]
48-
public function current()
46+
public function current(): mixed
4947
{
5048
return $this->hydrate($this->getIterator()->current());
5149
}
5250

53-
/** @return mixed */
54-
#[ReturnTypeWillChange]
55-
public function key()
51+
public function key(): mixed
5652
{
5753
return $this->getIterator()->key();
5854
}

src/Iterator/PrimingIterator.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
88
use Doctrine\ODM\MongoDB\Query\ReferencePrimer;
99
use Doctrine\ODM\MongoDB\UnitOfWork;
10-
use ReturnTypeWillChange;
1110

1211
use function is_callable;
1312
use function iterator_to_array;
@@ -38,8 +37,7 @@ public function toArray(): array
3837
}
3938

4039
/** @return TValue|null */
41-
#[ReturnTypeWillChange]
42-
public function current()
40+
public function current(): mixed
4341
{
4442
$this->primeReferences();
4543

@@ -51,9 +49,7 @@ public function next(): void
5149
$this->iterator->next();
5250
}
5351

54-
/** @return mixed */
55-
#[ReturnTypeWillChange]
56-
public function key()
52+
public function key(): mixed
5753
{
5854
return $this->iterator->key();
5955
}

src/Iterator/UnrewindableIterator.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Iterator as SPLIterator;
88
use IteratorIterator;
99
use LogicException;
10-
use ReturnTypeWillChange;
1110
use RuntimeException;
1211
use Traversable;
1312

@@ -55,21 +54,14 @@ public function toArray(): array
5554
}
5655

5756
/** @return TValue|null */
58-
#[ReturnTypeWillChange]
59-
public function current()
57+
public function current(): mixed
6058
{
6159
return $this->getIterator()->current();
6260
}
6361

64-
/** @return mixed */
65-
#[ReturnTypeWillChange]
66-
public function key()
62+
public function key(): mixed
6763
{
68-
if ($this->iterator) {
69-
return $this->iterator->key();
70-
}
71-
72-
return null;
64+
return $this->iterator?->key();
7365
}
7466

7567
public function next(): void

src/MongoDBException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,10 @@ public static function invalidClassMetadataFactory(string $className): self
6868

6969
/**
7070
* @param string|string[] $expected
71-
* @param mixed $got
7271
*
7372
* @return MongoDBException
7473
*/
75-
public static function invalidValueForType(string $type, $expected, $got): self
74+
public static function invalidValueForType(string $type, string|array $expected, mixed $got): self
7675
{
7776
if (is_array($expected)) {
7877
$expected = sprintf(

0 commit comments

Comments
 (0)