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 |
||
| 12 | class Installer implements InstallerContract |
||
| 13 | { |
||
| 14 | protected $honeybadger; |
||
| 15 | |||
| 16 | public function __construct(Honeybadger $honeybadger) |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Write the configurations to dotenv files. |
||
| 23 | * |
||
| 24 | * @param array $config |
||
| 25 | * @param string $file |
||
|
|
|||
| 26 | * @return bool |
||
| 27 | */ |
||
| 28 | public function writeConfig(array $config, string $filePath) : bool |
||
| 43 | |||
| 44 | public function sendTestException() : array |
||
| 48 | |||
| 49 | public function publishLaravelConfig() : bool |
||
| 55 | |||
| 56 | View Code Duplication | public function publishLumenConfig(): bool |
|
| 67 | } |
||
| 68 |
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.