Skip to content

Commit 3fac3a1

Browse files
committed
run rector with typeDeclarations to true
1 parent 44cb59d commit 3fac3a1

233 files changed

Lines changed: 528 additions & 702 deletions

File tree

Some content is hidden

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

rector.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@
2929
__DIR__.'/src/Doctrine/Odm/Tests/var',
3030
__DIR__.'/tests/Fixtures/app/config/reference.php',
3131
__DIR__.'/src/Symfony/Bundle/DependencyInjection/Configuration.php',
32+
__DIR__.'/tests/Fixer/SymfonyServiceClassConstantFixer.php',
3233
])
3334
// uncomment to reach your current PHP version
3435
// ->withPhpSets()
35-
->withTypeCoverageLevel(0)
36+
->withPreparedSets(
37+
typeDeclarations: true,
38+
)
3639
->withDeadCodeLevel(0)
3740
->withCodeQualityLevel(0);

src/Doctrine/Common/Filter/BackedEnumFilterTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function getDescription(string $resourceClass): array
5959
foreach ($filterParameterNames as $filterParameterName) {
6060
$isCollection = str_ends_with($filterParameterName, '[]');
6161

62-
$enumValues = array_map(static fn (\BackedEnum $case) => $case->value, $this->enumTypes[$property]::cases());
62+
$enumValues = array_map(static fn (\BackedEnum $case): int|string => $case->value, $this->enumTypes[$property]::cases());
6363

6464
$schema = $isCollection
6565
? ['type' => 'array', 'items' => ['type' => 'string', 'enum' => $enumValues]]
@@ -99,7 +99,7 @@ private function normalizeValue(mixed $value, string $property): mixed
9999
$value = (int) $value;
100100
}
101101

102-
$values = array_map(static fn (\BackedEnum $case) => $case->value, $this->enumTypes[$property]::cases());
102+
$values = array_map(static fn (\BackedEnum $case): int|string => $case->value, $this->enumTypes[$property]::cases());
103103

104104
if (\in_array($value, $values, true)) {
105105
return $value;

src/Doctrine/Common/State/LinksHandlerLocatorTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private function findSimilarMethod(string $className, string $methodName): ?stri
5858
{
5959
$methods = get_class_methods($className);
6060

61-
$similarMethods = array_filter($methods, static function ($method) use ($methodName) {
61+
$similarMethods = array_filter($methods, static function ($method) use ($methodName): bool {
6262
return levenshtein($methodName, $method) <= 3;
6363
});
6464

src/Doctrine/Common/State/PersistProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private function handleLazyObjectRelations(object $data, DoctrineObjectManager $
196196
$identifiers = $metadata->getIdentifierValues($value);
197197

198198
// Do not get reference for partial objects or objects with null identifiers
199-
if (!$identifiers || \count($identifiers) !== \count(array_filter($identifiers, static fn ($v) => null !== $v))) {
199+
if (!$identifiers || \count($identifiers) !== \count(array_filter($identifiers, static fn ($v): bool => null !== $v))) {
200200
continue;
201201
}
202202

src/Doctrine/Common/Tests/CollectionPaginatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class CollectionPaginatorTest extends TestCase
2222
{
2323
#[DataProvider('initializeProvider')]
24-
public function testInitialize($results, $currentPage, $itemsPerPage, $totalItems, $lastPage, $currentItems): void
24+
public function testInitialize(array $results, int $currentPage, int $itemsPerPage, int $totalItems, int $lastPage, int $currentItems): void
2525
{
2626
$results = new ArrayCollection($results);
2727
$paginator = new CollectionPaginator($results, $currentPage, $itemsPerPage);

src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/Dummy.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function getDummyDate()
209209
return $this->dummyDate;
210210
}
211211

212-
public function setDummyPrice($dummyPrice)
212+
public function setDummyPrice($dummyPrice): static
213213
{
214214
$this->dummyPrice = $dummyPrice;
215215

@@ -284,10 +284,7 @@ public function isDummyBoolean(): ?bool
284284
return $this->dummyBoolean;
285285
}
286286

287-
/**
288-
* @param bool $dummyBoolean
289-
*/
290-
public function setDummyBoolean($dummyBoolean): void
287+
public function setDummyBoolean(?bool $dummyBoolean): void
291288
{
292289
$this->dummyBoolean = $dummyBoolean;
293290
}

src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/RelatedDummy.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ public function isDummyBoolean(): ?bool
148148
return $this->dummyBoolean;
149149
}
150150

151-
/**
152-
* @param bool $dummyBoolean
153-
*/
154-
public function setDummyBoolean($dummyBoolean): void
151+
public function setDummyBoolean(?bool $dummyBoolean): void
155152
{
156153
$this->dummyBoolean = $dummyBoolean;
157154
}

src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/RelatedToDummyFriend.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ public function getDescription(): ?string
7474
return $this->description;
7575
}
7676

77-
/**
78-
* @param string|null $description
79-
*/
80-
public function setDescription($description): void
77+
public function setDescription(?string $description): void
8178
{
8279
$this->description = $description;
8380
}

src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/ThirdLevel.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ public function getLevel(): ?int
6161
return $this->level;
6262
}
6363

64-
/**
65-
* @param int $level
66-
*/
67-
public function setLevel($level): void
64+
public function setLevel(int $level): void
6865
{
6966
$this->level = $level;
7067
}
@@ -74,10 +71,7 @@ public function isTest(): bool
7471
return $this->test;
7572
}
7673

77-
/**
78-
* @param bool $test
79-
*/
80-
public function setTest($test): void
74+
public function setTest(bool $test): void
8175
{
8276
$this->test = $test;
8377
}

src/Doctrine/Common/Tests/SelectablePaginatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class SelectablePaginatorTest extends TestCase
2222
{
2323
#[DataProvider('initializeProvider')]
24-
public function testInitialize($results, $currentPage, $itemsPerPage, $totalItems, $lastPage, $currentItems): void
24+
public function testInitialize(array $results, int $currentPage, int $itemsPerPage, int $totalItems, int $lastPage, int $currentItems): void
2525
{
2626
$results = new ArrayCollection($results);
2727
$paginator = new SelectablePaginator($results, $currentPage, $itemsPerPage);

0 commit comments

Comments
 (0)