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); |
||
| 10 | final class ReadableStreamHash extends EventEmitter implements ReadableStreamInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var WritableStreamInterface |
||
| 14 | */ |
||
| 15 | private $stream; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var resource |
||
| 19 | */ |
||
| 20 | private $context; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param ReadableStreamInterface $stream |
||
| 24 | * @param string $algo |
||
| 25 | * @param string|null $key |
||
| 26 | */ |
||
| 27 | 368 | public function __construct(ReadableStreamInterface $stream, string $algo, string $key = null) |
|
| 58 | |||
| 59 | 368 | public function isReadable() |
|
| 63 | |||
| 64 | public function pause() |
||
| 68 | |||
| 69 | public function resume() |
||
| 73 | |||
| 74 | public function pipe(WritableStreamInterface $dest, array $options = []) |
||
| 78 | |||
| 79 | public function close() |
||
| 83 | } |
||
| 84 |
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..