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 |
||
15 | class EE_Vsprintf_Layout extends EE_No_Layout |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * Will hold the incoming format string to be used for the vsprintf first argument. |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $_v_format = ''; |
||
23 | |||
24 | |||
25 | |||
26 | /** |
||
27 | * EE_Vsprintf_Layout constructor. |
||
28 | * |
||
29 | * @param array $options Expects an array with 'vsprintf_format' as a key to represent the format argument that |
||
30 | * will be passed to the vsprintf function. Make sure the number of placeholders matches |
||
31 | * the number of subsections in your form. |
||
32 | */ |
||
33 | public function __construct($options = array()) |
||
40 | |||
41 | |||
42 | |||
43 | public function layout_form_loop() |
||
65 | |||
66 | |||
67 | |||
68 | } |
||
69 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.