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); |
||
| 17 | final class PushEventThroughQueueWithCommandId implements EventListener |
||
| 18 | { |
||
| 19 | /** @var Queue */ |
||
| 20 | private $queue; |
||
| 21 | |||
| 22 | /** @var Serializer */ |
||
| 23 | private $serializer; |
||
| 24 | |||
| 25 | /** @var NotificationsCommandBus */ |
||
| 26 | private $notificationsCommandBus; |
||
| 27 | /** @var Repository */ |
||
| 28 | private $config; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * PushEventsThroughQueue constructor. |
||
| 32 | * @param Queue $queue |
||
| 33 | * @param Serializer $serializer |
||
| 34 | * @param StrongConsistencyCommandBusMiddleware|CommandBus $notificationsCommandBus |
||
| 35 | * @param Repository $config |
||
| 36 | */ |
||
| 37 | public function __construct( |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @param DomainMessage $domainMessage |
||
| 51 | * @return void |
||
| 52 | */ |
||
| 53 | View Code Duplication | public function handle(DomainMessage $domainMessage) |
|
| 69 | } |
||
| 70 |
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..