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 |
||
7 | class ZmqDealer extends ZmqModel implements ModelInterface |
||
8 | { |
||
9 | /** |
||
10 | * @return int |
||
11 | */ |
||
12 | protected function getSocketType() |
||
16 | |||
17 | /** |
||
18 | * @param string[] $multipartMessage |
||
19 | * @return string[] |
||
|
|||
20 | */ |
||
21 | View Code Duplication | protected function parseBinderMessage($multipartMessage) |
|
29 | |||
30 | /** |
||
31 | * @param string[] $multipartMessage |
||
32 | * @return string[] |
||
33 | */ |
||
34 | View Code Duplication | protected function parseConnectorMessage($multipartMessage) |
|
42 | |||
43 | /** |
||
44 | * @param string $id |
||
45 | * @param string $type |
||
46 | * @return string[] |
||
47 | */ |
||
48 | protected function prepareBinderMessage($id, $type) |
||
52 | |||
53 | /** |
||
54 | * @param string $id |
||
55 | * @param string $type |
||
56 | * @return string[] |
||
57 | */ |
||
58 | protected function prepareConnectorMessage($id, $type) |
||
62 | } |
||
63 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.