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 |
||
9 | class CrawlerRobots |
||
10 | { |
||
11 | /** @var \Spatie\Robots\RobotsHeaders */ |
||
12 | protected $robotsHeaders; |
||
13 | |||
14 | /** @var \Spatie\Robots\RobotsMeta */ |
||
15 | protected $robotsMeta; |
||
16 | |||
17 | /** @var bool */ |
||
18 | protected $mustRespectRobots; |
||
19 | |||
20 | public function __construct(ResponseInterface $response, bool $mustRespectRobots) |
||
28 | |||
29 | View Code Duplication | public function mayIndex(): bool |
|
45 | |||
46 | View Code Duplication | public function mayFollow(): bool |
|
62 | } |
||
63 |
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..