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_tab 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() { |
|
48 | |||
49 | |||
50 | /* |
||
51 | * prepare_field |
||
52 | * |
||
53 | * description |
||
54 | * |
||
55 | * @type function |
||
56 | * @date 9/07/2015 |
||
57 | * @since 5.2.3 |
||
58 | * |
||
59 | * @param $post_id (int) |
||
60 | * @return $post_id (int) |
||
61 | */ |
||
62 | |||
63 | /* |
||
64 | function prepare_field( $field ) { |
||
65 | |||
66 | // append class |
||
67 | if( $field['endpoint'] ) { |
||
68 | |||
69 | $field['wrapper']['class'] .= ' acf-field-tab-endpoint'; |
||
70 | |||
71 | } |
||
72 | |||
73 | |||
74 | // return |
||
75 | return $field; |
||
76 | |||
77 | } |
||
78 | */ |
||
79 | |||
80 | |||
81 | /* |
||
82 | * render_field() |
||
83 | * |
||
84 | * Create the HTML interface for your field |
||
85 | * |
||
86 | * @param $field - an array holding all the field's data |
||
87 | * |
||
88 | * @type action |
||
89 | * @since 3.6 |
||
90 | * @date 23/01/13 |
||
91 | */ |
||
92 | |||
93 | function render_field( $field ) { |
||
108 | |||
109 | |||
110 | |||
111 | /* |
||
112 | * render_field_settings() |
||
113 | * |
||
114 | * Create extra options for your field. This is rendered when editing a field. |
||
115 | * The value of $field['name'] can be used (like bellow) to save extra data to the $field |
||
116 | * |
||
117 | * @param $field - an array holding all the field's data |
||
118 | * |
||
119 | * @type action |
||
120 | * @since 3.6 |
||
121 | * @date 23/01/13 |
||
122 | */ |
||
123 | |||
124 | function render_field_settings( $field ) { |
||
168 | |||
169 | } |
||
170 | |||
176 |
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.