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 |
||
26 | View Code Duplication | class TextMessage extends Response |
|
27 | { |
||
28 | /** |
||
29 | * @var string The text of the message. |
||
30 | */ |
||
31 | private $body; |
||
32 | |||
33 | /** |
||
34 | * @var string A technology specific URI specifying the source of the message. For sip and pjsip technologies, any SIP URI can be specified. For xmpp, the URI must correspond to the client connection being used to send the message. |
||
35 | */ |
||
36 | private $from; |
||
37 | |||
38 | /** |
||
39 | * @var string A technology specific URI specifying the destination of the message. Valid technologies include sip, pjsip, and xmp. The destination of a message should be an endpoint. |
||
40 | */ |
||
41 | private $to; |
||
42 | |||
43 | /** |
||
44 | * @var array (optional) - Technology specific key/value pairs associated with the message. |
||
45 | */ |
||
46 | private $variables; |
||
47 | |||
48 | /** |
||
49 | * @return string The text of the message. |
||
50 | */ |
||
51 | public function getBody() |
||
55 | |||
56 | /** |
||
57 | * @return string A technology specific URI specifying the source of the message. For sip and pjsip technologies, any SIP URI can be specified. For xmpp, the URI must correspond to the client connection being used to send the message. |
||
58 | */ |
||
59 | public function getFrom() |
||
63 | |||
64 | /** |
||
65 | * @return string A technology specific URI specifying the destination of the message. Valid technologies include sip, pjsip, and xmp. The destination of a message should be an endpoint. |
||
66 | */ |
||
67 | public function getTo() |
||
71 | |||
72 | /** |
||
73 | * @return TextMessageVariable[] (optional) - Technology specific key/value pairs associated with the message. |
||
74 | */ |
||
75 | public function getVariables() |
||
79 | |||
80 | /** |
||
81 | * @param string $response |
||
82 | */ |
||
83 | public function __construct($response) |
||
92 | |||
93 | } |
||
94 |
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..