PHPCBF run

This commit is contained in:
Ferdinand Kuhl 2022-09-18 13:17:53 +02:00
parent 16777f1daf
commit 42dd283690
10 changed files with 28 additions and 29 deletions

View file

@ -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

View file

@ -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;
}

View file

@ -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

View file

@ -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

View file

@ -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'
);

View file

@ -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);
}
}

View file

@ -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'] ?? []
);

View file

@ -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://');
}
}

View file

@ -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://');
}
}

View file

@ -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'],