Skip to content

Add missing param type #7313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ parameters:
- src/Symfony/Bundle/Test
- src/Symfony/Tests
- tests
- src # TODO
-
identifier: missingType.return
paths:
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Common/Filter/BackedEnumFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ abstract protected function normalizePropertyName(string $property): string;
*/
abstract protected function isBackedEnumField(string $property, string $resourceClass): bool;

private function normalizeValue($value, string $property): mixed
private function normalizeValue(mixed $value, string $property): mixed
{
$firstCase = $this->enumTypes[$property]::cases()[0] ?? null;
if (
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Common/Filter/BooleanFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function isBooleanField(string $property, string $resourceClass): bool
return isset(self::DOCTRINE_BOOLEAN_TYPES[(string) $this->getDoctrineFieldType($property, $resourceClass)]);
}

private function normalizeValue($value, string $property): ?bool
private function normalizeValue(mixed $value, string $property): ?bool
{
if (\in_array($value, [true, 'true', '1'], true)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Common/Filter/DateFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function getFilterDescription(string $property, string $period): array
];
}

private function normalizeValue($value, string $operator): ?string
private function normalizeValue(mixed $value, string $operator): ?string
{
if (false === \is_string($value)) {
$this->getLogger()->notice('Invalid filter ignored', [
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Common/Filter/ExistsFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ abstract protected function getLogger(): LoggerInterface;

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

private function normalizeValue($value, string $property): ?bool
private function normalizeValue(mixed $value, string $property): ?bool
{
if (\in_array($value, [true, 'true', '1', '', null], true)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Common/Filter/NumericFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function isNumericField(string $property, string $resourceClass): bool
return isset(self::DOCTRINE_NUMERIC_TYPES[(string) $this->getDoctrineFieldType($property, $resourceClass)]);
}

protected function normalizeValues($value, string $property): ?array
protected function normalizeValues(mixed $value, string $property): ?array
{
if (!is_numeric($value) && (!\is_array($value) || !$this->isNumericArray($value))) {
$this->getLogger()->notice('Invalid filter ignored', [
Expand Down
11 changes: 10 additions & 1 deletion src/Doctrine/Common/Filter/OrderFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace ApiPlatform\Doctrine\Common\Filter;

use ApiPlatform\Doctrine\Common\PropertyHelperTrait;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;

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

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

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

if (!\is_string($value)) {
$this->getLogger()->notice('Invalid filter ignored', [
'exception' => new InvalidArgumentException(\sprintf('Invalid string value for "%s" property', $property)),
]);

return null;
}

$value = strtoupper($value);
if (!\in_array($value, [self::DIRECTION_ASC, self::DIRECTION_DESC], true)) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Common/State/PersistProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
/**
* Checks if doctrine does not manage data automatically.
*/
private function isDeferredExplicit(DoctrineObjectManager $manager, $data): bool
private function isDeferredExplicit(DoctrineObjectManager $manager, object $data): bool
{
$classMetadata = $manager->getClassMetadata($this->getObjectClass($data));
if ($classMetadata && method_exists($classMetadata, 'isChangeTrackingDeferredExplicit')) { // @phpstan-ignore-line metadata can be null
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Common/State/RemoveProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
/**
* Gets the Doctrine object manager associated with given data.
*/
private function getManager($data): ?DoctrineObjectManager
private function getManager(mixed $data): ?DoctrineObjectManager
{
return \is_object($data) ? $this->managerRegistry->getManagerForClass($this->getObjectClass($data)) : null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/Filter/AbstractFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function apply(Builder $aggregationBuilder, string $resourceClass, ?Opera
/**
* Passes a property through the filter.
*/
abstract protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void;
abstract protected function filterProperty(string $property, mixed $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void;

public function hasManagerRegistry(): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/Filter/BooleanFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ final class BooleanFilter extends AbstractFilter implements JsonSchemaFilterInte
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
protected function filterProperty(string $property, mixed $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
{
if (
!$this->isPropertyEnabled($property, $resourceClass)
Expand Down
4 changes: 2 additions & 2 deletions src/Doctrine/Odm/Filter/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ final class DateFilter extends AbstractFilter implements DateFilterInterface, Js
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
protected function filterProperty(string $property, mixed $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
{
// Expect $value to be an array having the period as keys and the date value as values
if (
Expand Down Expand Up @@ -202,7 +202,7 @@ protected function filterProperty(string $property, $value, Builder $aggregation
/**
* Adds the match stage according to the chosen null management.
*/
private function addMatch(Builder $aggregationBuilder, string $field, string $operator, $value, ?string $nullManagement = null): void
private function addMatch(Builder $aggregationBuilder, string $field, string $operator, mixed $value, ?string $nullManagement = null): void
{
$value = $this->normalizeValue($value, $operator);

Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/Filter/ExistsFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function apply(Builder $aggregationBuilder, string $resourceClass, ?Opera
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
protected function filterProperty(string $property, mixed $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
{
if (
!$this->isPropertyEnabled($property, $resourceClass)
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/Filter/NumericFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ final class NumericFilter extends AbstractFilter implements JsonSchemaFilterInte
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
protected function filterProperty(string $property, mixed $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
{
if (
!$this->isPropertyEnabled($property, $resourceClass)
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/Filter/OrderFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function apply(Builder $aggregationBuilder, string $resourceClass, ?Opera
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
protected function filterProperty(string $property, mixed $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
{
if (!$this->isPropertyEnabled($property, $resourceClass) || !$this->isPropertyMapped($property, $resourceClass)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/Filter/RangeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ final class RangeFilter extends AbstractFilter implements RangeFilterInterface,
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $values, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
protected function filterProperty(string $property, mixed $values, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
{
if (
!\is_array($values)
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Odm/Filter/SearchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ protected function getPropertyAccessor(): PropertyAccessorInterface
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
protected function filterProperty(string $property, mixed $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
{
if (
null === $value
Expand Down
11 changes: 11 additions & 0 deletions src/Doctrine/Odm/PropertyInfo/DoctrineExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public function __construct(private readonly ObjectManager $objectManager)
/**
* {@inheritdoc}
*
* @param string $class
*
* @return string[]|null
*/
public function getProperties($class, array $context = []): ?array
Expand Down Expand Up @@ -111,6 +113,9 @@ public function getType(string $class, string $property, array $context = []): ?
*
* // deprecated since 4.2 use "getType" instead
*
* @param string $class
* @param string $property
*
* @return LegacyType[]|null
*/
public function getTypes($class, $property, array $context = []): ?array
Expand Down Expand Up @@ -183,6 +188,9 @@ public function getTypes($class, $property, array $context = []): ?array

/**
* {@inheritdoc}
*
* @param string $class
* @param string $property
*/
public function isReadable($class, $property, array $context = []): ?bool
{
Expand All @@ -191,6 +199,9 @@ public function isReadable($class, $property, array $context = []): ?bool

/**
* {@inheritdoc}
*
* @param string $class
* @param string $property
*/
public function isWritable($class, $property, array $context = []): ?bool
{
Expand Down
6 changes: 6 additions & 0 deletions src/Doctrine/Orm/Extension/DoctrinePaginatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@

namespace ApiPlatform\Doctrine\Orm\Extension;

use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\Tools\Pagination\Paginator;

class DoctrinePaginatorFactory
{
/**
* @param Query|QueryBuilder $query
* @param bool $fetchJoinCollection
*/
public function getPaginator($query, $fetchJoinCollection): Paginator
{
return new Paginator($query, $fetchJoinCollection);
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/Filter/AbstractFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $q
* @param class-string $resourceClass
* @param array<string, mixed> $context
*/
abstract protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void;
abstract protected function filterProperty(string $property, mixed $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void;

public function hasManagerRegistry(): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/Filter/BooleanFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ final class BooleanFilter extends AbstractFilter implements JsonSchemaFilterInte
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
protected function filterProperty(string $property, mixed $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
{
if (
!$this->isPropertyEnabled($property, $resourceClass)
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/Filter/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ final class DateFilter extends AbstractFilter implements DateFilterInterface, Js
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
protected function filterProperty(string $property, mixed $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
{
// Expect $value to be an array having the period as keys and the date value as values
if (
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/Filter/ExistsFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $q
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
protected function filterProperty(string $property, mixed $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
{
if (
!$this->isPropertyEnabled($property, $resourceClass)
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/Filter/NumericFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ final class NumericFilter extends AbstractFilter implements JsonSchemaFilterInte
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
protected function filterProperty(string $property, mixed $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
{
if (
!$this->isPropertyEnabled($property, $resourceClass)
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/Filter/OrderFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $q
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
protected function filterProperty(string $property, mixed $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
{
if (!$this->isPropertyEnabled($property, $resourceClass) || !$this->isPropertyMapped($property, $resourceClass)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/Filter/RangeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ final class RangeFilter extends AbstractFilter implements RangeFilterInterface,
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $values, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
protected function filterProperty(string $property, mixed $values, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
{
if (
!\is_array($values)
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Orm/Filter/SearchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected function getPropertyAccessor(): PropertyAccessorInterface
/**
* {@inheritdoc}
*/
protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
protected function filterProperty(string $property, mixed $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
{
if (
null === $value
Expand Down
3 changes: 3 additions & 0 deletions src/Elasticsearch/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public function supportsNormalization(mixed $data, ?string $format = null, array
return DocumentNormalizer::FORMAT !== $format && $this->decorated->supportsNormalization($data, $format);
}

/**
* @param string|null $format
*/
public function getSupportedTypes($format): array
{
return DocumentNormalizer::FORMAT !== $format ? $this->decorated->getSupportedTypes($format) : [];
Expand Down
3 changes: 3 additions & 0 deletions src/GraphQl/Action/GraphiQlAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
*/
final class GraphiQlAction
{
/**
* @param string|null $assetPackage
*/
public function __construct(private readonly TwigEnvironment $twig, private readonly RouterInterface $router, private readonly bool $graphiqlEnabled = false, private readonly string $title = '', private $assetPackage = null)
{
}
Expand Down
2 changes: 2 additions & 0 deletions src/GraphQl/ExecutorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ interface ExecutorInterface
{
/**
* @see http://webonyx.github.io/graphql-php/executing-queries/#using-facade-method
*
* @param mixed $source
*/
public function executeQuery(Schema $schema, $source, mixed $rootValue = null, mixed $context = null, ?array $variableValues = null, ?string $operationName = null, ?callable $fieldResolver = null, ?array $validationRules = null): ExecutionResult;
}
3 changes: 3 additions & 0 deletions src/GraphQl/Resolver/ResourceFieldResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public function __construct(private readonly IriConverterInterface $iriConverter
{
}

/**
* @param array $context
*/
public function __invoke(?array $source, array $args, $context, ResolveInfo $info): mixed
{
$property = null;
Expand Down
3 changes: 3 additions & 0 deletions src/GraphQl/Serializer/Exception/ErrorNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public function supportsNormalization(mixed $data, ?string $format = null, array
return $data instanceof Error;
}

/**
* @param string|null $format
*/
public function getSupportedTypes($format): array
{
return [
Expand Down
3 changes: 3 additions & 0 deletions src/GraphQl/Serializer/Exception/HttpExceptionNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public function supportsNormalization(mixed $data, ?string $format = null, array
return $data instanceof Error && $data->getPrevious() instanceof HttpExceptionInterface;
}

/**
* @param string|null $format
*/
public function getSupportedTypes($format): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function supportsNormalization(mixed $data, ?string $format = null, array
return $data instanceof Error && $data->getPrevious() instanceof \RuntimeException;
}

/**
* @param string|null $format
*/
public function getSupportedTypes($format): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public function supportsNormalization(mixed $data, ?string $format = null, array
return $data instanceof Error && ($data->getPrevious() instanceof ConstraintViolationListAwareExceptionInterface);
}

/**
* @param string|null $format
*/
public function getSupportedTypes($format): array
{
return [
Expand Down
Loading
Loading