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 | abstract class AbstractProvider implements EmailDataProviderInterface |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | protected $configResolver; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var \eZ\Publish\Core\Helper\TranslationHelper |
||
| 21 | */ |
||
| 22 | protected $translationHelper; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var \eZ\Publish\Core\Helper\FieldHelper |
||
| 26 | */ |
||
| 27 | protected $fieldHelper; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var \Twig\Environment |
||
| 31 | */ |
||
| 32 | protected $twig; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * EmailDataFactory constructor. |
||
| 36 | * |
||
| 37 | * @param array $config |
||
|
|
|||
| 38 | * @param \eZ\Publish\Core\Helper\TranslationHelper $translationHelper |
||
| 39 | * @param \eZ\Publish\Core\Helper\FieldHelper $fieldHelper |
||
| 40 | * @param \Twig\Environment $twig |
||
| 41 | */ |
||
| 42 | View Code Duplication | public function __construct( |
|
| 54 | } |
||
| 55 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.