Skip to content

Commit

Permalink
Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_…
Browse files Browse the repository at this point in the history
…null_value
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
1 parent 211e349 commit 9b17d85
Show file tree
Hide file tree
Showing 31 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Command/ConsumeMessagesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ConsumeMessagesCommand extends Command
private $resetServicesListener;
private $busIds;

public function __construct(RoutableMessageBus $routableBus, ContainerInterface $receiverLocator, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger = null, array $receiverNames = [], ResetServicesListener $resetServicesListener = null, array $busIds = [])
public function __construct(RoutableMessageBus $routableBus, ContainerInterface $receiverLocator, EventDispatcherInterface $eventDispatcher, ?LoggerInterface $logger = null, array $receiverNames = [], ?ResetServicesListener $resetServicesListener = null, array $busIds = [])
{
$this->routableBus = $routableBus;
$this->receiverLocator = $receiverLocator;
Expand Down
2 changes: 1 addition & 1 deletion Command/FailedMessagesRetryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class FailedMessagesRetryCommand extends AbstractFailedMessagesCommand
private $messageBus;
private $logger;

public function __construct(?string $globalReceiverName, $failureTransports, MessageBusInterface $messageBus, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger = null)
public function __construct(?string $globalReceiverName, $failureTransports, MessageBusInterface $messageBus, EventDispatcherInterface $eventDispatcher, ?LoggerInterface $logger = null)
{
$this->eventDispatcher = $eventDispatcher;
$this->messageBus = $messageBus;
Expand Down
6 changes: 3 additions & 3 deletions DataCollector/MessengerDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function registerBus(string $name, TraceableMessageBus $bus)
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Throwable $exception = null)
public function collect(Request $request, Response $response, ?\Throwable $exception = null)
{
// Noop. Everything is collected live by the traceable buses & cloned as late as possible.
}
Expand Down Expand Up @@ -121,7 +121,7 @@ private function collectMessage(string $busName, array $tracedMessage)
return $debugRepresentation;
}

public function getExceptionsCount(string $bus = null): int
public function getExceptionsCount(?string $bus = null): int
{
$count = 0;
foreach ($this->getMessages($bus) as $message) {
Expand All @@ -131,7 +131,7 @@ public function getExceptionsCount(string $bus = null): int
return $count;
}

public function getMessages(string $bus = null): array
public function getMessages(?string $bus = null): array
{
if (null === $bus) {
return $this->data['messages'];
Expand Down
2 changes: 1 addition & 1 deletion Envelope.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function last(string $stampFqcn): ?StampInterface
/**
* @return StampInterface[]|StampInterface[][] The stamps for the specified FQCN, or all stamps by their class name
*/
public function all(string $stampFqcn = null): array
public function all(?string $stampFqcn = null): array
{
if (null !== $stampFqcn) {
return $this->stamps[$this->resolveAlias($stampFqcn)] ?? [];
Expand Down
2 changes: 1 addition & 1 deletion Event/WorkerMessageReceivedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class WorkerMessageReceivedEvent extends AbstractWorkerMessageEvent
{
private $shouldHandle = true;

public function shouldHandle(bool $shouldHandle = null): bool
public function shouldHandle(?bool $shouldHandle = null): bool
{
if (null !== $shouldHandle) {
$this->shouldHandle = $shouldHandle;
Expand Down
2 changes: 1 addition & 1 deletion EventListener/SendFailedMessageForRetryListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SendFailedMessageForRetryListener implements EventSubscriberInterface
private $eventDispatcher;
private $historySize;

public function __construct(ContainerInterface $sendersLocator, ContainerInterface $retryStrategyLocator, LoggerInterface $logger = null, EventDispatcherInterface $eventDispatcher = null, int $historySize = 10)
public function __construct(ContainerInterface $sendersLocator, ContainerInterface $retryStrategyLocator, ?LoggerInterface $logger = null, ?EventDispatcherInterface $eventDispatcher = null, int $historySize = 10)
{
$this->sendersLocator = $sendersLocator;
$this->retryStrategyLocator = $retryStrategyLocator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SendFailedMessageToFailureTransportListener implements EventSubscriberInte
/**
* @param ContainerInterface $failureSenders
*/
public function __construct($failureSenders, LoggerInterface $logger = null)
public function __construct($failureSenders, ?LoggerInterface $logger = null)
{
if (!$failureSenders instanceof ContainerInterface) {
trigger_deprecation('symfony/messenger', '5.3', 'Passing a SenderInterface value as 1st argument to "%s()" is deprecated, pass a ServiceLocator instead.', __METHOD__);
Expand Down
2 changes: 1 addition & 1 deletion EventListener/StopWorkerOnFailureLimitListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class StopWorkerOnFailureLimitListener implements EventSubscriberInterface
private $logger;
private $failedMessages = 0;

public function __construct(int $maximumNumberOfFailures, LoggerInterface $logger = null)
public function __construct(int $maximumNumberOfFailures, ?LoggerInterface $logger = null)
{
$this->maximumNumberOfFailures = $maximumNumberOfFailures;
$this->logger = $logger;
Expand Down
2 changes: 1 addition & 1 deletion EventListener/StopWorkerOnMemoryLimitListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class StopWorkerOnMemoryLimitListener implements EventSubscriberInterface
private $logger;
private $memoryResolver;

public function __construct(int $memoryLimit, LoggerInterface $logger = null, callable $memoryResolver = null)
public function __construct(int $memoryLimit, ?LoggerInterface $logger = null, ?callable $memoryResolver = null)
{
$this->memoryLimit = $memoryLimit;
$this->logger = $logger;
Expand Down
2 changes: 1 addition & 1 deletion EventListener/StopWorkerOnMessageLimitListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class StopWorkerOnMessageLimitListener implements EventSubscriberInterface
private $logger;
private $receivedMessages = 0;

public function __construct(int $maximumNumberOfMessages, LoggerInterface $logger = null)
public function __construct(int $maximumNumberOfMessages, ?LoggerInterface $logger = null)
{
$this->maximumNumberOfMessages = $maximumNumberOfMessages;
$this->logger = $logger;
Expand Down
2 changes: 1 addition & 1 deletion EventListener/StopWorkerOnRestartSignalListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class StopWorkerOnRestartSignalListener implements EventSubscriberInterface
private $logger;
private $workerStartedAt;

public function __construct(CacheItemPoolInterface $cachePool, LoggerInterface $logger = null)
public function __construct(CacheItemPoolInterface $cachePool, ?LoggerInterface $logger = null)
{
$this->cachePool = $cachePool;
$this->logger = $logger;
Expand Down
2 changes: 1 addition & 1 deletion EventListener/StopWorkerOnSigtermSignalListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class StopWorkerOnSigtermSignalListener implements EventSubscriberInterface
{
private $logger;

public function __construct(LoggerInterface $logger = null)
public function __construct(?LoggerInterface $logger = null)
{
$this->logger = $logger;
}
Expand Down
2 changes: 1 addition & 1 deletion EventListener/StopWorkerOnTimeLimitListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class StopWorkerOnTimeLimitListener implements EventSubscriberInterface
private $logger;
private $endTime;

public function __construct(int $timeLimitInSeconds, LoggerInterface $logger = null)
public function __construct(int $timeLimitInSeconds, ?LoggerInterface $logger = null)
{
$this->timeLimitInSeconds = $timeLimitInSeconds;
$this->logger = $logger;
Expand Down
2 changes: 1 addition & 1 deletion Exception/StopWorkerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
class StopWorkerException extends RuntimeException implements StopWorkerExceptionInterface
{
public function __construct(string $message = 'Worker should stop.', \Throwable $previous = null)
public function __construct(string $message = 'Worker should stop.', ?\Throwable $previous = null)
{
parent::__construct($message, 0, $previous);
}
Expand Down
4 changes: 2 additions & 2 deletions Handler/Acknowledger.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Acknowledger
/**
* @param \Closure(\Throwable|null, mixed):void|null $ack
*/
public function __construct(string $handlerClass, \Closure $ack = null)
public function __construct(string $handlerClass, ?\Closure $ack = null)
{
$this->handlerClass = $handlerClass;
$this->ack = $ack ?? static function () {};
Expand Down Expand Up @@ -70,7 +70,7 @@ public function __destruct()
}
}

private function doAck(\Throwable $e = null, $result = null): void
private function doAck(?\Throwable $e = null, $result = null): void
{
if (!$ack = $this->ack) {
throw new LogicException(sprintf('The acknowledger cannot be called twice by the "%s" batch handler.', $this->handlerClass));
Expand Down
2 changes: 1 addition & 1 deletion Middleware/HandleMessageMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope

/** @var AckStamp $ackStamp */
if ($batchHandler && $ackStamp = $envelope->last(AckStamp::class)) {
$ack = new Acknowledger(get_debug_type($batchHandler), static function (\Throwable $e = null, $result = null) use ($envelope, $ackStamp, $handlerDescriptor) {
$ack = new Acknowledger(get_debug_type($batchHandler), static function (?\Throwable $e = null, $result = null) use ($envelope, $ackStamp, $handlerDescriptor) {
if (null !== $e) {
$e = new HandlerFailedException($envelope, [$e]);
} else {
Expand Down
2 changes: 1 addition & 1 deletion Middleware/SendMessageMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SendMessageMiddleware implements MiddlewareInterface
private $sendersLocator;
private $eventDispatcher;

public function __construct(SendersLocatorInterface $sendersLocator, EventDispatcherInterface $eventDispatcher = null)
public function __construct(SendersLocatorInterface $sendersLocator, ?EventDispatcherInterface $eventDispatcher = null)
{
$this->sendersLocator = $sendersLocator;
$this->eventDispatcher = class_exists(Event::class) ? LegacyEventDispatcherProxy::decorate($eventDispatcher) : $eventDispatcher;
Expand Down
4 changes: 2 additions & 2 deletions Retry/MultiplierRetryStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct(int $maxRetries = 3, int $delayMilliseconds = 1000,
/**
* @param \Throwable|null $throwable The cause of the failed handling
*/
public function isRetryable(Envelope $message, \Throwable $throwable = null): bool
public function isRetryable(Envelope $message, ?\Throwable $throwable = null): bool
{
$retries = RedeliveryStamp::getRetryCountFromEnvelope($message);

Expand All @@ -76,7 +76,7 @@ public function isRetryable(Envelope $message, \Throwable $throwable = null): bo
/**
* @param \Throwable|null $throwable The cause of the failed handling
*/
public function getWaitingTime(Envelope $message, \Throwable $throwable = null): int
public function getWaitingTime(Envelope $message, ?\Throwable $throwable = null): int
{
$retries = RedeliveryStamp::getRetryCountFromEnvelope($message);

Expand Down
2 changes: 1 addition & 1 deletion RoutableMessageBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RoutableMessageBus implements MessageBusInterface
private $busLocator;
private $fallbackBus;

public function __construct(ContainerInterface $busLocator, MessageBusInterface $fallbackBus = null)
public function __construct(ContainerInterface $busLocator, ?MessageBusInterface $fallbackBus = null)
{
$this->busLocator = $busLocator;
$this->fallbackBus = $fallbackBus;
Expand Down
2 changes: 1 addition & 1 deletion Stamp/AckStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(\Closure $ack)
$this->ack = $ack;
}

public function ack(Envelope $envelope, \Throwable $e = null): void
public function ack(Envelope $envelope, ?\Throwable $e = null): void
{
($this->ack)($envelope, $e);
}
Expand Down
2 changes: 1 addition & 1 deletion Stamp/ErrorDetailsStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class ErrorDetailsStamp implements StampInterface
/**
* @param int|string $exceptionCode
*/
public function __construct(string $exceptionClass, $exceptionCode, string $exceptionMessage, FlattenException $flattenException = null)
public function __construct(string $exceptionClass, $exceptionCode, string $exceptionMessage, ?FlattenException $flattenException = null)
{
$this->exceptionClass = $exceptionClass;
$this->exceptionCode = $exceptionCode;
Expand Down
2 changes: 1 addition & 1 deletion Stamp/SentStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class SentStamp implements NonSendableStampInterface
private $senderClass;
private $senderAlias;

public function __construct(string $senderClass, string $senderAlias = null)
public function __construct(string $senderClass, ?string $senderAlias = null)
{
$this->senderAlias = $senderAlias;
$this->senderClass = $senderClass;
Expand Down
2 changes: 1 addition & 1 deletion Test/Middleware/MiddlewareTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function getStackMock(bool $nextIsCalled = true)
return new StackMiddleware($nextMiddleware);
}

protected function getThrowingStackMock(\Throwable $throwable = null)
protected function getThrowingStackMock(?\Throwable $throwable = null)
{
$nextMiddleware = $this->createMock(MiddlewareInterface::class);
$nextMiddleware
Expand Down
10 changes: 5 additions & 5 deletions Tests/Middleware/HandleMessageMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function testBatchHandler()

use BatchHandlerTrait;

public function __invoke(DummyMessage $message, Acknowledger $ack = null)
public function __invoke(DummyMessage $message, ?Acknowledger $ack = null)
{
return $this->handle($message, $ack);
}
Expand All @@ -198,7 +198,7 @@ private function process(array $jobs): void
]));

$ackedMessages = [];
$ack = static function (Envelope $envelope, \Throwable $e = null) use (&$ackedMessages) {
$ack = static function (Envelope $envelope, ?\Throwable $e = null) use (&$ackedMessages) {
if (null !== $e) {
throw $e;
}
Expand Down Expand Up @@ -227,7 +227,7 @@ public function testBatchHandlerNoAck()
$handler = new class() implements BatchHandlerInterface {
use BatchHandlerTrait;

public function __invoke(DummyMessage $message, Acknowledger $ack = null)
public function __invoke(DummyMessage $message, ?Acknowledger $ack = null)
{
return $this->handle($message, $ack);
}
Expand All @@ -247,7 +247,7 @@ private function process(array $jobs): void
]));

$error = null;
$ack = static function (Envelope $envelope, \Throwable $e = null) use (&$error) {
$ack = static function (Envelope $envelope, ?\Throwable $e = null) use (&$error) {
$error = $e;
};

Expand All @@ -264,7 +264,7 @@ public function testBatchHandlerNoBatch()

use BatchHandlerTrait;

public function __invoke(DummyMessage $message, Acknowledger $ack = null)
public function __invoke(DummyMessage $message, ?Acknowledger $ack = null)
{
return $this->handle($message, $ack);
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Middleware/TraceableMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope

$stopwatch->expects($this->exactly(2))
->method('start')
->willReturnCallback(function (string $name, string $category = null) use (&$series) {
->willReturnCallback(function (string $name, ?string $category = null) use (&$series) {
[$constraint, $expectedCategory] = array_shift($series);

$constraint->evaluate($name);
Expand Down Expand Up @@ -195,7 +195,7 @@ class_exists(TraceableMiddleware::class);
];
$stopwatch->expects($this->exactly(4))
->method('start')
->willReturnCallback(function (string $name, string $category = null) use (&$startSeries) {
->willReturnCallback(function (string $name, ?string $category = null) use (&$startSeries) {
[$constraint, $expectedCategory] = array_shift($startSeries);

$constraint->evaluate($name);
Expand Down
2 changes: 1 addition & 1 deletion Tests/WorkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ class DummyBatchHandler implements BatchHandlerInterface

public $processedMessages;

public function __invoke(DummyMessage $message, Acknowledger $ack = null)
public function __invoke(DummyMessage $message, ?Acknowledger $ack = null)
{
return $this->handle($message, $ack);
}
Expand Down
2 changes: 1 addition & 1 deletion Transport/InMemoryTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class InMemoryTransport implements TransportInterface, ResetInterface
*/
private $serializer;

public function __construct(SerializerInterface $serializer = null)
public function __construct(?SerializerInterface $serializer = null)
{
$this->serializer = $serializer;
}
Expand Down
2 changes: 1 addition & 1 deletion Transport/Receiver/ListableReceiverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface ListableReceiverInterface extends ReceiverInterface
*
* @return Envelope[]|iterable
*/
public function all(int $limit = null): iterable;
public function all(?int $limit = null): iterable;

/**
* Returns the Envelope by id or none.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class FlattenExceptionNormalizer implements DenormalizerInterface, Context
*
* @throws InvalidArgumentException
*/
public function normalize($object, string $format = null, array $context = []): array
public function normalize($object, ?string $format = null, array $context = []): array
{
$normalized = [
'message' => $object->getMessage(),
Expand All @@ -54,15 +54,15 @@ public function normalize($object, string $format = null, array $context = []):
/**
* {@inheritdoc}
*/
public function supportsNormalization($data, string $format = null, array $context = []): bool
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
{
return $data instanceof FlattenException && ($context[Serializer::MESSENGER_SERIALIZATION_CONTEXT] ?? false);
}

/**
* {@inheritdoc}
*/
public function denormalize($data, string $type, string $format = null, array $context = []): FlattenException
public function denormalize($data, string $type, ?string $format = null, array $context = []): FlattenException
{
$object = new FlattenException();

Expand Down Expand Up @@ -93,7 +93,7 @@ public function denormalize($data, string $type, string $format = null, array $c
/**
* {@inheritdoc}
*/
public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
public function supportsDenormalization($data, string $type, ?string $format = null, array $context = []): bool
{
return FlattenException::class === $type && ($context[Serializer::MESSENGER_SERIALIZATION_CONTEXT] ?? false);
}
Expand Down
2 changes: 1 addition & 1 deletion Transport/Serialization/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Serializer implements SerializerInterface
private $format;
private $context;

public function __construct(SymfonySerializerInterface $serializer = null, string $format = 'json', array $context = [])
public function __construct(?SymfonySerializerInterface $serializer = null, string $format = 'json', array $context = [])
{
$this->serializer = $serializer ?? self::create()->serializer;
$this->format = $format;
Expand Down
4 changes: 2 additions & 2 deletions Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Worker
/**
* @param ReceiverInterface[] $receivers Where the key is the transport name
*/
public function __construct(array $receivers, MessageBusInterface $bus, EventDispatcherInterface $eventDispatcher = null, LoggerInterface $logger = null)
public function __construct(array $receivers, MessageBusInterface $bus, ?EventDispatcherInterface $eventDispatcher = null, ?LoggerInterface $logger = null)
{
$this->receivers = $receivers;
$this->bus = $bus;
Expand Down Expand Up @@ -148,7 +148,7 @@ private function handleMessage(Envelope $envelope, string $transportName): void
}

$acked = false;
$ack = function (Envelope $envelope, \Throwable $e = null) use ($transportName, &$acked) {
$ack = function (Envelope $envelope, ?\Throwable $e = null) use ($transportName, &$acked) {
$acked = true;
$this->acks[] = [$transportName, $envelope, $e];
};
Expand Down

0 comments on commit 9b17d85

Please sign in to comment.