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 |
||
| 9 | class MailAPI extends API |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var Type\BaseFolderIdType |
||
| 13 | */ |
||
| 14 | protected $folderId; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @return Type\BaseFolderIdType |
||
| 18 | */ |
||
| 19 | 7 | public function getFolderId() |
|
| 27 | |||
| 28 | /** |
||
| 29 | * @param Type\BaseFolderIdType $folderId |
||
| 30 | */ |
||
| 31 | 1 | public function setFolderId($folderId) |
|
| 35 | |||
| 36 | /** |
||
| 37 | * @param string $displayName |
||
| 38 | * @param string|Type\BaseFolderIdType $parentFolder |
||
| 39 | */ |
||
| 40 | 7 | public function pickMailFolder($displayName = null, $parentFolder = 'inbox') |
|
| 50 | |||
| 51 | 1 | protected function formatRestrictions($restrictions) |
|
| 55 | |||
| 56 | /** |
||
| 57 | * Get all mail items in the inbox |
||
| 58 | * |
||
| 59 | * @param Type\BaseFolderIdType $folderId |
||
| 60 | * @param array $options |
||
| 61 | * @return Type\MessageType[] |
||
| 62 | */ |
||
| 63 | 7 | public function getMailItems($folderId = null, $options = array()) |
|
| 86 | |||
| 87 | /** |
||
| 88 | * @param Type\BaseFolderIdType $folderId |
||
| 89 | * @param array $options |
||
| 90 | * @return Type\MessageType[] |
||
| 91 | */ |
||
| 92 | 3 | public function getUnreadMailItems($folderId = null, $options = array()) |
|
| 106 | |||
| 107 | /** |
||
| 108 | * Updates a calendar item with changes |
||
| 109 | * |
||
| 110 | * @param $itemId Type\ItemIdType|Type |
||
| 111 | * @param $changes |
||
| 112 | * @param array $options |
||
| 113 | * @return Type\MessageType[] |
||
| 114 | */ |
||
| 115 | 1 | View Code Duplication | public function updateMailItem($itemId, $changes, $options = []) |
| 133 | |||
| 134 | /** |
||
| 135 | * @param $mailItem Type\MessageType|Type\ItemIdType |
||
| 136 | * @param $isRead boolean |
||
| 137 | */ |
||
| 138 | 1 | public function markMailAsRead($mailItem, $isRead = true) |
|
| 148 | |||
| 149 | 3 | public function sendMail(MessageType $message, $options = array()) |
|
| 165 | |||
| 166 | public function getAttachment(Type\AttachmentIdType $attachmentId, $options = []) |
||
| 181 | |||
| 182 | /** |
||
| 183 | * @param array $options |
||
| 184 | * @return API\Message\EmptyFolderResponseType |
||
| 185 | */ |
||
| 186 | public function emptyTrash(array $options = []) |
||
| 195 | } |
||
| 196 |
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..