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 |
||
13 | class DropboxAdapter extends AbstractAdapter |
||
14 | { |
||
15 | use NotSupportingVisibilityTrait; |
||
16 | |||
17 | /** @var \Spatie\FlysystemDropbox\DropboxClient */ |
||
18 | protected $client; |
||
19 | |||
20 | public function __construct(Client $client, string $prefix = null) |
||
26 | |||
27 | /** |
||
28 | * {@inheritdoc} |
||
29 | */ |
||
30 | public function write($path, $contents, Config $config) |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | public function writeStream($path, $resource, Config $config) |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | public function update($path, $contents, Config $config) |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | public function updateStream($path, $resource, Config $config) |
||
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | public function rename($path, $newPath): bool |
||
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | View Code Duplication | public function copy($path, $newpath): bool |
|
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function delete($path): bool |
||
108 | |||
109 | /** |
||
110 | * {@inheritdoc} |
||
111 | */ |
||
112 | public function deleteDir($dirname): bool |
||
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | View Code Duplication | public function createDir($dirname, Config $config) |
|
132 | |||
133 | /** |
||
134 | * {@inheritdoc} |
||
135 | */ |
||
136 | public function has($path) |
||
140 | |||
141 | /** |
||
142 | * {@inheritdoc} |
||
143 | */ |
||
144 | public function read($path) |
||
156 | |||
157 | /** |
||
158 | * {@inheritdoc} |
||
159 | */ |
||
160 | View Code Duplication | public function readStream($path) |
|
172 | |||
173 | /** |
||
174 | * {@inheritdoc} |
||
175 | */ |
||
176 | public function listContents($directory = '', $recursive = false): array |
||
192 | |||
193 | /** |
||
194 | * {@inheritdoc} |
||
195 | */ |
||
196 | View Code Duplication | public function getMetadata($path) |
|
208 | |||
209 | /** |
||
210 | * {@inheritdoc} |
||
211 | */ |
||
212 | public function getSize($path) |
||
216 | |||
217 | /** |
||
218 | * {@inheritdoc} |
||
219 | */ |
||
220 | public function getMimetype($path) |
||
224 | |||
225 | /** |
||
226 | * {@inheritdoc} |
||
227 | */ |
||
228 | public function getTimestamp($path) |
||
232 | |||
233 | public function getTemporaryLink(string $path): string |
||
237 | |||
238 | public function getThumbnail(string $path, string $format = 'jpeg', string $size = 'w64h64') |
||
242 | |||
243 | /** |
||
244 | * {@inheritdoc} |
||
245 | */ |
||
246 | public function applyPathPrefix($path): string |
||
252 | |||
253 | public function getClient(): Client |
||
257 | |||
258 | /** |
||
259 | * @param string $path |
||
260 | * @param resource|string $contents |
||
261 | * @param string $mode |
||
262 | * |
||
263 | * @return array|false file metadata |
||
264 | */ |
||
265 | View Code Duplication | protected function upload(string $path, $contents, string $mode) |
|
277 | |||
278 | protected function normalizeResponse(array $response): array |
||
297 | } |
||
298 |
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..