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) |
|
70 | |||
71 | /** |
||
72 | * Get all mail items in the inbox |
||
73 | * |
||
74 | * @param Type\BaseFolderIdType $folderId |
||
75 | * @param array $options |
||
76 | * @return Type\MessageType[] |
||
77 | */ |
||
78 | 7 | public function getMailItems($folderId = null, $options = array()) |
|
101 | |||
102 | /** |
||
103 | * @param Type\BaseFolderIdType $folderId |
||
104 | * @param array $options |
||
105 | * @return Type\MessageType[] |
||
106 | */ |
||
107 | 1 | public function getUnreadMailItems($folderId = null, $options = array()) |
|
121 | |||
122 | /** |
||
123 | * Updates a calendar item with changes |
||
124 | * |
||
125 | * @param $itemId Type\ItemIdType|Type |
||
126 | * @param $changes |
||
127 | * @return Type\MessageType[] |
||
128 | */ |
||
129 | 1 | View Code Duplication | public function updateMailItem($itemId, $changes) |
147 | |||
148 | /** |
||
149 | * @param $mailItem Type\MessageType|Type\ItemIdType |
||
150 | * @param $isRead boolean |
||
151 | */ |
||
152 | 1 | public function markMailAsRead($mailItem, $isRead = true) |
|
162 | |||
163 | 3 | public function sendMail(MessageType $message, $options = array()) |
|
179 | |||
180 | public function getAttachment(Type\AttachmentIdType $attachmentId) |
||
194 | |||
195 | /** |
||
196 | * @param array $options |
||
197 | * @return API\Message\EmptyFolderResponseType |
||
198 | */ |
||
199 | public function emptyTrash(array $options = []) |
||
208 | } |
||
209 |
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..