Skip to content

Commit d75eed7

Browse files
author
Mathieu Lemoine
committed
apply new cs-fixer and phpstan rules
1 parent 23d22f9 commit d75eed7

18 files changed

+54
-103
lines changed

phpstan.neon

+7
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@ parameters:
1414
- pkg/enqueue-bundle/DependencyInjection/Configuration.php
1515
- pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php
1616
- pkg/simple-client/SimpleClient.php
17+
ignoreErrors:
18+
-
19+
message: Class Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy not found.
20+
path: %currentWorkingDirectory%/*
21+
-
22+
message: #.*Symfony\Contracts\EventDispatcher\Event.*#
23+
path: %currentWorkingDirectory%/*

pkg/async-event-dispatcher/AbstractAsyncEventDispatcher.php

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ abstract class AbstractAsyncEventDispatcher extends EventDispatcher implements E
1919
*/
2020
protected $asyncListener;
2121

22-
/**
23-
* @param EventDispatcherInterface $trueEventDispatcher
24-
* @param AsyncListener $asyncListener
25-
*/
2622
public function __construct(EventDispatcherInterface $trueEventDispatcher, AsyncListener $asyncListener)
2723
{
2824
$this->trueEventDispatcher = $trueEventDispatcher;

pkg/async-event-dispatcher/AbstractAsyncListener.php

-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Interop\Queue\Context;
66
use Interop\Queue\Queue;
7-
use Symfony\Component\EventDispatcher\Event;
87

98
abstract class AbstractAsyncListener
109
{
@@ -29,8 +28,6 @@ abstract class AbstractAsyncListener
2928
protected $syncMode;
3029

3130
/**
32-
* @param Context $context
33-
* @param Registry $registry
3431
* @param Queue|string $eventQueue
3532
*/
3633
public function __construct(Context $context, Registry $registry, $eventQueue)

pkg/async-event-dispatcher/AbstractPhpSerializerEventTransformer.php

-9
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
use Interop\Queue\Context;
66
use Interop\Queue\Message;
7-
use Symfony\Component\EventDispatcher\Event;
8-
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
9-
use Symfony\Contracts\EventDispatcher\Event as ContractEvent;
107

118
abstract class AbstractPhpSerializerEventTransformer
129
{
@@ -15,17 +12,11 @@ abstract class AbstractPhpSerializerEventTransformer
1512
*/
1613
protected $context;
1714

18-
/**
19-
* @param Context $context
20-
*/
2115
public function __construct(Context $context)
2216
{
2317
$this->context = $context;
2418
}
2519

26-
/**
27-
* {@inheritdoc}
28-
*/
2920
public function toEvent($eventName, Message $message)
3021
{
3122
return unserialize($message->getBody());

pkg/async-event-dispatcher/AsyncEventDispatcher.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
if (class_exists(Event::class) && !class_exists(LegacyEventDispatcherProxy::class)) {
99
/**
10-
* Symfony < 4.3
10+
* Symfony < 4.3.
1111
*/
1212
class AsyncEventDispatcher extends AbstractAsyncEventDispatcher
1313
{
@@ -28,7 +28,7 @@ protected function parentDispatch($event, $eventName)
2828
}
2929
} elseif (class_exists(Event::class)) {
3030
/**
31-
* Symfony >= 4.3 and < 5.0
31+
* Symfony >= 4.3 and < 5.0.
3232
*/
3333
class AsyncEventDispatcher extends AbstractAsyncEventDispatcher
3434
{
@@ -49,7 +49,7 @@ protected function parentDispatch($event, $eventName)
4949
}
5050
} else {
5151
/**
52-
* Symfony >= 5.0
52+
* Symfony >= 5.0.
5353
*/
5454
class AsyncEventDispatcher extends AbstractAsyncEventDispatcher
5555
{

pkg/async-event-dispatcher/AsyncListener.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
if (class_exists(Event::class) && !class_exists(LegacyEventDispatcherProxy::class)) {
1010
/**
11-
* Symfony < 4.3
11+
* Symfony < 4.3.
1212
*/
1313
class AsyncListener extends AbstractAsyncListener
1414
{
@@ -18,7 +18,6 @@ public function __invoke(Event $event, $eventName)
1818
}
1919

2020
/**
21-
* @param Event $event
2221
* @param string $eventName
2322
*/
2423
public function onEvent(Event $event, $eventName)
@@ -36,7 +35,7 @@ public function onEvent(Event $event, $eventName)
3635
}
3736
} elseif (class_exists(Event::class)) {
3837
/**
39-
* Symfony >= 4.3 and < 5.0
38+
* Symfony >= 4.3 and < 5.0.
4039
*/
4140
class AsyncListener extends AbstractAsyncListener
4241
{
@@ -68,7 +67,7 @@ public function onEvent($event, $eventName)
6867
}
6968
} else {
7069
/**
71-
* Symfony >= 5.0
70+
* Symfony >= 5.0.
7271
*/
7372
class AsyncListener extends AbstractAsyncListener
7473
{
@@ -78,7 +77,6 @@ public function __invoke(ContractEvent $event, $eventName)
7877
}
7978

8079
/**
81-
* @param Event $event
8280
* @param string $eventName
8381
*/
8482
public function onEvent(ContractEvent $event, $eventName)

pkg/async-event-dispatcher/EventTransformer.php

+11-13
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,22 @@
99

1010
if (class_exists(Event::class) && !class_exists(LegacyEventDispatcherProxy::class)) {
1111
/**
12-
* Symfony < 4.3
12+
* Symfony < 4.3.
1313
*/
1414
interface EventTransformer
1515
{
1616
/**
17-
* @param string $eventName
18-
* @param Event|null $event
17+
* @param string $eventName
1918
*
2019
* @return Message
2120
*/
2221
public function toMessage($eventName, Event $event = null);
2322

2423
/**
2524
* If you able to transform message back to event return it.
26-
* If you failed to transform for some reason you can return a string status (@param string $eventName
25+
* If you failed to transform for some reason you can return a string status.
2726
*
28-
* @param Message $message
27+
* @param mixed $eventName
2928
*
3029
* @return Event|string|object
3130
* @see Process constants) or an object that implements __toString method.
@@ -36,7 +35,7 @@ public function toEvent($eventName, Message $message);
3635
}
3736
} elseif (class_exists(Event::class)) {
3837
/**
39-
* Symfony >= 4.3 and < 5.0
38+
* Symfony >= 4.3 and < 5.0.
4039
*/
4140
interface EventTransformer
4241
{
@@ -50,9 +49,9 @@ public function toMessage($eventName, $event = null);
5049

5150
/**
5251
* If you able to transform message back to event return it.
53-
* If you failed to transform for some reason you can return a string status (@param string $eventName
52+
* If you failed to transform for some reason you can return a string status.
5453
*
55-
* @param Message $message
54+
* @param mixed $eventName
5655
*
5756
* @return ContractEvent|Event|string|object
5857
* @see Process constants) or an object that implements __toString method.
@@ -63,23 +62,22 @@ public function toEvent($eventName, Message $message);
6362
}
6463
} else {
6564
/**
66-
* Symfony >= 5.0
65+
* Symfony >= 5.0.
6766
*/
6867
interface EventTransformer
6968
{
7069
/**
71-
* @param string $eventName
72-
* @param ContractEvent|null $event
70+
* @param string $eventName
7371
*
7472
* @return Message
7573
*/
7674
public function toMessage($eventName, ContractEvent $event = null);
7775

7876
/**
7977
* If you able to transform message back to event return it.
80-
* If you failed to transform for some reason you can return a string status (@param string $eventName
78+
* If you failed to transform for some reason you can return a string status.
8179
*
82-
* @param Message $message
80+
* @param mixed $eventNAme
8381
*
8482
* @return ContractEvent|string|object
8583
* @see Process constants) or an object that implements __toString method.

pkg/async-event-dispatcher/PhpSerializerEventTransformer.php

+3-12
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,32 @@
88

99
if (class_exists(Event::class) && !class_exists(LegacyEventDispatcherProxy::class)) {
1010
/**
11-
* Symfony < 4.3
11+
* Symfony < 4.3.
1212
*/
1313
class PhpSerializerEventTransformer extends AbstractPhpSerializerEventTransformer implements EventTransformer
1414
{
15-
/**
16-
* {@inheritdoc}
17-
*/
1815
public function toMessage($eventName, Event $event = null)
1916
{
2017
return $this->context->createMessage(serialize($event));
2118
}
2219
}
2320
} elseif (class_exists(Event::class)) {
2421
/**
25-
* Symfony >= 4.3 and < 5.0
22+
* Symfony >= 4.3 and < 5.0.
2623
*/
2724
class PhpSerializerEventTransformer extends AbstractPhpSerializerEventTransformer implements EventTransformer
2825
{
29-
/**
30-
* {@inheritdoc}
31-
*/
3226
public function toMessage($eventName, $event = null)
3327
{
3428
return $this->context->createMessage(serialize($event));
3529
}
3630
}
3731
} else {
3832
/**
39-
* Symfony >= 5.0
33+
* Symfony >= 5.0.
4034
*/
4135
class PhpSerializerEventTransformer extends AbstractPhpSerializerEventTransformer implements EventTransformer
4236
{
43-
/**
44-
* {@inheritdoc}
45-
*/
4637
public function toMessage($eventName, ContractEvent $event = null)
4738
{
4839
return $this->context->createMessage(serialize($event));

pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function testShouldDispatchBothAsyncEventAndSyncOne()
104104
echo "Async event\n";
105105
});
106106

107-
$this->dispatch($this->dispatcher, new GenericEvent(),'test_async');
107+
$this->dispatch($this->dispatcher, new GenericEvent(), 'test_async');
108108
$this->processMessages();
109109

110110
$this->expectOutputString("Sync event\nSend message for event: test_async\nAsync event\n");
@@ -115,7 +115,7 @@ public function testShouldDispatchBothAsyncEventAndSyncOneFromWhenDispatchedFrom
115115
$this->dispatcher->addListener('foo', function ($event, $name, EventDispatcherInterface $dispatcher) {
116116
echo "Foo event\n";
117117

118-
$this->dispatch($dispatcher, new GenericEvent(),'test_async');
118+
$this->dispatch($dispatcher, new GenericEvent(), 'test_async');
119119
});
120120

121121
$this->dispatcher->addListener('test_async', function () {
@@ -128,7 +128,7 @@ public function testShouldDispatchBothAsyncEventAndSyncOneFromWhenDispatchedFrom
128128
echo "Async event\n";
129129
});
130130

131-
$this->dispatch($this->dispatcher, new GenericEvent(),'foo');
131+
$this->dispatch($this->dispatcher, new GenericEvent(), 'foo');
132132

133133
$this->processMessages();
134134

@@ -143,14 +143,14 @@ public function testShouldDispatchOtherAsyncEventFromAsyncEvent()
143143
$this->asyncDispatcher->addListener('test_async', function ($event, $eventName, EventDispatcherInterface $dispatcher) {
144144
echo "Async event\n";
145145

146-
$this->dispatch($dispatcher, new GenericEvent(),'test_async_from_async');
146+
$this->dispatch($dispatcher, new GenericEvent(), 'test_async_from_async');
147147
});
148148

149149
$this->dispatcher->addListener('test_async_from_async', function ($event, $eventName, EventDispatcherInterface $dispatcher) {
150150
echo "Async event from event\n";
151151
});
152152

153-
$this->dispatch($this->dispatcher, new GenericEvent(),'test_async');
153+
$this->dispatch($this->dispatcher, new GenericEvent(), 'test_async');
154154

155155
$this->processMessages();
156156
$this->processMessages();
@@ -169,10 +169,10 @@ public function testShouldDispatchSyncListenerIfDispatchedFromAsycListner()
169169
$this->asyncDispatcher->addListener('test_async', function ($event, $eventName, EventDispatcherInterface $dispatcher) {
170170
echo "Async event\n";
171171

172-
$this->dispatch($dispatcher, new GenericEvent(),'sync');
172+
$this->dispatch($dispatcher, new GenericEvent(), 'sync');
173173
});
174174

175-
$this->dispatch($this->dispatcher, new GenericEvent(),'test_async');
175+
$this->dispatch($this->dispatcher, new GenericEvent(), 'test_async');
176176

177177
$this->processMessages();
178178

pkg/async-event-dispatcher/Tests/ProxyEventDispatcherTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Symfony\Component\EventDispatcher\Event;
1111
use Symfony\Component\EventDispatcher\EventDispatcher;
1212
use Symfony\Component\EventDispatcher\GenericEvent;
13-
use Symfony\Component\HttpKernel\Kernel;
1413

1514
class ProxyEventDispatcherTest extends TestCase
1615
{

pkg/enqueue-bundle/Consumption/Extension/DoctrinePingConnectionExtension.php

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ class DoctrinePingConnectionExtension implements MessageReceivedExtensionInterfa
1414
*/
1515
protected $registry;
1616

17-
/**
18-
* @param ManagerRegistry $registry
19-
*/
2017
public function __construct(ManagerRegistry $registry)
2118
{
2219
$this->registry = $registry;

pkg/enqueue-bundle/Profiler/AbstractMessageQueueCollector.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@ public function addProducer(string $name, ProducerInterface $producer): void
2222
$this->producers[$name] = $producer;
2323
}
2424

25-
protected function collectInternal(Request $request, Response $response): void
26-
{
27-
$this->data = [];
28-
29-
foreach ($this->producers as $name => $producer) {
30-
if ($producer instanceof TraceableProducer) {
31-
$this->data[$name] = $producer->getTraces();
32-
}
33-
}
34-
}
35-
3625
public function getCount(): int
3726
{
3827
$count = 0;
@@ -94,4 +83,15 @@ public function reset()
9483
{
9584
$this->data = [];
9685
}
86+
87+
protected function collectInternal(Request $request, Response $response): void
88+
{
89+
$this->data = [];
90+
91+
foreach ($this->producers as $name => $producer) {
92+
if ($producer instanceof TraceableProducer) {
93+
$this->data[$name] = $producer->getTraces();
94+
}
95+
}
96+
}
9797
}

pkg/enqueue-bundle/Tests/Functional/App/AbstractAsyncListener.php

-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ abstract class AbstractAsyncListener extends \Enqueue\AsyncEventDispatcher\Async
2121
*/
2222
protected $registry;
2323

24-
/**
25-
* @param ProducerInterface $producer
26-
* @param Registry $registry
27-
*/
2824
public function __construct(ProducerInterface $producer, Registry $registry)
2925
{
3026
$this->producer = $producer;

0 commit comments

Comments
 (0)