Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php declare(strict_types = 1); |
||
16 | final class PushEventThroughQueueWithCommandId implements EventListener |
||
17 | { |
||
18 | /** @var Queue */ |
||
19 | private $queue; |
||
20 | |||
21 | /** @var Serializer */ |
||
22 | private $serializer; |
||
23 | |||
24 | /** @var NotificationsCommandBus */ |
||
25 | private $notificationsCommandBus; |
||
26 | |||
27 | /** |
||
28 | * PushEventsThroughQueue constructor. |
||
29 | * @param Queue $queue |
||
30 | * @param Serializer $serializer |
||
31 | * @param StrongConsistencyCommandBus|CommandBus $notificationsCommandBus |
||
32 | */ |
||
33 | public function __construct(Queue $queue, Serializer $serializer, CommandBus $notificationsCommandBus) |
||
39 | |||
40 | /** |
||
41 | * @param DomainMessage $domainMessage |
||
42 | * @return void |
||
43 | */ |
||
44 | View Code Duplication | public function handle(DomainMessage $domainMessage) |
|
59 | } |
||
60 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..