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 acf_field_text extends acf_field { |
||
17 | |||
18 | |||
19 | /* |
||
20 | * __construct |
||
21 | * |
||
22 | * This function will setup the field type data |
||
23 | * |
||
24 | * @type function |
||
25 | * @date 5/03/2014 |
||
26 | * @since 5.0.0 |
||
27 | * |
||
28 | * @param n/a |
||
29 | * @return n/a |
||
30 | */ |
||
|
|||
31 | |||
32 | View Code Duplication | function __construct() { |
|
51 | |||
52 | |||
53 | /* |
||
54 | * render_field() |
||
55 | * |
||
56 | * Create the HTML interface for your field |
||
57 | * |
||
58 | * @param $field - an array holding all the field's data |
||
59 | * |
||
60 | * @type action |
||
61 | * @since 3.6 |
||
62 | * @date 23/01/13 |
||
63 | */ |
||
64 | |||
65 | function render_field( $field ) { |
||
129 | |||
130 | |||
131 | /* |
||
132 | * render_field_settings() |
||
133 | * |
||
134 | * Create extra options for your field. This is rendered when editing a field. |
||
135 | * The value of $field['name'] can be used (like bellow) to save extra data to the $field |
||
136 | * |
||
137 | * @param $field - an array holding all the field's data |
||
138 | * |
||
139 | * @type action |
||
140 | * @since 3.6 |
||
141 | * @date 23/01/13 |
||
142 | */ |
||
143 | |||
144 | function render_field_settings( $field ) { |
||
191 | |||
192 | } |
||
193 | |||
199 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.