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 |
||
14 | abstract class AbstractContent |
||
15 | { |
||
16 | |||
17 | private static $opts = array ( |
||
18 | 'http' => array ( |
||
19 | 'method' => 'GET' , |
||
20 | 'header' => array ( |
||
21 | 'User-Agent: PHP' |
||
22 | ) |
||
23 | ) |
||
24 | ); |
||
25 | |||
26 | /** |
||
27 | * @type \Classes\Update\ProtocolFileContent |
||
28 | */ |
||
29 | protected $objProtocol; |
||
30 | /** |
||
31 | * @type Content |
||
32 | */ |
||
33 | private static $objContent; |
||
34 | |||
35 | /** |
||
36 | * @type array |
||
37 | */ |
||
38 | private $content = array (); |
||
39 | |||
40 | protected function __construct () |
||
45 | |||
46 | protected function init (){ } |
||
47 | |||
48 | /** |
||
49 | * @return \Classes\Update\Content |
||
50 | */ |
||
51 | public static function getInstance () |
||
60 | |||
61 | /** |
||
62 | * @param $url |
||
63 | * |
||
64 | * @return string |
||
65 | */ |
||
66 | public function getContent ( $url , $progress = false ) |
||
87 | |||
88 | /** |
||
89 | * @param $url |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | protected function getCurlContent ( $url , $progress = false ) |
||
111 | |||
112 | /** |
||
113 | * @param $url |
||
114 | * |
||
115 | * @return string |
||
116 | */ |
||
117 | View Code Duplication | protected function getFileContent ( $url , $progress = false ) |
|
131 | |||
132 | /** |
||
133 | * @param $url |
||
134 | * |
||
135 | * @return string |
||
136 | */ |
||
137 | View Code Duplication | protected function getStreamContent ( $url , $progress = false ) |
|
153 | |||
154 | public function putContent ( $url , $content ) |
||
168 | |||
169 | public function putFileContent ( $url , $content ) |
||
177 | |||
178 | public function putFopen ( $url , $content ) |
||
184 | |||
185 | /** |
||
186 | * Stream downloading |
||
187 | * |
||
188 | * @param $notification_code |
||
189 | * @param $severity |
||
190 | * @param $message |
||
191 | * @param $message_code |
||
192 | * @param $bytes_transferred |
||
193 | * @param $bytes_max |
||
194 | */ |
||
195 | public function stream_notification_callback ( $notificationCode , $severity , $message , $messageCode , $bytesTransferred , $bytesMax ) |
||
226 | |||
227 | function progressCallback ( $download_size , $downloaded_size , $upload_size , $uploaded_size ) |
||
237 | |||
238 | } |
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..