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 |
||
| 10 | class BrowserConsoleLoggerServiceProvider implements ServiceProviderInterface |
||
| 11 | { |
||
| 12 | |||
| 13 | |||
| 14 | /** |
||
| 15 | * @var int |
||
| 16 | */ |
||
| 17 | public $loglevel = Logger::INFO; |
||
| 18 | |||
| 19 | |||
| 20 | /** |
||
| 21 | * @param string $incoming_webook_url [description] |
||
|
|
|||
| 22 | * @param int|null $loglevel [description] |
||
| 23 | */ |
||
| 24 | 2 | public function __construct(int $loglevel = null) |
|
| 30 | |||
| 31 | |||
| 32 | /** |
||
| 33 | * @param Container $dic [description] |
||
| 34 | * @return void |
||
| 35 | */ |
||
| 36 | 2 | View Code Duplication | public function register(Container $dic) |
| 66 | } |
||
| 67 |
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.