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 |
||
29 | class Application extends Resource |
||
30 | { |
||
31 | /** |
||
32 | * @var array Id's for bridges subscribed to. |
||
33 | */ |
||
34 | private $bridgeIds; |
||
35 | |||
36 | /** |
||
37 | * @var array Id's for channels subscribed to. |
||
38 | */ |
||
39 | private $channelIds; |
||
40 | |||
41 | /** |
||
42 | * @var array Names of the devices subscribed to. |
||
43 | */ |
||
44 | private $deviceNames; |
||
45 | |||
46 | /** |
||
47 | * @var array {tech}/{resource} for endpoints subscribed to. |
||
48 | */ |
||
49 | private $endpointIds; |
||
50 | |||
51 | /** |
||
52 | * @var string Name of this application |
||
53 | */ |
||
54 | private $name; |
||
55 | |||
56 | /** |
||
57 | * @return array Id's for bridges subscribed to. |
||
58 | */ |
||
59 | public function getBridgeIds() |
||
63 | |||
64 | /** |
||
65 | * @return array Id's for channels subscribed to. |
||
66 | */ |
||
67 | public function getChannelIds() |
||
71 | |||
72 | /** |
||
73 | * @return array Names of the devices subscribed to. |
||
74 | */ |
||
75 | public function getDeviceNames() |
||
79 | |||
80 | /** |
||
81 | * @return array {tech}/{resource} for endpoints subscribed to. |
||
82 | */ |
||
83 | public function getEndpointIds() |
||
87 | |||
88 | /** |
||
89 | * @return string string Name of this application |
||
90 | */ |
||
91 | public function getName() |
||
95 | |||
96 | /** |
||
97 | * @param callable $callback |
||
98 | */ |
||
99 | public function onApplicationReplaced(callable $callback) |
||
103 | |||
104 | /** |
||
105 | * @param callable $callback |
||
106 | */ |
||
107 | public function onceApplicationReplaced(callable $callback) |
||
111 | |||
112 | /** |
||
113 | * @param AriClient $client |
||
114 | * @param string $response |
||
115 | */ |
||
116 | View Code Duplication | public function __construct(AriClient $client, $response) |
|
126 | |||
127 | } |
||
128 |
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..