diff --git a/Classes/Command/MessengerCommandController.php b/Classes/Command/MessengerCommandController.php index 9b692ff..de0930f 100644 --- a/Classes/Command/MessengerCommandController.php +++ b/Classes/Command/MessengerCommandController.php @@ -84,18 +84,17 @@ class MessengerCommandController extends CommandController $this->receiverContainer, $this->eventDispatcher, $this->logger, - array_keys($this->configuration['transports']) + \array_keys($this->configuration['transports']) ); $this->run($command); } - /** * List all available receivers */ public function listReceiversCommand() { - foreach (array_keys($this->configuration['transports']) as $transportName) { + foreach (\array_keys($this->configuration['transports']) as $transportName) { $this->outputLine('- ' . $transportName); } } @@ -112,7 +111,7 @@ class MessengerCommandController extends CommandController $cacheItem = $this->restartSignalCachePool->getItem( StopWorkerOnRestartSignalListener::RESTART_REQUESTED_TIMESTAMP_KEY ); - $cacheItem->set(microtime(true)); + $cacheItem->set(\microtime(true)); $this->restartSignalCachePool->save($cacheItem); //TODO: Add the possibility to wait until all are exited diff --git a/Classes/Command/RunSymfonyCommandTrait.php b/Classes/Command/RunSymfonyCommandTrait.php index 68654cb..b5e4779 100644 --- a/Classes/Command/RunSymfonyCommandTrait.php +++ b/Classes/Command/RunSymfonyCommandTrait.php @@ -13,11 +13,11 @@ trait RunSymfonyCommandTrait protected function run(Command $command) { $definition = $command->getDefinition(); - $definition->setArguments(array_merge( + $definition->setArguments(\array_merge( [new InputArgument('command', InputArgument::REQUIRED)], $definition->getArguments() )); - $definition->setOptions(array_merge( + $definition->setOptions(\array_merge( [ new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'), new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'), @@ -31,7 +31,7 @@ trait RunSymfonyCommandTrait protected function configureIO($input, $output) { - switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) { + switch ($shellVerbosity = (int)\getenv('SHELL_VERBOSITY')) { case -1: $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); break; @@ -82,7 +82,7 @@ trait RunSymfonyCommandTrait $input->setInteractive(false); } - putenv('SHELL_VERBOSITY=' . $shellVerbosity); + \putenv('SHELL_VERBOSITY=' . $shellVerbosity); $_ENV['SHELL_VERBOSITY'] = $shellVerbosity; $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity; } diff --git a/Classes/EventDispatcherFactory.php b/Classes/EventDispatcherFactory.php index 1b612e3..99fccad 100644 --- a/Classes/EventDispatcherFactory.php +++ b/Classes/EventDispatcherFactory.php @@ -28,7 +28,7 @@ class EventDispatcherFactory $eventDispatcher = new EventDispatcher(); foreach ($this->configuration['eventDispatcher']['subscribers'] as $subscriberId => $enabled) { - if ($subscriberId === null || ! (bool) $enabled) { + if ($subscriberId === null || ! (bool)$enabled) { continue; } $this->addLazySubscribers($eventDispatcher, $subscriberId); @@ -39,7 +39,7 @@ class EventDispatcherFactory private function addLazySubscribers(EventDispatcherInterface $eventDispatcher, $subscriberId) { $subscriberClass = $this->objectManager->getClassNameByObjectName($subscriberId); - if (! is_a($subscriberClass, EventSubscriberInterface::class, true)) { + if (! \is_a($subscriberClass, EventSubscriberInterface::class, true)) { throw new \RuntimeException( 'Object with name ' . $subscriberId . ' is not an EventSubscriberInterface', 1618753949 diff --git a/Classes/EventListener/StopWorkerOnRestartSignalListener.php b/Classes/EventListener/StopWorkerOnRestartSignalListener.php index 2104fea..9d878a4 100644 --- a/Classes/EventListener/StopWorkerOnRestartSignalListener.php +++ b/Classes/EventListener/StopWorkerOnRestartSignalListener.php @@ -35,7 +35,7 @@ class StopWorkerOnRestartSignalListener implements EventSubscriberInterface public function onWorkerStarted(): void { - $this->workerStartedAt = microtime(true); + $this->workerStartedAt = \microtime(true); } public function onWorkerRunning(WorkerRunningEvent $event): void diff --git a/Classes/HandlersLocatorFactory.php b/Classes/HandlersLocatorFactory.php index b7b3b50..a060ab9 100644 --- a/Classes/HandlersLocatorFactory.php +++ b/Classes/HandlersLocatorFactory.php @@ -36,7 +36,7 @@ class HandlersLocatorFactory $handlerDescriptors = []; foreach ($messageHandlerClasses as $messageHandlerClass) { foreach ($messageHandlerClass::getHandledMessages() as $messageName => $config) { - if (! is_array($config)) { + if (! \is_array($config)) { throw new \InvalidArgumentException( 'different from doctrine, we (currently) need subscribers to always have an option array' ); diff --git a/Classes/ObjectManagement/RewindableGenerator.php b/Classes/ObjectManagement/RewindableGenerator.php index 5332e5d..e6fe50b 100644 --- a/Classes/ObjectManagement/RewindableGenerator.php +++ b/Classes/ObjectManagement/RewindableGenerator.php @@ -28,7 +28,7 @@ class RewindableGenerator implements \IteratorAggregate, \Countable public function __construct(array $serviceIds) { $this->serviceIds = $serviceIds; - $sortedServiceIds = array_keys( + $sortedServiceIds = \array_keys( (new PositionalArraySorter($serviceIds))->toArray() ); $this->generator = function () use ($sortedServiceIds) { @@ -38,7 +38,7 @@ class RewindableGenerator implements \IteratorAggregate, \Countable } $object = $this->objectManager->get($serviceId); // TODO: Thats a quite poor solution to dynamically inject the logger - but it is easy - if (method_exists($object, 'setLogger')) { + if (\method_exists($object, 'setLogger')) { $object->setLogger($this->objectManager->get(LoggerInterface::class)); } yield $object; @@ -55,6 +55,6 @@ class RewindableGenerator implements \IteratorAggregate, \Countable public function count() { - return count($this->serviceIds); + return \count($this->serviceIds); } } diff --git a/Classes/RetryStrategiesContainer.php b/Classes/RetryStrategiesContainer.php index 58ddff1..6041c9f 100644 --- a/Classes/RetryStrategiesContainer.php +++ b/Classes/RetryStrategiesContainer.php @@ -36,7 +36,7 @@ class RetryStrategiesContainer implements ContainerInterface throw new \InvalidArgumentException('Unknown transport name: ' . $id); } if (! isset($this->retryStrategies[$id])) { - $strategyDefinition = array_merge( + $strategyDefinition = \array_merge( $this->configuration['defaultRetryStrategyOptions'], $this->configuration['transports'][$id]['retryStrategy'] ?? [] ); diff --git a/Classes/Transport/FlowDoctrineTransportFactory.php b/Classes/Transport/FlowDoctrineTransportFactory.php index d18897f..f9c4d9d 100644 --- a/Classes/Transport/FlowDoctrineTransportFactory.php +++ b/Classes/Transport/FlowDoctrineTransportFactory.php @@ -4,6 +4,7 @@ namespace DigiComp\FlowSymfonyBridge\Messenger\Transport; use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver; use Doctrine\ORM\EntityManagerInterface; +use Neos\Flow\Annotations as Flow; use Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection; use Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineTransport; use Symfony\Component\Messenger\Bridge\Doctrine\Transport\PostgreSqlConnection; @@ -11,7 +12,6 @@ use Symfony\Component\Messenger\Exception\TransportException; use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface; use Symfony\Component\Messenger\Transport\TransportFactoryInterface; use Symfony\Component\Messenger\Transport\TransportInterface; -use Neos\Flow\Annotations as Flow; /** * @Flow\Scope("singleton") @@ -36,7 +36,7 @@ class FlowDoctrineTransportFactory implements TransportFactoryInterface try { $driverConnection = $this->entityManager->getConnection(); } catch (\InvalidArgumentException $e) { - throw new TransportException(sprintf( + throw new TransportException(\sprintf( 'Could not find Doctrine connection from Messenger DSN "%s".', $dsn ), 0, $e); @@ -56,6 +56,6 @@ class FlowDoctrineTransportFactory implements TransportFactoryInterface */ public function supports(string $dsn, array $options): bool { - return 0 === strpos($dsn, 'flow-doctrine://'); + return 0 === \strpos($dsn, 'flow-doctrine://'); } } diff --git a/Classes/Transport/NullTransportFactory.php b/Classes/Transport/NullTransportFactory.php index 7358745..4915998 100644 --- a/Classes/Transport/NullTransportFactory.php +++ b/Classes/Transport/NullTransportFactory.php @@ -21,6 +21,6 @@ class NullTransportFactory implements TransportFactoryInterface */ public function supports(string $dsn, array $options): bool { - return 0 === strpos($dsn, 'null://'); + return 0 === \strpos($dsn, 'null://'); } } diff --git a/Classes/Transport/TransportsContainer.php b/Classes/Transport/TransportsContainer.php index fb967a9..d96a752 100644 --- a/Classes/Transport/TransportsContainer.php +++ b/Classes/Transport/TransportsContainer.php @@ -42,23 +42,23 @@ class TransportsContainer implements ContainerInterface throw new \InvalidArgumentException('Unknown transport name: ' . $id); } if (! isset($this->transports[$id])) { - $transportDefinition = array_merge([ + $transportDefinition = \array_merge([ 'dsn' => '', 'options' => [], 'serializer' => $this->configuration['defaultSerializerName'], - # TODO: Probably this has to be setup elsewhere, as the transport does not care by itself - 'retry_strategy' => [ # TODO: Make the default configurable + // TODO: Probably this has to be setup elsewhere, as the transport does not care by itself + 'retry_strategy' => [ // TODO: Make the default configurable 'max_retries' => 3, - # milliseconds delay + // milliseconds delay 'delay' => 1000, - # causes the delay to be higher before each retry - # e.g. 1 second delay, 2 seconds, 4 seconds + // causes the delay to be higher before each retry + // e.g. 1 second delay, 2 seconds, 4 seconds 'multiplier' => 2, 'max_delay' => 0, - # override all of this with a service that - # implements Symfony\Component\Messenger\Retry\RetryStrategyInterface + // override all of this with a service that + // implements Symfony\Component\Messenger\Retry\RetryStrategyInterface 'service' => null - ] + ], ], $this->configuration['transports'][$id]); $this->transports[$id] = $this->transportFactory->createTransport( $transportDefinition['dsn'],