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 |
||
20 | final class PHPCRPagerProvider implements PagerProviderInterface |
||
21 | { |
||
22 | const ENTITY_ALIAS = 'a'; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | private $objectClass; |
||
28 | |||
29 | /** |
||
30 | * @var ManagerRegistry |
||
31 | */ |
||
32 | private $doctrine; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | private $baseOptions; |
||
38 | |||
39 | /** |
||
40 | * @var RegisterListenersService |
||
41 | */ |
||
42 | private $registerListenersService; |
||
43 | |||
44 | /** |
||
45 | * @param ManagerRegistry $doctrine |
||
46 | * @param RegisterListenersService $registerListenersService |
||
47 | * @param string $objectClass |
||
48 | * @param array $baseOptions |
||
49 | */ |
||
50 | View Code Duplication | public function __construct(ManagerRegistry $doctrine, RegisterListenersService $registerListenersService, $objectClass, array $baseOptions) |
|
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | View Code Duplication | public function provide(array $options = array()) |
|
78 | } |
||
79 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: