Skip to content

Commit

Permalink
Merge branch '5.4' into 6.3
Browse files Browse the repository at this point in the history
* 5.4:
  Fix implicitly-required parameters
  List CS fix in .git-blame-ignore-revs
  Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value
  [Messenger][AmazonSqs] Allow async-aws/sqs version 2
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
2 parents 96f41b3 + 9b17d85 commit e5baef7
Show file tree
Hide file tree
Showing 37 changed files with 51 additions and 51 deletions.
4 changes: 2 additions & 2 deletions Command/AbstractFailedMessagesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract class AbstractFailedMessagesCommand extends Command

private ?string $globalFailureReceiverName;

public function __construct(?string $globalFailureReceiverName, ServiceProviderInterface $failureTransports, PhpSerializer $phpSerializer = null)
public function __construct(?string $globalFailureReceiverName, ServiceProviderInterface $failureTransports, ?PhpSerializer $phpSerializer = null)
{
$this->failureTransports = $failureTransports;
$this->globalFailureReceiverName = $globalFailureReceiverName;
Expand Down Expand Up @@ -159,7 +159,7 @@ protected function printPendingMessagesMessage(ReceiverInterface $receiver, Symf
}
}

protected function getReceiver(string $name = null): ReceiverInterface
protected function getReceiver(?string $name = null): ReceiverInterface
{
if (null === $name ??= $this->globalFailureReceiverName) {
throw new InvalidArgumentException(sprintf('No default failure transport is defined. Available transports are: "%s".', implode('", "', array_keys($this->failureTransports->getProvidedServices()))));
Expand Down
2 changes: 1 addition & 1 deletion Command/ConsumeMessagesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ConsumeMessagesCommand extends Command implements SignalableCommandInterfa
private ?array $signals;
private ?Worker $worker = null;

public function __construct(RoutableMessageBus $routableBus, ContainerInterface $receiverLocator, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger = null, array $receiverNames = [], ResetServicesListener $resetServicesListener = null, array $busIds = [], ContainerInterface $rateLimiterLocator = null, array $signals = null)
public function __construct(RoutableMessageBus $routableBus, ContainerInterface $receiverLocator, EventDispatcherInterface $eventDispatcher, ?LoggerInterface $logger = null, array $receiverNames = [], ?ResetServicesListener $resetServicesListener = null, array $busIds = [], ?ContainerInterface $rateLimiterLocator = null, ?array $signals = null)
{
$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 @@ -47,7 +47,7 @@ class FailedMessagesRetryCommand extends AbstractFailedMessagesCommand implement
private bool $forceExit = false;
private ?Worker $worker = null;

public function __construct(?string $globalReceiverName, ServiceProviderInterface $failureTransports, MessageBusInterface $messageBus, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger = null, PhpSerializer $phpSerializer = null, array $signals = null)
public function __construct(?string $globalReceiverName, ServiceProviderInterface $failureTransports, MessageBusInterface $messageBus, EventDispatcherInterface $eventDispatcher, ?LoggerInterface $logger = null, ?PhpSerializer $phpSerializer = null, ?array $signals = null)
{
$this->eventDispatcher = $eventDispatcher;
$this->messageBus = $messageBus;
Expand Down
2 changes: 1 addition & 1 deletion Command/FailedMessagesShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

private function listMessages(?string $failedTransportName, SymfonyStyle $io, int $max, string $classFilter = null): void
private function listMessages(?string $failedTransportName, SymfonyStyle $io, int $max, ?string $classFilter = null): void
{
/** @var ListableReceiverInterface $receiver */
$receiver = $this->getReceiver($failedTransportName);
Expand Down
6 changes: 3 additions & 3 deletions DataCollector/MessengerDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function registerBus(string $name, TraceableMessageBus $bus)
$this->traceableBuses[$name] = $bus;
}

public function collect(Request $request, Response $response, \Throwable $exception = null): void
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
{
// Noop. Everything is collected live by the traceable buses & cloned as late as possible.
}
Expand Down Expand Up @@ -106,7 +106,7 @@ private function collectMessage(string $busName, array $tracedMessage): array
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 @@ -116,7 +116,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 @@ -114,7 +114,7 @@ public function last(string $stampFqcn): ?StampInterface
*
* @psalm-return ($stampFqcn is string : array<class-string<StampInterface>, list<StampInterface>> ? list<TStamp>)
*/
public function all(string $stampFqcn = null): array
public function all(?string $stampFqcn = null): array
{
if (null !== $stampFqcn) {
return $this->stamps[$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 bool $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 ?EventDispatcherInterface $eventDispatcher;
private int $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 @@ -29,7 +29,7 @@ class SendFailedMessageToFailureTransportListener implements EventSubscriberInte
private ContainerInterface $failureSenders;
private ?LoggerInterface $logger;

public function __construct(ContainerInterface $failureSenders, LoggerInterface $logger = null)
public function __construct(ContainerInterface $failureSenders, ?LoggerInterface $logger = null)
{
$this->failureSenders = $failureSenders;
$this->logger = $logger;
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 ?LoggerInterface $logger;
private int $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 ?LoggerInterface $logger;
private \Closure $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 ?LoggerInterface $logger;
private int $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 ?LoggerInterface $logger;
private float $workerStartedAt = 0;

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/StopWorkerOnSignalsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class StopWorkerOnSignalsListener implements EventSubscriberInterface
private array $signals;
private ?LoggerInterface $logger;

public function __construct(array $signals = null, LoggerInterface $logger = null)
public function __construct(?array $signals = null, ?LoggerInterface $logger = null)
{
if (null === $signals && \extension_loaded('pcntl')) {
$signals = [SIGTERM, SIGINT];
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 extends StopWorkerOnSignalsListener
{
public function __construct(LoggerInterface $logger = null)
public function __construct(?LoggerInterface $logger = null)
{
parent::__construct(\extension_loaded('pcntl') ? [SIGTERM] : [], $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 ?LoggerInterface $logger;
private float $endTime = 0;

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/DelayedMessageHandlingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DelayedMessageHandlingException extends RuntimeException
private array $exceptions;
private ?Envelope $envelope;

public function __construct(array $exceptions, Envelope $envelope = null)
public function __construct(array $exceptions, ?Envelope $envelope = null)
{
$this->envelope = $envelope;

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 @@ -67,7 +67,7 @@ public function __destruct()
}
}

private function doAck(\Throwable $e = null, mixed $result = null): void
private function doAck(?\Throwable $e = null, mixed $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 @@ -69,7 +69,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 ?EventDispatcherInterface $eventDispatcher;
private bool $allowNoSenders;

public function __construct(SendersLocatorInterface $sendersLocator, EventDispatcherInterface $eventDispatcher = null, bool $allowNoSenders = true)
public function __construct(SendersLocatorInterface $sendersLocator, ?EventDispatcherInterface $eventDispatcher = null, bool $allowNoSenders = true)
{
$this->sendersLocator = $sendersLocator;
$this->eventDispatcher = $eventDispatcher;
Expand Down
2 changes: 1 addition & 1 deletion Middleware/StackMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class StackMiddleware implements MiddlewareInterface, StackInterface
/**
* @param iterable<mixed, MiddlewareInterface>|MiddlewareInterface|null $middlewareIterator
*/
public function __construct(iterable|MiddlewareInterface $middlewareIterator = null)
public function __construct(iterable|MiddlewareInterface|null $middlewareIterator = null)
{
$this->stack = new MiddlewareStack();

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
4 changes: 2 additions & 2 deletions Retry/RetryStrategyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ interface RetryStrategyInterface
/**
* @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;

/**
* @param \Throwable|null $throwable The cause of the failed handling
*
* @return int The time to delay/wait in milliseconds
*/
public function getWaitingTime(Envelope $message, \Throwable $throwable = null): int;
public function getWaitingTime(Envelope $message, ?\Throwable $throwable = null): int;
}
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 ContainerInterface $busLocator;
private ?MessageBusInterface $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 @@ -24,7 +24,7 @@ final class ErrorDetailsStamp implements StampInterface
private string $exceptionMessage;
private ?FlattenException $flattenException;

public function __construct(string $exceptionClass, int|string $exceptionCode, string $exceptionMessage, FlattenException $flattenException = null)
public function __construct(string $exceptionClass, int|string $exceptionCode, string $exceptionMessage, ?FlattenException $flattenException = null)
{
$this->exceptionClass = $exceptionClass;
$this->exceptionCode = $exceptionCode;
Expand Down
2 changes: 1 addition & 1 deletion Stamp/RedeliveryStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class RedeliveryStamp implements StampInterface
private int $retryCount;
private \DateTimeInterface $redeliveredAt;

public function __construct(int $retryCount, \DateTimeInterface $redeliveredAt = null)
public function __construct(int $retryCount, ?\DateTimeInterface $redeliveredAt = null)
{
$this->retryCount = $retryCount;
$this->redeliveredAt = $redeliveredAt ?? new \DateTimeImmutable();
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 string $senderClass;
private ?string $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 @@ -44,7 +44,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 @@ -174,7 +174,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 @@ -199,7 +199,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 @@ -228,7 +228,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 @@ -248,7 +248,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 @@ -265,7 +265,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 @@ -596,7 +596,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
Loading

0 comments on commit e5baef7

Please sign in to comment.