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 |
||
16 | class Builder |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $root; |
||
23 | |||
24 | /** |
||
25 | * Builder constructor. |
||
26 | * |
||
27 | * @param string $root |
||
28 | */ |
||
29 | 8 | public function __construct(string $root) |
|
33 | |||
34 | /** |
||
35 | * @return Config |
||
36 | */ |
||
37 | public function config(): Config |
||
43 | |||
44 | /** |
||
45 | * @return Router |
||
46 | */ |
||
47 | public function router(): Router |
||
53 | |||
54 | /** |
||
55 | * @return ServerRequestInterface |
||
56 | */ |
||
57 | 1 | private function _request(): ServerRequestInterface |
|
79 | |||
80 | /** |
||
81 | * @return ServerRequestInterface |
||
82 | */ |
||
83 | public function request(): ServerRequestInterface |
||
109 | |||
110 | /** |
||
111 | * @return Session |
||
112 | */ |
||
113 | View Code Duplication | public function session(): Session |
|
124 | |||
125 | /** |
||
126 | * @return Cookies |
||
127 | */ |
||
128 | View Code Duplication | public function cookies(): Cookies |
|
139 | |||
140 | /** |
||
141 | * @return Factory |
||
142 | */ |
||
143 | public function factory(): Factory |
||
149 | |||
150 | /** |
||
151 | * @return Flow |
||
152 | */ |
||
153 | public function flow(): Flow |
||
159 | |||
160 | } |
||
161 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.