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 |
||
| 20 | class StopwatchHttpAdapter extends PsrHttpAdapterDecorator |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var Stopwatch\Stopwatch |
||
| 24 | */ |
||
| 25 | private $stopwatch; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @param HttpAdapterInterface $httpAdapter |
||
| 29 | * @param Stopwatch $stopwatch |
||
| 30 | */ |
||
| 31 | 45 | public function __construct(HttpAdapterInterface $httpAdapter, Stopwatch $stopwatch) |
|
| 37 | |||
| 38 | /** |
||
| 39 | * {@inheritdoc} |
||
| 40 | */ |
||
| 41 | 18 | View Code Duplication | protected function doSendInternalRequest(InternalRequestInterface $internalRequest) |
| 57 | |||
| 58 | /** |
||
| 59 | * {@inheritdoc} |
||
| 60 | */ |
||
| 61 | 18 | View Code Duplication | protected function doSendInternalRequests(array $internalRequests) |
| 77 | } |
||
| 78 |
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..