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 |
||
| 9 | class PhpMdToolProcessor implements PhpMdToolProcessorInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var ToolPathFinder |
||
| 13 | */ |
||
| 14 | private $toolPathFinder; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * PhpMdToolProcessor constructor. |
||
| 18 | * |
||
| 19 | * @param ToolPathFinder $toolPathFinder |
||
| 20 | */ |
||
| 21 | public function __construct(ToolPathFinder $toolPathFinder) |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @param string $file |
||
| 28 | * @param string $options |
||
| 29 | * |
||
| 30 | * @return string |
||
| 31 | */ |
||
| 32 | public function process($file, $options) |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param string $file |
||
| 41 | * @param string $options |
||
| 42 | * |
||
| 43 | * @return Process |
||
| 44 | */ |
||
| 45 | private function execute($file, $options) |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @param Process $process |
||
| 57 | * |
||
| 58 | * @return null|string |
||
| 59 | * |
||
| 60 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
| 61 | */ |
||
| 62 | View Code Duplication | private function setError(Process $process) |
|
| 70 | } |
||
| 71 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: