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 |
||
| 11 | View Code Duplication | class UpdateTask extends BaseTask |
|
| 12 | { |
||
| 13 | /** |
||
| 14 | * Update a task. |
||
| 15 | * |
||
| 16 | * @param Request $request |
||
| 17 | * @param Response $response |
||
| 18 | * @param array $args |
||
| 19 | * @return array |
||
| 20 | */ |
||
| 21 | public function __invoke($request, $response, $args) |
||
| 33 | } |
||
| 34 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.