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 |
||
| 17 | class MimePartFactory extends MessagePartFactory |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var \ZBateson\MailMimeParser\Header\HeaderFactory the HeaderFactory |
||
| 21 | * instance |
||
| 22 | */ |
||
| 23 | protected $headerFactory; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var \ZBateson\MailMimeParser\Header\HeaderFactory the PartFilterFactory |
||
| 27 | * instance |
||
| 28 | */ |
||
| 29 | protected $partFilterFactory; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Creates a MimePartFactory instance with its dependencies. |
||
| 33 | * |
||
| 34 | * @param PartStreamFilterManagerFactory $psf |
||
| 35 | * @param HeaderFactory $hf |
||
| 36 | * @param PartFilterFactory $pf |
||
| 37 | */ |
||
| 38 | public function __construct(PartStreamFilterManagerFactory $psf, HeaderFactory $hf, PartFilterFactory $pf) |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Returns the singleton instance for the class. |
||
| 47 | * |
||
| 48 | * @param PartStreamFilterManagerFactory $psf |
||
| 49 | * @param HeaderFactory $hf |
||
| 50 | * @param PartFilterFactory $pf |
||
| 51 | * @return MimePartFactory |
||
| 52 | */ |
||
| 53 | View Code Duplication | public static function getInstance( |
|
| 65 | |||
| 66 | /** |
||
| 67 | * Constructs a new MimePart object and returns it |
||
| 68 | * |
||
| 69 | * @param string $messageObjectId |
||
| 70 | * @param PartBuilder $partBuilder |
||
| 71 | * @return \ZBateson\MailMimeParser\Message\Part\MimePart |
||
| 72 | */ |
||
| 73 | public function newInstance($messageObjectId, PartBuilder $partBuilder) |
||
| 83 | } |
||
| 84 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..