Skip to content

Commit 843698f

Browse files
committed
fixed CS
1 parent da14597 commit 843698f

29 files changed

+261
-261
lines changed

Command/ConsumeMessagesCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ConsumeMessagesCommand extends Command
4040
private $receiverNames;
4141
private $busNames;
4242

43-
public function __construct(ContainerInterface $busLocator, ContainerInterface $receiverLocator, LoggerInterface $logger = null, array $receiverNames = array(), array $busNames = array())
43+
public function __construct(ContainerInterface $busLocator, ContainerInterface $receiverLocator, LoggerInterface $logger = null, array $receiverNames = [], array $busNames = [])
4444
{
4545
$this->busLocator = $busLocator;
4646
$this->receiverLocator = $receiverLocator;
@@ -60,13 +60,13 @@ protected function configure(): void
6060
$defaultBusName = 1 === \count($this->busNames) ? current($this->busNames) : null;
6161

6262
$this
63-
->setDefinition(array(
63+
->setDefinition([
6464
new InputArgument('receiver', $defaultReceiverName ? InputArgument::OPTIONAL : InputArgument::REQUIRED, 'Name of the receiver', $defaultReceiverName),
6565
new InputOption('limit', 'l', InputOption::VALUE_REQUIRED, 'Limit the number of received messages'),
6666
new InputOption('memory-limit', 'm', InputOption::VALUE_REQUIRED, 'The memory limit the worker can consume'),
6767
new InputOption('time-limit', 't', InputOption::VALUE_REQUIRED, 'The time limit in seconds the worker can run'),
6868
new InputOption('bus', 'b', InputOption::VALUE_REQUIRED, 'Name of the bus to which received messages should be dispatched', $defaultBusName),
69-
))
69+
])
7070
->setDescription('Consumes messages')
7171
->setHelp(<<<'EOF'
7272
The <info>%command.name%</info> command consumes messages and dispatches them to the message bus.
@@ -186,7 +186,7 @@ private function convertToBytes(string $memoryLimit): int
186186

187187
private function findAlternatives($name, array $collection)
188188
{
189-
$alternatives = array();
189+
$alternatives = [];
190190
foreach ($collection as $item) {
191191
$lev = levenshtein($name, $item);
192192
if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {

DataCollector/MessengerDataCollector.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
class MessengerDataCollector extends DataCollector implements LateDataCollectorInterface
2727
{
28-
private $traceableBuses = array();
28+
private $traceableBuses = [];
2929

3030
public function registerBus(string $name, TraceableMessageBus $bus)
3131
{
@@ -45,13 +45,13 @@ public function collect(Request $request, Response $response, \Exception $except
4545
*/
4646
public function lateCollect()
4747
{
48-
$this->data = array('messages' => array(), 'buses' => array_keys($this->traceableBuses));
48+
$this->data = ['messages' => [], 'buses' => array_keys($this->traceableBuses)];
4949

50-
$messages = array();
50+
$messages = [];
5151
foreach ($this->traceableBuses as $busName => $bus) {
5252
foreach ($bus->getDispatchedMessages() as $message) {
5353
$debugRepresentation = $this->cloneVar($this->collectMessage($busName, $message));
54-
$messages[] = array($debugRepresentation, $message['callTime']);
54+
$messages[] = [$debugRepresentation, $message['callTime']];
5555
}
5656
}
5757

@@ -75,7 +75,7 @@ public function getName()
7575
*/
7676
public function reset()
7777
{
78-
$this->data = array();
78+
$this->data = [];
7979
foreach ($this->traceableBuses as $traceableBus) {
8080
$traceableBus->reset();
8181
}
@@ -85,23 +85,23 @@ private function collectMessage(string $busName, array $tracedMessage)
8585
{
8686
$message = $tracedMessage['message'];
8787

88-
$debugRepresentation = array(
88+
$debugRepresentation = [
8989
'bus' => $busName,
9090
'stamps' => $tracedMessage['stamps'] ?? null,
91-
'message' => array(
91+
'message' => [
9292
'type' => new ClassStub(\get_class($message)),
9393
'value' => $message,
94-
),
94+
],
9595
'caller' => $tracedMessage['caller'],
96-
);
96+
];
9797

9898
if (isset($tracedMessage['exception'])) {
9999
$exception = $tracedMessage['exception'];
100100

101-
$debugRepresentation['exception'] = array(
101+
$debugRepresentation['exception'] = [
102102
'type' => \get_class($exception),
103103
'value' => $exception,
104-
);
104+
];
105105
}
106106

107107
return $debugRepresentation;

DependencyInjection/MessengerPass.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(string $handlerTag = 'messenger.message_handler', st
4747
*/
4848
public function process(ContainerBuilder $container)
4949
{
50-
$busIds = array();
50+
$busIds = [];
5151
foreach ($container->findTaggedServiceIds($this->busTag) as $busId => $tags) {
5252
$busIds[] = $busId;
5353
if ($container->hasParameter($busMiddlewareParameter = $busId.'.middleware')) {
@@ -69,8 +69,8 @@ public function process(ContainerBuilder $container)
6969

7070
private function registerHandlers(ContainerBuilder $container, array $busIds)
7171
{
72-
$definitions = array();
73-
$handlersByBusAndMessage = array();
72+
$definitions = [];
73+
$handlersByBusAndMessage = [];
7474

7575
foreach ($container->findTaggedServiceIds($this->handlerTag, true) as $serviceId => $tags) {
7676
foreach ($tags as $tag) {
@@ -86,7 +86,7 @@ private function registerHandlers(ContainerBuilder $container, array $busIds)
8686
}
8787

8888
if (isset($tag['handles'])) {
89-
$handles = isset($tag['method']) ? array($tag['handles'] => $tag['method']) : array($tag['handles']);
89+
$handles = isset($tag['method']) ? [$tag['handles'] => $tag['method']] : [$tag['handles']];
9090
} else {
9191
$handles = $this->guessHandledClasses($r, $serviceId);
9292
}
@@ -115,7 +115,7 @@ private function registerHandlers(ContainerBuilder $container, array $busIds)
115115
throw new RuntimeException(sprintf('Invalid configuration %s for message "%s": bus "%s" does not exist.', $messageLocation, $message, $method['bus']));
116116
}
117117

118-
$buses = array($method['bus']);
118+
$buses = [$method['bus']];
119119
}
120120

121121
$priority = $method['priority'] ?? $priority;
@@ -133,7 +133,7 @@ private function registerHandlers(ContainerBuilder $container, array $busIds)
133133
}
134134

135135
if ('__invoke' !== $method) {
136-
$wrapperDefinition = (new Definition('callable'))->addArgument(array(new Reference($serviceId), $method))->setFactory('Closure::fromCallable');
136+
$wrapperDefinition = (new Definition('callable'))->addArgument([new Reference($serviceId), $method])->setFactory('Closure::fromCallable');
137137

138138
$definitions[$definitionId = '.messenger.method_on_object_wrapper.'.ContainerBuilder::hash($message.':'.$priority.':'.$serviceId.':'.$method)] = $wrapperDefinition;
139139
} else {
@@ -158,7 +158,7 @@ private function registerHandlers(ContainerBuilder $container, array $busIds)
158158
}
159159
}
160160

161-
$handlersLocatorMappingByBus = array();
161+
$handlersLocatorMappingByBus = [];
162162
foreach ($handlersByBusAndMessage as $bus => $handlersByMessage) {
163163
foreach ($handlersByMessage as $message => $handlerIds) {
164164
$handlers = array_map(function (string $handlerId) { return new Reference($handlerId); }, $handlerIds);
@@ -169,7 +169,7 @@ private function registerHandlers(ContainerBuilder $container, array $busIds)
169169

170170
foreach ($busIds as $bus) {
171171
$container->register($locatorId = $bus.'.messenger.handlers_locator', HandlersLocator::class)
172-
->setArgument(0, $handlersLocatorMappingByBus[$bus] ?? array())
172+
->setArgument(0, $handlersLocatorMappingByBus[$bus] ?? [])
173173
;
174174
if ($container->has($handleMessageId = $bus.'.middleware.handle_message')) {
175175
$container->getDefinition($handleMessageId)
@@ -182,7 +182,7 @@ private function registerHandlers(ContainerBuilder $container, array $busIds)
182182
$debugCommandMapping = $handlersByBusAndMessage;
183183
foreach ($busIds as $bus) {
184184
if (!isset($debugCommandMapping[$bus])) {
185-
$debugCommandMapping[$bus] = array();
185+
$debugCommandMapping[$bus] = [];
186186
}
187187
}
188188
$container->getDefinition('console.command.messenger_debug')->replaceArgument(0, $debugCommandMapping);
@@ -214,12 +214,12 @@ private function guessHandledClasses(\ReflectionClass $handlerClass, string $ser
214214
throw new RuntimeException(sprintf('Invalid handler service "%s": type-hint of argument "$%s" in method "%s::__invoke()" must be a class , "%s" given.', $serviceId, $parameters[0]->getName(), $handlerClass->getName(), $type));
215215
}
216216

217-
return array((string) $parameters[0]->getType());
217+
return [(string) $parameters[0]->getType()];
218218
}
219219

220220
private function registerReceivers(ContainerBuilder $container, array $busIds)
221221
{
222-
$receiverMapping = array();
222+
$receiverMapping = [];
223223

224224
foreach ($container->findTaggedServiceIds($this->receiverTag) as $id => $tags) {
225225
$receiverClass = $container->findDefinition($id)->getClass();
@@ -237,11 +237,11 @@ private function registerReceivers(ContainerBuilder $container, array $busIds)
237237
}
238238

239239
if ($container->hasDefinition('console.command.messenger_consume_messages')) {
240-
$receiverNames = array();
240+
$receiverNames = [];
241241
foreach ($receiverMapping as $name => $reference) {
242242
$receiverNames[(string) $reference] = $name;
243243
}
244-
$buses = array();
244+
$buses = [];
245245
foreach ($busIds as $busId) {
246246
$buses[$busId] = new Reference($busId);
247247
}
@@ -259,18 +259,18 @@ private function registerBusToCollector(ContainerBuilder $container, string $bus
259259
{
260260
$container->setDefinition(
261261
$tracedBusId = 'debug.traced.'.$busId,
262-
(new Definition(TraceableMessageBus::class, array(new Reference($tracedBusId.'.inner'))))->setDecoratedService($busId)
262+
(new Definition(TraceableMessageBus::class, [new Reference($tracedBusId.'.inner')]))->setDecoratedService($busId)
263263
);
264264

265-
$container->getDefinition('data_collector.messenger')->addMethodCall('registerBus', array($busId, new Reference($tracedBusId)));
265+
$container->getDefinition('data_collector.messenger')->addMethodCall('registerBus', [$busId, new Reference($tracedBusId)]);
266266
}
267267

268268
private function registerBusMiddleware(ContainerBuilder $container, string $busId, array $middlewareCollection)
269269
{
270-
$middlewareReferences = array();
270+
$middlewareReferences = [];
271271
foreach ($middlewareCollection as $middlewareItem) {
272272
$id = $middlewareItem['id'];
273-
$arguments = $middlewareItem['arguments'] ?? array();
273+
$arguments = $middlewareItem['arguments'] ?? [];
274274
if (!$container->has($messengerMiddlewareId = 'messenger.middleware.'.$id)) {
275275
$messengerMiddlewareId = $id;
276276
}

Envelope.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
final class Envelope
2424
{
25-
private $stamps = array();
25+
private $stamps = [];
2626
private $message;
2727

2828
/**
@@ -65,7 +65,7 @@ public function last(string $stampFqcn): ?StampInterface
6565
public function all(string $stampFqcn = null): array
6666
{
6767
if (null !== $stampFqcn) {
68-
return $this->stamps[$stampFqcn] ?? array();
68+
return $this->stamps[$stampFqcn] ?? [];
6969
}
7070

7171
return $this->stamps;

Handler/HandlersLocator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public function __construct(array $handlers)
3737
*/
3838
public function getHandlers(Envelope $envelope): iterable
3939
{
40-
$seen = array();
40+
$seen = [];
4141

4242
foreach (self::listTypes($envelope) as $type) {
43-
foreach ($this->handlers[$type] ?? array() as $alias => $handler) {
43+
foreach ($this->handlers[$type] ?? [] as $alias => $handler) {
4444
if (!\in_array($handler, $seen, true)) {
4545
yield $alias => $seen[] = $handler;
4646
}
@@ -55,9 +55,9 @@ public static function listTypes(Envelope $envelope): array
5555
{
5656
$class = \get_class($envelope->getMessage());
5757

58-
return array($class => $class)
58+
return [$class => $class]
5959
+ class_parents($class)
6060
+ class_implements($class)
61-
+ array('*' => '*');
61+
+ ['*' => '*'];
6262
}
6363
}

Middleware/LoggingMiddleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public function __construct(LoggerInterface $logger)
3434
public function handle(Envelope $envelope, StackInterface $stack): Envelope
3535
{
3636
$message = $envelope->getMessage();
37-
$context = array(
37+
$context = [
3838
'message' => $message,
3939
'class' => \get_class($envelope->getMessage()),
40-
);
40+
];
4141
$this->logger->debug('Starting handling message "{class}"', $context);
4242

4343
try {

Tests/Command/ConsumeMessagesCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ class ConsumeMessagesCommandTest extends TestCase
1919
{
2020
public function testConfigurationWithDefaultReceiver()
2121
{
22-
$command = new ConsumeMessagesCommand($this->createMock(ServiceLocator::class), $this->createMock(ServiceLocator::class), null, array('amqp'));
22+
$command = new ConsumeMessagesCommand($this->createMock(ServiceLocator::class), $this->createMock(ServiceLocator::class), null, ['amqp']);
2323
$inputArgument = $command->getDefinition()->getArgument('receiver');
2424
$this->assertFalse($inputArgument->isRequired());
2525
$this->assertSame('amqp', $inputArgument->getDefault());
2626
}
2727

2828
public function testConfigurationWithoutDefaultReceiver()
2929
{
30-
$command = new ConsumeMessagesCommand($this->createMock(ServiceLocator::class), $this->createMock(ServiceLocator::class), null, array('amqp', 'dummy'));
30+
$command = new ConsumeMessagesCommand($this->createMock(ServiceLocator::class), $this->createMock(ServiceLocator::class), null, ['amqp', 'dummy']);
3131
$inputArgument = $command->getDefinition()->getArgument('receiver');
3232
$this->assertTrue($inputArgument->isRequired());
3333
$this->assertNull($inputArgument->getDefault());

0 commit comments

Comments
 (0)