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); |
||
| 45 | class GlobalScaleController extends BaseController { |
||
| 46 | |||
| 47 | |||
| 48 | use TStringTools; |
||
| 49 | use TAsync; |
||
| 50 | |||
| 51 | |||
| 52 | /** |
||
| 53 | * @PublicPage |
||
| 54 | * @NoCSRFRequired |
||
| 55 | * |
||
| 56 | * @param string $data |
||
|
|
|||
| 57 | * |
||
| 58 | * @return DataResponse |
||
| 59 | */ |
||
| 60 | View Code Duplication | public function event(): DataResponse { |
|
| 74 | |||
| 75 | |||
| 76 | /** |
||
| 77 | * @PublicPage |
||
| 78 | * @NoCSRFRequired |
||
| 79 | * |
||
| 80 | * @param string $token |
||
| 81 | * |
||
| 82 | * @return DataResponse |
||
| 83 | */ |
||
| 84 | public function asyncBroadcast(string $token): DataResponse { |
||
| 97 | |||
| 98 | |||
| 99 | /** |
||
| 100 | * @PublicPage |
||
| 101 | * @NoCSRFRequired |
||
| 102 | * |
||
| 103 | * @param string $data |
||
| 104 | * |
||
| 105 | * @return DataResponse |
||
| 106 | */ |
||
| 107 | View Code Duplication | public function broadcast(): DataResponse { |
|
| 121 | |||
| 122 | } |
||
| 123 | |||
| 124 |
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.