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 |
||
11 | abstract class ActionSearchAbstract extends MiddlewareAbstract |
||
12 | { |
||
13 | /** |
||
14 | * @var ResourceDO |
||
15 | */ |
||
16 | protected $resourceDO; |
||
17 | |||
18 | /** |
||
19 | * Search provider |
||
20 | * @var mixed |
||
21 | */ |
||
22 | protected $searcher; |
||
23 | |||
24 | public function __construct( |
||
30 | |||
31 | /** |
||
32 | * @param ServerRequestInterface $request |
||
33 | * @param ResponseInterface $response |
||
34 | * @param callable|null $next |
||
35 | * @return EmptyResponse |
||
36 | * @throws \Exception |
||
37 | */ |
||
38 | View Code Duplication | public function __invoke( |
|
49 | |||
50 | abstract protected function search(ResourceDOInterface $resourceDO); |
||
51 | |||
52 | protected function action() |
||
58 | } |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.