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 |
||
| 8 | class UnifiedAccount implements IAccount { |
||
| 9 | |||
| 10 | const ID = -1; |
||
| 11 | const INBOX_ID = 'all-inboxes'; |
||
| 12 | |||
| 13 | /** @var AccountService */ |
||
| 14 | private $accountService; |
||
| 15 | |||
| 16 | /** @var string */ |
||
| 17 | private $userId; |
||
| 18 | |||
| 19 | /** @var IL10N */ |
||
| 20 | private $l10n; |
||
| 21 | |||
| 22 | /** @var Horde_Mail_Rfc822_List */ |
||
| 23 | private $email; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param AccountService $accountService |
||
| 27 | * @param string $userId |
||
| 28 | * @param IL10N $l10n |
||
| 29 | */ |
||
| 30 | 1 | public function __construct(AccountService $accountService, $userId, IL10N $l10n) { |
|
| 35 | |||
| 36 | /** |
||
| 37 | * @return array |
||
| 38 | */ |
||
| 39 | public function getConfiguration() { |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @return array |
||
| 47 | * TODO: function name is :hankey: |
||
| 48 | */ |
||
| 49 | public function getListArray() { |
||
| 59 | |||
| 60 | private function buildInbox() { |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @param $folderId |
||
| 100 | * @return IMailBox |
||
| 101 | */ |
||
| 102 | public function getMailbox($folderId) { |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @return string |
||
| 108 | */ |
||
| 109 | public function getEmail() { |
||
| 124 | |||
| 125 | /** |
||
| 126 | * @param IMessage $message |
||
| 127 | * @param int|null $draftUID |
||
| 128 | */ |
||
| 129 | public function sendMessage(IMessage $message, $draftUID) { |
||
| 132 | |||
| 133 | /** |
||
| 134 | * @param IMessage $message |
||
| 135 | * @param int|null $previousUID |
||
| 136 | * @return int |
||
| 137 | */ |
||
| 138 | public function saveDraft(IMessage $message, $previousUID) { |
||
| 141 | |||
| 142 | /** |
||
| 143 | * @param string $folderId |
||
| 144 | * @param string $messageId |
||
| 145 | */ |
||
| 146 | public function deleteMessage($folderId, $messageId) { |
||
| 154 | |||
| 155 | /** |
||
| 156 | * @param string[] $query |
||
| 157 | * @return array |
||
| 158 | */ |
||
| 159 | public function getChangedMailboxes($query) { |
||
| 192 | |||
| 193 | /** |
||
| 194 | * @return IMailBox |
||
| 195 | */ |
||
| 196 | public function getInbox() { |
||
| 199 | |||
| 200 | /** |
||
| 201 | * @return int |
||
| 202 | */ |
||
| 203 | public function getId() { |
||
| 206 | |||
| 207 | /** |
||
| 208 | * @param $messageId |
||
| 209 | * @return array |
||
| 210 | */ |
||
| 211 | View Code Duplication | public function resolve($messageId) { |
|
| 219 | } |
||
| 220 |
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..