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 |
||
| 18 | class InvalidRecaptcha extends \InvalidArgumentException implements Exception { |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Create a new instance of the exception for a field class name that is |
||
| 22 | * not recognized. |
||
| 23 | * |
||
| 24 | * @since %VERSION% |
||
| 25 | * |
||
| 26 | * @param string $field Class name of the service that was not recognized. |
||
|
|
|||
| 27 | * |
||
| 28 | * @return static |
||
| 29 | */ |
||
| 30 | View Code Duplication | public static function from_site_key() { |
|
| 37 | |||
| 38 | /** |
||
| 39 | * Create a new instance of the exception for a field class name that is |
||
| 40 | * not recognized. |
||
| 41 | * |
||
| 42 | * @since %VERSION% |
||
| 43 | * |
||
| 44 | * @param string $field Class name of the service that was not recognized. |
||
| 45 | * |
||
| 46 | * @return static |
||
| 47 | */ |
||
| 48 | View Code Duplication | public static function from_secret_key() { |
|
| 55 | |||
| 56 | } |
||
| 57 |
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.