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 |
||
| 8 | class SlotManager extends ManagerBase |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Get a list of slots. |
||
| 12 | * |
||
| 13 | * Example of how to structure the $options parameter: |
||
| 14 | * <code> |
||
| 15 | * $options = [ |
||
| 16 | * 'visible_on_page' => 'http://localhost/blog/*', |
||
| 17 | * 'status' => 'enabled', |
||
| 18 | * ]; |
||
| 19 | * </code> |
||
| 20 | * |
||
| 21 | * @see http://docs.decision-api.acquia.com/#slots_get |
||
| 22 | * |
||
| 23 | * @param array $options |
||
| 24 | * |
||
| 25 | * @return \Acquia\LiftClient\Entity\Slot[] |
||
| 26 | * |
||
| 27 | * @throws \GuzzleHttp\Exception\RequestException |
||
| 28 | */ |
||
| 29 | public function query($options = []) |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Get a specific slot. |
||
| 55 | * |
||
| 56 | * Example of how to structure the $options parameter: |
||
| 57 | * |
||
| 58 | * @see http://docs.decision-api.acquia.com/#slots__slotId__get |
||
| 59 | * |
||
| 60 | * @param array $options |
||
|
|
|||
| 61 | * |
||
| 62 | * @return \Acquia\LiftClient\Entity\Slot |
||
| 63 | * |
||
| 64 | * @throws \GuzzleHttp\Exception\RequestException |
||
| 65 | */ |
||
| 66 | View Code Duplication | public function get( |
|
| 77 | |||
| 78 | /** |
||
| 79 | * Add a slot. |
||
| 80 | * |
||
| 81 | * @param \Acquia\LiftClient\Entity\Slot $slot |
||
| 82 | * |
||
| 83 | * @return \Acquia\LiftClient\Entity\Slot |
||
| 84 | * |
||
| 85 | * @throws \GuzzleHttp\Exception\RequestException |
||
| 86 | */ |
||
| 87 | View Code Duplication | public function add( |
|
| 97 | |||
| 98 | /** |
||
| 99 | * Deletes a slot by ID. |
||
| 100 | * |
||
| 101 | * @param string $id |
||
| 102 | * |
||
| 103 | * @return bool |
||
| 104 | * returns TRUE if successful |
||
| 105 | * |
||
| 106 | * @throws \GuzzleHttp\Exception\RequestException |
||
| 107 | */ |
||
| 108 | public function delete( |
||
| 116 | } |
||
| 117 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.