Skip to content

Commit 2611f42

Browse files
chore: add param type
1 parent 77b292b commit 2611f42

File tree

73 files changed

+224
-56
lines changed

Some content is hidden

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

73 files changed

+224
-56
lines changed

phpstan.neon.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ parameters:
149149
- src/Symfony/Bundle/Test
150150
- src/Symfony/Tests
151151
- tests
152-
- src # TODO
153152
-
154153
identifier: missingType.return
155154
paths:

src/Doctrine/Common/Filter/BackedEnumFilterTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ abstract protected function normalizePropertyName(string $property): string;
8989
*/
9090
abstract protected function isBackedEnumField(string $property, string $resourceClass): bool;
9191

92-
private function normalizeValue($value, string $property): mixed
92+
private function normalizeValue(mixed $value, string $property): mixed
9393
{
9494
$firstCase = $this->enumTypes[$property]::cases()[0] ?? null;
9595
if (

src/Doctrine/Common/Filter/BooleanFilterTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function isBooleanField(string $property, string $resourceClass): bool
7575
return isset(self::DOCTRINE_BOOLEAN_TYPES[(string) $this->getDoctrineFieldType($property, $resourceClass)]);
7676
}
7777

78-
private function normalizeValue($value, string $property): ?bool
78+
private function normalizeValue(mixed $value, string $property): ?bool
7979
{
8080
if (\in_array($value, [true, 'true', '1'], true)) {
8181
return true;

src/Doctrine/Common/Filter/DateFilterTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function getFilterDescription(string $property, string $period): array
8181
];
8282
}
8383

84-
private function normalizeValue($value, string $operator): ?string
84+
private function normalizeValue(mixed $value, string $operator): ?string
8585
{
8686
if (false === \is_string($value)) {
8787
$this->getLogger()->notice('Invalid filter ignored', [

src/Doctrine/Common/Filter/ExistsFilterTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ abstract protected function getLogger(): LoggerInterface;
7070

7171
abstract protected function normalizePropertyName(string $property): string;
7272

73-
private function normalizeValue($value, string $property): ?bool
73+
private function normalizeValue(mixed $value, string $property): ?bool
7474
{
7575
if (\in_array($value, [true, 'true', '1', '', null], true)) {
7676
return true;

src/Doctrine/Common/Filter/NumericFilterTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function isNumericField(string $property, string $resourceClass): bool
7979
return isset(self::DOCTRINE_NUMERIC_TYPES[(string) $this->getDoctrineFieldType($property, $resourceClass)]);
8080
}
8181

82-
protected function normalizeValues($value, string $property): ?array
82+
protected function normalizeValues(mixed $value, string $property): ?array
8383
{
8484
if (!is_numeric($value) && (!\is_array($value) || !$this->isNumericArray($value))) {
8585
$this->getLogger()->notice('Invalid filter ignored', [

src/Doctrine/Common/Filter/OrderFilterTrait.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace ApiPlatform\Doctrine\Common\Filter;
1515

1616
use ApiPlatform\Doctrine\Common\PropertyHelperTrait;
17+
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
1718

1819
/**
1920
* Trait for ordering the collection by given properties.
@@ -70,13 +71,21 @@ abstract protected function getProperties(): ?array;
7071

7172
abstract protected function normalizePropertyName(string $property): string;
7273

73-
private function normalizeValue($value, string $property): ?string
74+
private function normalizeValue(mixed $value, string $property): ?string
7475
{
7576
if (empty($value) && null !== $defaultDirection = $this->getProperties()[$property]['default_direction'] ?? null) {
7677
// fallback to default direction
7778
$value = $defaultDirection;
7879
}
7980

81+
if (!\is_string($value)) {
82+
$this->getLogger()->notice('Invalid filter ignored', [
83+
'exception' => new InvalidArgumentException(\sprintf('Invalid string value for "%s" property', $property)),
84+
]);
85+
86+
return null;
87+
}
88+
8089
$value = strtoupper($value);
8190
if (!\in_array($value, [self::DIRECTION_ASC, self::DIRECTION_DESC], true)) {
8291
return null;

src/Doctrine/Common/State/PersistProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
110110
/**
111111
* Checks if doctrine does not manage data automatically.
112112
*/
113-
private function isDeferredExplicit(DoctrineObjectManager $manager, $data): bool
113+
private function isDeferredExplicit(DoctrineObjectManager $manager, object $data): bool
114114
{
115115
$classMetadata = $manager->getClassMetadata($this->getObjectClass($data));
116116
if ($classMetadata && method_exists($classMetadata, 'isChangeTrackingDeferredExplicit')) { // @phpstan-ignore-line metadata can be null

src/Doctrine/Common/State/RemoveProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
4040
/**
4141
* Gets the Doctrine object manager associated with given data.
4242
*/
43-
private function getManager($data): ?DoctrineObjectManager
43+
private function getManager(mixed $data): ?DoctrineObjectManager
4444
{
4545
return \is_object($data) ? $this->managerRegistry->getManagerForClass($this->getObjectClass($data)) : null;
4646
}

src/Doctrine/Odm/Filter/AbstractFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function apply(Builder $aggregationBuilder, string $resourceClass, ?Opera
6060
/**
6161
* Passes a property through the filter.
6262
*/
63-
abstract protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void;
63+
abstract protected function filterProperty(string $property, mixed $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void;
6464

6565
public function hasManagerRegistry(): bool
6666
{

0 commit comments

Comments
 (0)