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 if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
||
15 | class EEM_Term_Relationship extends EEM_Base { |
||
16 | |||
17 | // private instance of the Attendee object |
||
18 | protected static $_instance = null; |
||
19 | |||
20 | |||
21 | |||
22 | /** |
||
23 | * EEM_Term_Relationship constructor. |
||
24 | * |
||
25 | * @param string $timezone |
||
26 | */ |
||
27 | protected function __construct( $timezone = null ) { |
||
115 | |||
116 | |||
117 | |||
118 | /** |
||
119 | * Makes sure all term-taxonomy counts are correct |
||
120 | * |
||
121 | * @param int $term_taxonomy_id the id of the term taxonomy to update. If NULL, updates ALL |
||
122 | * @global wpdb $wpdb |
||
123 | * @return int the number of rows affected |
||
124 | */ |
||
125 | public function update_term_taxonomy_counts( $term_taxonomy_id = null ) { |
||
145 | |||
146 | |||
147 | |||
148 | /** |
||
149 | * Overrides the parent to also make sure term-taxonomy counts are up-to-date after |
||
150 | * inserting |
||
151 | * |
||
152 | * @param array $field_n_values @see EEM_Base::insert |
||
153 | * @return boolean |
||
154 | */ |
||
155 | public function insert( $field_n_values ) { |
||
162 | |||
163 | |||
164 | |||
165 | /** |
||
166 | * Overrides parent so that after an update, we also check the term_taxonomy_counts are |
||
167 | * all ok |
||
168 | * |
||
169 | * @param array $fields_n_values see EEM_Base::update |
||
170 | * @param array $query_params @see EEM_Base::get_all |
||
171 | * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
||
172 | * in this model's entity map according to $fields_n_values that match |
||
173 | * $query_params. This obviously has some overhead, so you can disable it |
||
174 | * by setting this to FALSE, but be aware that model objects being used |
||
175 | * could get out-of-sync with the database |
||
176 | * @return int |
||
177 | */ |
||
178 | public function update( $fields_n_values, $query_params, $keep_model_objs_in_sync = true ) { |
||
185 | |||
186 | |||
187 | |||
188 | /** |
||
189 | * Overrides parent so that after running this, we also double-check |
||
190 | * the term taxonomy counts are up-to-date |
||
191 | * |
||
192 | * @param array $query_params @see EEM_Base::get_all |
||
193 | * @param boolean $allow_blocking |
||
194 | * @return int @see EEM_Base::delete |
||
195 | */ |
||
196 | public function delete( $query_params, $allow_blocking = true ) { |
||
203 | |||
204 | |||
205 | |||
206 | /** |
||
207 | * Makes sure that during REST API queries, we only return term relationships |
||
208 | * for term taxonomies which should be shown in the rest api |
||
209 | * |
||
210 | * @param array $model_query_params |
||
211 | * @param array $querystring_query_params |
||
212 | * @param EEM_Base $model |
||
213 | * @return array |
||
214 | */ |
||
215 | View Code Duplication | public static function rest_api_query_params( $model_query_params, $querystring_query_params, $model ) { |
|
224 | |||
225 | |||
226 | } |
||
227 | // End of file EEM_Term_Relationship.model.php |
||
228 | // Location: /includes/models/EEM_Term_Relationship.model.php |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..