Skip to content

Commit 2bc74aa

Browse files
chore: fix CS nullable_type_declaration_for_default_null_value in src/
1 parent bbd0cb4 commit 2bc74aa

File tree

241 files changed

+1180
-1180
lines changed

Some content is hidden

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

241 files changed

+1180
-1180
lines changed

.php-cs-fixer.dist.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@
8989
'no_unset_on_property' => true,
9090
'no_useless_else' => true,
9191
'no_useless_return' => true,
92-
'nullable_type_declaration_for_default_null_value' => [
93-
// enabled by default on v3.49.0 in SymfonySet
94-
// https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/7773
95-
'use_nullable_type_declaration' => false, // temporary
96-
],
92+
// 'nullable_type_declaration_for_default_null_value' => [
93+
// // enabled by default on v3.49.0 in SymfonySet
94+
// // https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/7773
95+
// 'use_nullable_type_declaration' => false, // temporary
96+
// ],
9797
'ordered_imports' => [
9898
'imports_order' => [
9999
'class',

src/Action/EntrypointAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(
4141
/**
4242
* @return Entrypoint|Response
4343
*/
44-
public function __invoke(Request $request = null)
44+
public function __invoke(?Request $request = null)
4545
{
4646
if ($this->provider && $this->processor) {
4747
$context = ['request' => $request];

src/Action/ExceptionAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class ExceptionAction
4343
* @param array $errorFormats A list of enabled error formats
4444
* @param array $exceptionToStatus A list of exceptions mapped to their HTTP status code
4545
*/
46-
public function __construct(private readonly SerializerInterface $serializer, private readonly array $errorFormats, private readonly array $exceptionToStatus = [], ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory = null)
46+
public function __construct(private readonly SerializerInterface $serializer, private readonly array $errorFormats, private readonly array $exceptionToStatus = [], ?ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory = null)
4747
{
4848
$this->resourceMetadataCollectionFactory = $resourceMetadataCollectionFactory;
4949
}

src/Api/IdentifiersExtractor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ final class IdentifiersExtractor implements IdentifiersExtractorInterface
3737
use ResourceClassInfoTrait;
3838
private readonly PropertyAccessorInterface $propertyAccessor;
3939

40-
public function __construct(ResourceMetadataCollectionFactoryInterface $resourceMetadataFactory, ResourceClassResolverInterface $resourceClassResolver, private readonly PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, private readonly PropertyMetadataFactoryInterface $propertyMetadataFactory, PropertyAccessorInterface $propertyAccessor = null)
40+
public function __construct(ResourceMetadataCollectionFactoryInterface $resourceMetadataFactory, ResourceClassResolverInterface $resourceClassResolver, private readonly PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, private readonly PropertyMetadataFactoryInterface $propertyMetadataFactory, ?PropertyAccessorInterface $propertyAccessor = null)
4141
{
4242
$this->resourceMetadataFactory = $resourceMetadataFactory;
4343
$this->resourceClassResolver = $resourceClassResolver;
@@ -49,7 +49,7 @@ public function __construct(ResourceMetadataCollectionFactoryInterface $resource
4949
*
5050
* TODO: 3.0 identifiers should be stringable?
5151
*/
52-
public function getIdentifiersFromItem(object $item, Operation $operation = null, array $context = []): array
52+
public function getIdentifiersFromItem(object $item, ?Operation $operation = null, array $context = []): array
5353
{
5454
if (!$this->isResourceClass($this->getObjectClass($item))) {
5555
return ['id' => $this->propertyAccessor->getValue($item, 'id')];
@@ -96,7 +96,7 @@ private function getIdentifiersFromOperation(object $item, Operation $operation,
9696
/**
9797
* Gets the value of the given class property.
9898
*/
99-
private function getIdentifierValue(object $item, string $class, string $property, string $parameterName, string $toProperty = null): float|bool|int|string
99+
private function getIdentifierValue(object $item, string $class, string $property, string $parameterName, ?string $toProperty = null): float|bool|int|string
100100
{
101101
if ($item instanceof $class) {
102102
try {

src/Api/IdentifiersExtractorInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ interface IdentifiersExtractorInterface
2828
*
2929
* @throws RuntimeException
3030
*/
31-
public function getIdentifiersFromItem(object $item, Operation $operation = null, array $context = []): array;
31+
public function getIdentifiersFromItem(object $item, ?Operation $operation = null, array $context = []): array;
3232
}

src/Api/IriConverterInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ interface IriConverterInterface
3131
* @throws InvalidArgumentException
3232
* @throws ItemNotFoundException
3333
*/
34-
public function getResourceFromIri(string $iri, array $context = [], Operation $operation = null): object;
34+
public function getResourceFromIri(string $iri, array $context = [], ?Operation $operation = null): object;
3535

3636
/**
3737
* Gets the IRI associated with the given item.
@@ -41,5 +41,5 @@ public function getResourceFromIri(string $iri, array $context = [], Operation $
4141
* @throws InvalidArgumentException
4242
* @throws RuntimeException
4343
*/
44-
public function getIriFromResource(object|string $resource, int $referenceType = UrlGeneratorInterface::ABS_PATH, Operation $operation = null, array $context = []): ?string;
44+
public function getIriFromResource(object|string $resource, int $referenceType = UrlGeneratorInterface::ABS_PATH, ?Operation $operation = null, array $context = []): ?string;
4545
}

src/Api/ResourceClassResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(private readonly ResourceNameCollectionFactoryInterf
3838
/**
3939
* {@inheritdoc}
4040
*/
41-
public function getResourceClass(mixed $value, string $resourceClass = null, bool $strict = false): string
41+
public function getResourceClass(mixed $value, ?string $resourceClass = null, bool $strict = false): string
4242
{
4343
if ($strict && null === $resourceClass) {
4444
throw new InvalidArgumentException('Strict checking is only possible when resource class is specified.');

src/Api/ResourceClassResolverInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface ResourceClassResolverInterface
3030
*
3131
* @throws InvalidArgumentException
3232
*/
33-
public function getResourceClass(mixed $value, string $resourceClass = null, bool $strict = false): string;
33+
public function getResourceClass(mixed $value, ?string $resourceClass = null, bool $strict = false): string;
3434

3535
/**
3636
* Is the given class a resource class?

src/Doctrine/Common/Filter/NumericFilterTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getDescription(string $resourceClass): array
6363
/**
6464
* Gets the PHP type corresponding to this Doctrine type.
6565
*/
66-
abstract protected function getType(string $doctrineType = null): string;
66+
abstract protected function getType(?string $doctrineType = null): string;
6767

6868
abstract protected function getProperties(): ?array;
6969

src/Doctrine/Common/Filter/SearchFilterTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ protected function normalizeValues(array $values, string $property): ?array
165165
/**
166166
* When the field should be an integer, check that the given value is a valid one.
167167
*/
168-
protected function hasValidValues(array $values, string $type = null): bool
168+
protected function hasValidValues(array $values, ?string $type = null): bool
169169
{
170170
foreach ($values as $value) {
171171
if (null !== $value && \in_array($type, (array) self::DOCTRINE_INTEGER_TYPE, true) && false === filter_var($value, \FILTER_VALIDATE_INT)) {

src/Doctrine/Common/State/LinksHandlerTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private function getLinks(string $resourceClass, Operation $operation, array $co
9292
/**
9393
* @param array<int|string,mixed> $identifiers
9494
*/
95-
private function getIdentifierValue(array &$identifiers, string $name = null): mixed
95+
private function getIdentifierValue(array &$identifiers, ?string $name = null): mixed
9696
{
9797
if (null !== $name && isset($identifiers[$name])) {
9898
$value = $identifiers[$name];
@@ -107,7 +107,7 @@ private function getIdentifierValue(array &$identifiers, string $name = null): m
107107
/**
108108
* @return \ApiPlatform\Metadata\Link[]|array
109109
*/
110-
private function getOperationLinks(Operation $operation = null): array
110+
private function getOperationLinks(?Operation $operation = null): array
111111
{
112112
if ($operation instanceof GraphQlOperation) {
113113
return $operation->getLinks() ?? [];

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ public function getFoo(): ?array
194194
return $this->foo;
195195
}
196196

197-
public function setFoo(array $foo = null): void
197+
public function setFoo(?array $foo = null): void
198198
{
199199
$this->foo = $foo;
200200
}
201201

202-
public function setDummyDate(\DateTime $dummyDate = null): void
202+
public function setDummyDate(?\DateTime $dummyDate = null): void
203203
{
204204
$this->dummyDate = $dummyDate;
205205
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function getThirdLevel(): ?ThirdLevel
161161
return $this->thirdLevel;
162162
}
163163

164-
public function setThirdLevel(ThirdLevel $thirdLevel = null): void
164+
public function setThirdLevel(?ThirdLevel $thirdLevel = null): void
165165
{
166166
$this->thirdLevel = $thirdLevel;
167167
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function getFourthLevel(): ?FourthLevel
8787
return $this->fourthLevel;
8888
}
8989

90-
public function setFourthLevel(FourthLevel $fourthLevel = null): void
90+
public function setFourthLevel(?FourthLevel $fourthLevel = null): void
9191
{
9292
$this->fourthLevel = $fourthLevel;
9393
}

src/Doctrine/EventListener/PublishMercureUpdatesListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ final class PublishMercureUpdatesListener
6666
/**
6767
* @param array<string, string[]|string> $formats
6868
*/
69-
public function __construct(LegacyResourceClassResolverInterface|ResourceClassResolverInterface $resourceClassResolver, private readonly LegacyIriConverterInterface|IriConverterInterface $iriConverter, ResourceMetadataCollectionFactoryInterface $resourceMetadataFactory, private readonly SerializerInterface $serializer, private readonly array $formats, MessageBusInterface $messageBus = null, private readonly ?HubRegistry $hubRegistry = null, private readonly ?GraphQlSubscriptionManagerInterface $graphQlSubscriptionManager = null, private readonly ?GraphQlMercureSubscriptionIriGeneratorInterface $graphQlMercureSubscriptionIriGenerator = null, ExpressionLanguage $expressionLanguage = null, private bool $includeType = false)
69+
public function __construct(LegacyResourceClassResolverInterface|ResourceClassResolverInterface $resourceClassResolver, private readonly LegacyIriConverterInterface|IriConverterInterface $iriConverter, ResourceMetadataCollectionFactoryInterface $resourceMetadataFactory, private readonly SerializerInterface $serializer, private readonly array $formats, ?MessageBusInterface $messageBus = null, private readonly ?HubRegistry $hubRegistry = null, private readonly ?GraphQlSubscriptionManagerInterface $graphQlSubscriptionManager = null, private readonly ?GraphQlMercureSubscriptionIriGeneratorInterface $graphQlMercureSubscriptionIriGenerator = null, ?ExpressionLanguage $expressionLanguage = null, private bool $includeType = false)
7070
{
7171
if (null === $messageBus && null === $hubRegistry) {
7272
throw new InvalidArgumentException('A message bus or a hub registry must be provided.');

src/Doctrine/EventListener/PurgeHttpCacheListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class PurgeHttpCacheListener
4343
private readonly PropertyAccessorInterface $propertyAccessor;
4444
private array $tags = [];
4545

46-
public function __construct(private readonly PurgerInterface $purger, private readonly IriConverterInterface|LegacyIriConverterInterface $iriConverter, private readonly ResourceClassResolverInterface|LegacyResourceClassResolverInterface $resourceClassResolver, PropertyAccessorInterface $propertyAccessor = null)
46+
public function __construct(private readonly PurgerInterface $purger, private readonly IriConverterInterface|LegacyIriConverterInterface $iriConverter, private readonly ResourceClassResolverInterface|LegacyResourceClassResolverInterface $resourceClassResolver, ?PropertyAccessorInterface $propertyAccessor = null)
4747
{
4848
$this->propertyAccessor = $propertyAccessor ?? PropertyAccess::createPropertyAccessor();
4949
}

src/Doctrine/Odm/Extension/AggregationCollectionExtensionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
*/
2424
interface AggregationCollectionExtensionInterface
2525
{
26-
public function applyToCollection(Builder $aggregationBuilder, string $resourceClass, Operation $operation = null, array &$context = []): void;
26+
public function applyToCollection(Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void;
2727
}

src/Doctrine/Odm/Extension/AggregationItemExtensionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
*/
2424
interface AggregationItemExtensionInterface
2525
{
26-
public function applyToItem(Builder $aggregationBuilder, string $resourceClass, array $identifiers, Operation $operation = null, array &$context = []): void;
26+
public function applyToItem(Builder $aggregationBuilder, string $resourceClass, array $identifiers, ?Operation $operation = null, array &$context = []): void;
2727
}

src/Doctrine/Odm/Extension/AggregationResultCollectionExtensionInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
interface AggregationResultCollectionExtensionInterface extends AggregationCollectionExtensionInterface
2626
{
27-
public function supportsResult(string $resourceClass, Operation $operation = null, array $context = []): bool;
27+
public function supportsResult(string $resourceClass, ?Operation $operation = null, array $context = []): bool;
2828

29-
public function getResult(Builder $aggregationBuilder, string $resourceClass, Operation $operation = null, array $context = []): iterable;
29+
public function getResult(Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array $context = []): iterable;
3030
}

src/Doctrine/Odm/Extension/AggregationResultItemExtensionInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
interface AggregationResultItemExtensionInterface extends AggregationItemExtensionInterface
2626
{
27-
public function supportsResult(string $resourceClass, Operation $operation = null, array $context = []): bool;
27+
public function supportsResult(string $resourceClass, ?Operation $operation = null, array $context = []): bool;
2828

29-
public function getResult(Builder $aggregationBuilder, string $resourceClass, Operation $operation = null, array $context = []): ?object;
29+
public function getResult(Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array $context = []): ?object;
3030
}

src/Doctrine/Odm/Extension/FilterExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(private readonly ContainerInterface $filterLocator)
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function applyToCollection(Builder $aggregationBuilder, string $resourceClass, Operation $operation = null, array &$context = []): void
36+
public function applyToCollection(Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
3737
{
3838
$resourceFilters = $operation?->getFilters();
3939

src/Doctrine/Odm/Extension/OrderExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(private readonly ?string $order = null, private read
4040
/**
4141
* {@inheritdoc}
4242
*/
43-
public function applyToCollection(Builder $aggregationBuilder, string $resourceClass, Operation $operation = null, array &$context = []): void
43+
public function applyToCollection(Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
4444
{
4545
// Do not apply order if already defined on $aggregationBuilder
4646
if ($this->hasSortStage($aggregationBuilder)) {

src/Doctrine/Odm/Extension/PaginationExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(private readonly ManagerRegistry $managerRegistry, p
4040
*
4141
* @throws RuntimeException
4242
*/
43-
public function applyToCollection(Builder $aggregationBuilder, string $resourceClass, Operation $operation = null, array &$context = []): void
43+
public function applyToCollection(Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
4444
{
4545
if (!$this->pagination->isEnabled($operation, $context)) {
4646
return;
@@ -85,7 +85,7 @@ public function applyToCollection(Builder $aggregationBuilder, string $resourceC
8585
/**
8686
* {@inheritdoc}
8787
*/
88-
public function supportsResult(string $resourceClass, Operation $operation = null, array $context = []): bool
88+
public function supportsResult(string $resourceClass, ?Operation $operation = null, array $context = []): bool
8989
{
9090
if ($context['graphql_operation_name'] ?? false) {
9191
return $this->pagination->isGraphQlEnabled($operation, $context);
@@ -99,7 +99,7 @@ public function supportsResult(string $resourceClass, Operation $operation = nul
9999
*
100100
* @throws RuntimeException
101101
*/
102-
public function getResult(Builder $aggregationBuilder, string $resourceClass, Operation $operation = null, array $context = []): iterable
102+
public function getResult(Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array $context = []): iterable
103103
{
104104
$manager = $this->managerRegistry->getManagerForClass($resourceClass);
105105
if (!$manager instanceof DocumentManager) {

src/Doctrine/Odm/Filter/AbstractFilter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ abstract class AbstractFilter implements FilterInterface
3535
use PropertyHelperTrait;
3636
protected LoggerInterface $logger;
3737

38-
public function __construct(protected ManagerRegistry $managerRegistry, LoggerInterface $logger = null, protected ?array $properties = null, protected ?NameConverterInterface $nameConverter = null)
38+
public function __construct(protected ManagerRegistry $managerRegistry, ?LoggerInterface $logger = null, protected ?array $properties = null, protected ?NameConverterInterface $nameConverter = null)
3939
{
4040
$this->logger = $logger ?? new NullLogger();
4141
}
4242

4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public function apply(Builder $aggregationBuilder, string $resourceClass, Operation $operation = null, array &$context = []): void
46+
public function apply(Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
4747
{
4848
foreach ($context['filters'] as $property => $value) {
4949
$this->filterProperty($this->denormalizePropertyName($property), $value, $aggregationBuilder, $resourceClass, $operation, $context);
@@ -53,7 +53,7 @@ public function apply(Builder $aggregationBuilder, string $resourceClass, Operat
5353
/**
5454
* Passes a property through the filter.
5555
*/
56-
abstract protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, Operation $operation = null, array &$context = []): void;
56+
abstract protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void;
5757

5858
protected function getManagerRegistry(): ManagerRegistry
5959
{

src/Doctrine/Odm/Filter/BooleanFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ final class BooleanFilter extends AbstractFilter
116116
/**
117117
* {@inheritdoc}
118118
*/
119-
protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, Operation $operation = null, array &$context = []): void
119+
protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
120120
{
121121
if (
122122
!$this->isPropertyEnabled($property, $resourceClass)

src/Doctrine/Odm/Filter/DateFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ final class DateFilter extends AbstractFilter implements DateFilterInterface
129129
/**
130130
* {@inheritdoc}
131131
*/
132-
protected function filterProperty(string $property, $values, Builder $aggregationBuilder, string $resourceClass, Operation $operation = null, array &$context = []): void
132+
protected function filterProperty(string $property, $values, Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
133133
{
134134
// Expect $values to be an array having the period as keys and the date value as values
135135
if (
@@ -197,7 +197,7 @@ protected function filterProperty(string $property, $values, Builder $aggregatio
197197
/**
198198
* Adds the match stage according to the chosen null management.
199199
*/
200-
private function addMatch(Builder $aggregationBuilder, string $field, string $operator, $value, string $nullManagement = null): void
200+
private function addMatch(Builder $aggregationBuilder, string $field, string $operator, $value, ?string $nullManagement = null): void
201201
{
202202
$value = $this->normalizeValue($value, $operator);
203203

0 commit comments

Comments
 (0)