Completed
Branch BUG-9647-cpt-queries (303307)
by
unknown
201:19 queued 184:10
created
core/db_models/relations/EE_Has_Many_Relation.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require_once( EE_MODELS . 'relations/EE_Model_Relation_Base.php');
2
+require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php');
3 3
 
4 4
 
5 5
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @subpackage    core
12 12
  * @author        Michael Nelson
13 13
  */
14
-class EE_Has_Many_Relation extends EE_Model_Relation_Base{
14
+class EE_Has_Many_Relation extends EE_Model_Relation_Base {
15 15
 
16 16
 	/**
17 17
 	 * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the foreign key
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @param boolean $block_deletes For this type of relation, we block by default. If there are related models across this relation, block (prevent and add an error) the deletion of this model
22 22
 	 * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the default
23 23
 	 */
24
-	public function __construct($block_deletes = true, $blocking_delete_error_message = null){
24
+	public function __construct($block_deletes = true, $blocking_delete_error_message = null) {
25 25
 		parent::__construct($block_deletes, $blocking_delete_error_message);
26 26
 	}
27 27
 
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
 	 * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = other_model_primary_table.fk" etc
35 35
 	 * @throws \EE_Error
36 36
 	 */
37
-	public function get_join_statement( $model_relation_chain){
37
+	public function get_join_statement($model_relation_chain) {
38 38
 		//create the sql string like
39 39
 		// LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions
40 40
 		$this_table_pk_field = $this->get_this_model()->get_primary_key_field();
41 41
 		$other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
42
-		$pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias();
43
-		$fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_fk_field->get_table_alias();
42
+		$pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias();
43
+		$fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_fk_field->get_table_alias();
44 44
 		$fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias);
45 45
 
46 46
 		return $this->_left_join($fk_table, $fk_table_alias, $other_table_fk_field->get_table_column(), $pk_table_alias, $this_table_pk_field->get_table_column()).$this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias);
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 	 * @return \EE_Base_Class
58 58
 	 * @throws \EE_Error
59 59
 	 */
60
-	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){
60
+	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) {
61 61
 		 $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
62 62
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
63 63
 
64 64
 		 //find the field on the other model which is a foreign key to this model
65 65
 		 $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
66
-		 if($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()){
66
+		 if ($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()) {
67 67
 			//set that field on the other model to this model's ID
68 68
 			$other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID());
69 69
 			$other_model_obj->save();
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 	 * @return \EE_Base_Class
84 84
 	 * @throws \EE_Error
85 85
 	 */
86
-	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()){
86
+	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) {
87 87
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
88 88
 		 //find the field on the other model which is a foreign key to this model
89 89
 		 $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
90 90
 		 //set that field on the other model to this model's ID
91
-		 $other_model_obj->set($fk_field_on_other_model->get_name(),null, true);
91
+		 $other_model_obj->set($fk_field_on_other_model->get_name(), null, true);
92 92
 		 $other_model_obj->save();
93 93
 		 return $other_model_obj;
94 94
 	 }
Please login to merge, or discard this patch.
core/db_models/relations/EE_Has_Many_Revision_Relation.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require_once( EE_MODELS . 'relations/EE_Has_Many_Relation.php');
2
+require_once(EE_MODELS.'relations/EE_Has_Many_Relation.php');
3 3
 
4 4
 
5 5
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @subpackage    core
12 12
  * @author        Michael Nelson
13 13
  */
14
-class EE_Has_Many_Revision_Relation extends EE_Has_Many_Relation{
14
+class EE_Has_Many_Revision_Relation extends EE_Has_Many_Relation {
15 15
 
16 16
 
17 17
 	/**
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param boolean $block_deletes For this type of relation, we block by default. If there are related models across this relation, block (prevent and add an error) the deletion of this model
45 45
 	 * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the default
46 46
 	 */
47
-	public function __construct($primary_cpt_field, $parent_pk_relation_field, $block_deletes = true, $blocking_delete_error_message = null){
47
+	public function __construct($primary_cpt_field, $parent_pk_relation_field, $block_deletes = true, $blocking_delete_error_message = null) {
48 48
 		$this->_primary_cpt_field = $primary_cpt_field;
49 49
 		$this->_parent_pk_relation_field = $parent_pk_relation_field;
50 50
 		parent::__construct($block_deletes, $blocking_delete_error_message);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 * @return \EE_Base_Class
62 62
 	 * @throws \EE_Error
63 63
 	 */
64
-	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){
64
+	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) {
65 65
 		 $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
66 66
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id);
67 67
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		 $other_model_obj = $this->_check_for_revision($this_model_obj, $other_model_obj);
70 70
 
71 71
 		 //if is array, then we've already done the add_relation so let's get out
72
-		if ( is_array( $other_model_obj ) ){
72
+		if (is_array($other_model_obj)) {
73 73
 			return $other_model_obj[0];
74 74
 		}
75 75
 		 //find the field on the other model which is a foreign key to this model
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
 	 * @return \EE_Base_Class
92 92
 	 * @throws \EE_Error
93 93
 	 */
94
-	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()){
94
+	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) {
95 95
 	 	$this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id);
96 96
 		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id);
97 97
 		//handle possible revisions
98
-		$other_model_obj = $this->_check_for_revision( $this_model_obj, $other_model_obj, TRUE );
98
+		$other_model_obj = $this->_check_for_revision($this_model_obj, $other_model_obj, TRUE);
99 99
 
100 100
 
101 101
 		//if is array, then we've already done the add_relation so let's get out
102
-		if ( is_array( $other_model_obj ) ){
102
+		if (is_array($other_model_obj)) {
103 103
 			return $other_model_obj[0];
104 104
 		}
105 105
 
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
 
109 109
 
110 110
 		 //set that field on the other model to this model's ID
111
-		 if ( $this->_blocking_delete ) {
112
-		 	$other_model_obj->set($fk_field_on_other_model->get_name(),null,true);
111
+		 if ($this->_blocking_delete) {
112
+		 	$other_model_obj->set($fk_field_on_other_model->get_name(), null, true);
113 113
 		 	$other_model_obj->save();
114 114
 		 } else {
115 115
 		 	$other_model_obj->delete();
116
-		 	$other_model_obj->set($fk_field_on_other_model->get_name(),null,true);
116
+		 	$other_model_obj->set($fk_field_on_other_model->get_name(), null, true);
117 117
 		 	return $other_model_obj;
118 118
 		 }
119 119
 		 return $other_model_obj;
@@ -130,17 +130,17 @@  discard block
 block discarded – undo
130 130
 	 * @return EE_Base_Class[]
131 131
 	 * @throws \EE_Error
132 132
 	 */
133
-	 public function get_all_related( $model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false ) {
134
-		if( $values_already_prepared_by_model_object !== false ) {
135
-			EE_Error::doing_it_wrong( 'EE_Model_Relation_Base::get_all_related', __( 'The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso' ), '4.8.1' );
133
+	 public function get_all_related($model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false) {
134
+		if ($values_already_prepared_by_model_object !== false) {
135
+			EE_Error::doing_it_wrong('EE_Model_Relation_Base::get_all_related', __('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'), '4.8.1');
136 136
 		}
137 137
 
138 138
 	 	//if this is an autosave then we're going to get things differently
139
-	 	if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
140
-	 		return $this->_do_autosave_get_all($model_object_or_id, $query_params );
139
+	 	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
140
+	 		return $this->_do_autosave_get_all($model_object_or_id, $query_params);
141 141
 	 	}
142 142
 
143
-	 	return parent::get_all_related( $model_object_or_id, $query_params );
143
+	 	return parent::get_all_related($model_object_or_id, $query_params);
144 144
 	 }
145 145
 
146 146
 
@@ -156,22 +156,22 @@  discard block
 block discarded – undo
156 156
 	 * @return \EE_Base_Class[]
157 157
 	 * @throws \EE_Error
158 158
 	 */
159
-	 protected function _do_autosave_get_all( $model_object_or_id, $query_params, $deprecated = false ) {
159
+	 protected function _do_autosave_get_all($model_object_or_id, $query_params, $deprecated = false) {
160 160
 
161 161
 	 	//first we check if the post_id for the incoming query is for an autosave.  If it isn't that's what we want!
162
-	 	$model_object_id = $this->_get_model_object_id( $model_object_or_id );
162
+	 	$model_object_id = $this->_get_model_object_id($model_object_or_id);
163 163
 
164
-	 	$autosave = wp_get_post_autosave( $model_object_id );
164
+	 	$autosave = wp_get_post_autosave($model_object_id);
165 165
 	 	$id_to_use = $autosave ? $autosave->ID : $model_object_id;
166 166
 
167
-	 	$autosave_relations =  parent::get_all_related( $id_to_use, $query_params );
167
+	 	$autosave_relations = parent::get_all_related($id_to_use, $query_params);
168 168
 	 	$parent_ids = $parents = array();
169 169
 	 	$return_objs = array();
170 170
 
171 171
 		//k this is where things differ because NOW what we're going to do is get the PARENTS for the get all related (and we'll also start setting up the return_objs array containing related that DON'T have parent ids, for those that DON'T have parents to merge with our returned objects);
172
-		foreach ( $autosave_relations as $a_r ) {
172
+		foreach ($autosave_relations as $a_r) {
173 173
 			$pid = $a_r->parent();
174
-			if ( !empty( $pid ) ) {
174
+			if ( ! empty($pid)) {
175 175
 				$parent_ids[] = $pid;
176 176
 			} else {
177 177
 				$return_objs[] = $a_r;
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 		}
180 180
 
181 181
 		//we have to make sure we also include the ORIGINAL values
182
-		$originals = parent::get_all_related($model_object_or_id, $query_params );
182
+		$originals = parent::get_all_related($model_object_or_id, $query_params);
183 183
 
184 184
 		//merge $originals with $return_objs
185
-		if ( $originals ) {
185
+		if ($originals) {
186 186
 			$return_objs = array_merge($originals, $return_objs);
187 187
 		}
188 188
 
189 189
 		//now we setup the query to get all the parents
190
-		if ( !empty( $parent_ids ) ) {
190
+		if ( ! empty($parent_ids)) {
191 191
 			$query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name().".".$this->get_this_model()->get_primary_key_field()->get_name();
192
-			$query_param[0][$query_param_where_this_model_pk] = array('IN', $parent_ids );
192
+			$query_param[0][$query_param_where_this_model_pk] = array('IN', $parent_ids);
193 193
 			$parents = $this->get_other_model()->get_all($query_params);
194 194
 		}
195 195
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 
198 198
 
199 199
 		//now merge parents with our current $return_objs and send back
200
-		return array_merge( $parents, $return_objs );
200
+		return array_merge($parents, $return_objs);
201 201
 	 }
202 202
 
203 203
 
@@ -211,42 +211,42 @@  discard block
 block discarded – undo
211 211
 	 * @return EE_Base_Class. ($other_obj);
212 212
 	 * @throws \EE_Error
213 213
 	 */
214
-	protected function _check_for_revision( $this_obj, $other_obj, $remove_relation = FALSE ) {
214
+	protected function _check_for_revision($this_obj, $other_obj, $remove_relation = FALSE) {
215 215
 		$pk_on_related_model = $this->get_other_model()->get_primary_key_field()->get_name();
216 216
 		//now we need to determine if we're in a WP revision save cause if we are we need to do some special handling
217
-		if (  $this_obj->post_type() === 'revision' ) {
217
+		if ($this_obj->post_type() === 'revision') {
218 218
 			//first if $other_obj fk = this_obj pk then we know that this is a pk object, let's make sure there is a matching set for the autosave if there is then we save over it, if there isn't then we need to create a new one.
219 219
 			$parent_evt_id = $this_obj->parent();
220 220
 			/*var_dump($parent_evt_id);
221 221
 			var_dump($this_obj);
222 222
 			var_dump($other_obj);/**/
223 223
 
224
-			if ( !empty($parent_evt_id) && $parent_evt_id == $other_obj->get($this->_primary_cpt_field) ) {
224
+			if ( ! empty($parent_evt_id) && $parent_evt_id == $other_obj->get($this->_primary_cpt_field)) {
225 225
 				//let's do query on this objects model to see if the incoming pk value on the obj matches any parents in this objects table.
226
-				$has_parent_obj = $this->get_other_model()->get_one( array( array( $this->_parent_pk_relation_field => $other_obj->ID(), $this->_primary_cpt_field => $this_obj->ID() ) ) );
226
+				$has_parent_obj = $this->get_other_model()->get_one(array(array($this->_parent_pk_relation_field => $other_obj->ID(), $this->_primary_cpt_field => $this_obj->ID())));
227 227
 
228
-				if ( $has_parent_obj ) {
228
+				if ($has_parent_obj) {
229 229
 					//this makes sure the update on the current obj happens to the revision's row NOT the parent row.
230 230
 
231
-					$other_obj->set( $this->_parent_pk_relation_field, $other_obj->ID());
232
-					$other_obj->set($pk_on_related_model, $has_parent_obj->ID() );
231
+					$other_obj->set($this->_parent_pk_relation_field, $other_obj->ID());
232
+					$other_obj->set($pk_on_related_model, $has_parent_obj->ID());
233 233
 					$other_obj->set($this->_primary_cpt_field, $this_obj->ID());
234 234
 
235
-					if ( !$remove_relation ) {
235
+					if ( ! $remove_relation) {
236 236
 						$other_obj->save();
237
-						return array( $other_obj );
238
-					} elseif ( $remove_relation && !$this->_blocking_delete) {
237
+						return array($other_obj);
238
+					} elseif ($remove_relation && ! $this->_blocking_delete) {
239 239
 						$other_obj->delete();
240 240
 						$other_obj->set($this->_parent_pk_relation_field, NULL, true);
241 241
 						return array($other_obj);
242 242
 					}
243 243
 
244 244
 				} else {
245
-					$other_obj->set( $this->_parent_pk_relation_field, $other_obj->ID() );
246
-					$other_obj->set( $this->_primary_cpt_field, $this_obj->ID() );
245
+					$other_obj->set($this->_parent_pk_relation_field, $other_obj->ID());
246
+					$other_obj->set($this->_primary_cpt_field, $this_obj->ID());
247 247
 					$other_obj->set($pk_on_related_model, NULL, true); //ensure we create a new row for the autosave with parent id the same as the incoming ID.
248 248
 					$other_obj->save(); //make sure we insert.
249
-					return array( $other_obj );
249
+					return array($other_obj);
250 250
 				}
251 251
 			}
252 252
 
@@ -259,24 +259,24 @@  discard block
 block discarded – undo
259 259
 		} else {
260 260
 
261 261
 			//we only need to do the below IF this is not a remove relation
262
-			if ( !$remove_relation ) {
262
+			if ( ! $remove_relation) {
263 263
 				//okay this is is a normal update/save/remove so, let's make sure the other object is not a revision of the current object.
264 264
 				//the other object will likely NOT have the correct fk on it (which is the primary_cpt_field_mame) so we must retrieve from the db to get that first.
265 265
 				$existing_other_obj = $this->get_other_model()->get_one_by_ID($other_obj->ID());
266 266
 				$potential_revision_id = is_object($existing_other_obj) ? $existing_other_obj->get($this->_primary_cpt_field) : NULL;
267 267
 
268
-				if ( $parent_this_obj_id = wp_is_post_revision($potential_revision_id) ) {
268
+				if ($parent_this_obj_id = wp_is_post_revision($potential_revision_id)) {
269 269
 					//yes the OTHER object is linked to the revision of the parent, not the parent itself. That means we need to make the other_object an attachment of this_obj and then duplicate other_obj for the revision.
270
-					$other_obj->set($this->_primary_cpt_field, $this_obj->ID() );
270
+					$other_obj->set($this->_primary_cpt_field, $this_obj->ID());
271 271
 					$other_obj->save();
272 272
 
273 273
 					//now create a new other_obj and fill with details from existing object
274 274
 					$new_obj = $other_obj;
275
-					$new_obj->set( $this->_primary_cpt_field, $potential_revision_id );
276
-					$new_obj->set( $this->_parent_pk_relation_field, $other_obj->ID() );
277
-					$new_obj->set( $pk_on_related_model, NULL );
275
+					$new_obj->set($this->_primary_cpt_field, $potential_revision_id);
276
+					$new_obj->set($this->_parent_pk_relation_field, $other_obj->ID());
277
+					$new_obj->set($pk_on_related_model, NULL);
278 278
 					$new_obj->save();
279
-					return array( $new_obj );
279
+					return array($new_obj);
280 280
 				}
281 281
 
282 282
 			}
Please login to merge, or discard this patch.
core/db_models/relations/EE_Belongs_To_Any_Relation.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require_once( EE_MODELS . 'relations/EE_Belongs_To_Relation.php');
2
+require_once(EE_MODELS.'relations/EE_Belongs_To_Relation.php');
3 3
 
4 4
 
5 5
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * @return string
24 24
 	 * @throws \EE_Error
25 25
 	 */
26
-	public function get_join_statement( $model_relation_chain) {
26
+	public function get_join_statement($model_relation_chain) {
27 27
 		//create the sql string like
28 28
 		$this_table_fk_field = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
29 29
 		//ALSO, need to get the field with the model name
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 
32 32
 
33 33
 		$other_table_pk_field = $this->get_other_model()->get_primary_key_field();
34
-		$this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,$this->get_this_model()->get_this_model_name()) . $this_table_fk_field->get_table_alias();
35
-		$other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias();
34
+		$this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_fk_field->get_table_alias();
35
+		$other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias();
36 36
 		$other_table = $this->get_other_model()->get_table_for_alias($other_table_alias);
37 37
 		return $this->_left_join($other_table,
38 38
 				$other_table_alias,
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) {
82 82
 		$this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
83
-		$other_model_obj = $this->get_other_model()->ensure_is_obj( $other_obj_or_id );
83
+		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id);
84 84
 		//find the field on the other model which is a foreign key to this model
85 85
 		$fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
86 86
 		//set that field on the other model to this model's ID
87 87
 		$this_model_obj->set($fk_on_this_model->get_name(), null, true);
88
-		$this_model_obj->set($this->get_this_model()->get_field_containing_related_model_name()->get_name(),null,true);
88
+		$this_model_obj->set($this->get_this_model()->get_field_containing_related_model_name()->get_name(), null, true);
89 89
 		$this_model_obj->save();
90 90
 		return $other_model_obj;
91 91
 	}
Please login to merge, or discard this patch.
core/db_models/relations/EE_Has_Many_Any_Relation.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 /*
5 5
  *
6 6
  */
7
-require_once( EE_MODELS . 'relations/EE_Model_Relation_Base.php');
7
+require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php');
8 8
 
9 9
 
10 10
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  * @subpackage    core
20 20
  * @author        Michael Nelson
21 21
  */
22
-class EE_Has_Many_Any_Relation extends EE_Has_Many_Relation{
22
+class EE_Has_Many_Any_Relation extends EE_Has_Many_Relation {
23 23
 
24 24
 	/**
25 25
 	 * Gets the SQL string for performing the join between this model and the other model.
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
 	 * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = other_model_primary_table.fk" etc
29 29
 	 * @throws \EE_Error
30 30
 	 */
31
-	public function get_join_statement( $model_relation_chain){
31
+	public function get_join_statement($model_relation_chain) {
32 32
 		//create the sql string like
33 33
 		// LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions
34 34
 		$this_table_pk_field = $this->get_this_model()->get_primary_key_field();
35 35
 		$other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
36
-		$pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias();
37
-		$fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_fk_field->get_table_alias();
36
+		$pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias();
37
+		$fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_fk_field->get_table_alias();
38 38
 		$fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias);
39 39
 		$field_with_model_name = $this->get_other_model()->get_field_containing_related_model_name();
40 40
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 				$other_table_fk_field->get_table_column(),
44 44
 				$pk_table_alias,
45 45
 				$this_table_pk_field->get_table_column(),
46
-				$fk_table_alias . '.' . $field_with_model_name->get_table_column() . "='" . $this->get_this_model()->get_this_model_name() . "'" )
46
+				$fk_table_alias.'.'.$field_with_model_name->get_table_column()."='".$this->get_this_model()->get_this_model_name()."'")
47 47
 				.$this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias);
48 48
 	}
49 49
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * @return \EE_Base_Class
59 59
 	 * @throws \EE_Error
60 60
 	 */
61
-	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){
61
+	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) {
62 62
 		 $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
63 63
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
64 64
 
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 	 * @return \EE_Base_Class
84 84
 	 * @throws \EE_Error
85 85
 	 */
86
-	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()){
86
+	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) {
87 87
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
88 88
 		 //find the field on the other model which is a foreign key to this model
89 89
 		 $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
90 90
 		 //set that field on the other model to this model's ID
91
-		 $other_model_obj->set($fk_field_on_other_model->get_name(),null, true);
91
+		 $other_model_obj->set($fk_field_on_other_model->get_name(), null, true);
92 92
 		 $other_model_obj->set($this->get_other_model()->get_field_containing_related_model_name()->get_name(), null, true);
93 93
 		 $other_model_obj->save();
94 94
 		 return $other_model_obj;
Please login to merge, or discard this patch.
core/helpers/EEH_Debug_Tools.helper.php 3 patches
Braces   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -131,8 +131,7 @@  discard block
 block discarded – undo
131 131
 				return;
132 132
 			}
133 133
 			echo '<h5>For Tag: '. $tag .'</h5>';
134
-		}
135
-		else {
134
+		} else {
136 135
 			$hook=$wp_filter;
137 136
 			ksort( $hook );
138 137
 		}
@@ -200,7 +199,7 @@  discard block
 block discarded – undo
200 199
 		if( isset( $this->_start_times[ $timer_name ] ) ){
201 200
 			$start_time = $this->_start_times[ $timer_name ];
202 201
 			unset( $this->_start_times[ $timer_name ] );
203
-		}else{
202
+		} else{
204 203
 			$start_time = array_pop( $this->_start_times );
205 204
 		}
206 205
 		$total_time = microtime( TRUE ) - $start_time;
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 
188 188
 	/**
189 189
 	 * 	start_timer
190
-	 * @param null $timer_name
190
+	 * @param string $timer_name
191 191
 	 */
192 192
 	public function start_timer( $timer_name = NULL ){
193 193
 		$this->_start_times[$timer_name] = microtime( TRUE );
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 
445 445
 
446 446
 	/**
447
-	 * @param mixed  $var
447
+	 * @param string  $var
448 448
 	 * @param string $var_name
449 449
 	 * @param string $file
450 450
 	 * @param int    $line
Please login to merge, or discard this patch.
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2 2
 /**
3 3
  * Class EEH_Debug_Tools
4 4
  *
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since 				4.0
9 9
  *
10 10
  */
11
-class EEH_Debug_Tools{
11
+class EEH_Debug_Tools {
12 12
 
13 13
 	/**
14 14
 	 * 	instance of the EEH_Autoloader object
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public static function instance() {
43 43
 		// check if class object is instantiated, and instantiated properly
44
-		if ( ! self::$_instance instanceof EEH_Debug_Tools ) {
44
+		if ( ! self::$_instance instanceof EEH_Debug_Tools) {
45 45
 			self::$_instance = new self();
46 46
 		}
47 47
 		return self::$_instance;
@@ -57,21 +57,21 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	private function __construct() {
59 59
 		// load Kint PHP debugging library
60
-		if ( ! class_exists( 'Kint' ) &&  file_exists( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' )){
60
+		if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) {
61 61
 			// despite EE4 having a check for an existing copy of the Kint debugging class,
62 62
 			// if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
63 63
 			// then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
64 64
 			// so we've moved it to our test folder so that it is not included with production releases
65 65
 			// plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
66
-			require_once( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' );
66
+			require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php');
67 67
 		}
68 68
 		// if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
69 69
 			//add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
70 70
 		// }
71
-		$plugin = basename( EE_PLUGIN_DIR_PATH );
72
-		add_action( "activate_{$plugin}", array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' ));
73
-		add_action( 'activated_plugin', array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' ));
74
-		add_action( 'shutdown', array( 'EEH_Debug_Tools', 'show_db_name' ));
71
+		$plugin = basename(EE_PLUGIN_DIR_PATH);
72
+		add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
73
+		add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
74
+		add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name'));
75 75
 	}
76 76
 
77 77
 
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
 	 * 	@return void
83 83
 	 */
84 84
 	public static function show_db_name() {
85
-		if ( ! defined( 'DOING_AJAX' ) && ( defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS )) {
86
-			echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '. DB_NAME .'</p>';
85
+		if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
86
+			echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '.DB_NAME.'</p>';
87 87
 		}
88
-		if ( EE_DEBUG ) {
88
+		if (EE_DEBUG) {
89 89
 			EEH_Debug_Tools::instance()->show_times();
90 90
 		}
91 91
 	}
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function espresso_session_footer_dump() {
101 101
 		if (
102
-			( defined( 'WP_DEBUG' ) && WP_DEBUG )
103
-			&& ! defined( 'DOING_AJAX' )
104
-			&& class_exists( 'Kint' )
105
-			&& function_exists( 'wp_get_current_user' )
106
-			&& current_user_can( 'update_core' )
107
-			&& class_exists( 'EE_Registry' )
102
+			(defined('WP_DEBUG') && WP_DEBUG)
103
+			&& ! defined('DOING_AJAX')
104
+			&& class_exists('Kint')
105
+			&& function_exists('wp_get_current_user')
106
+			&& current_user_can('update_core')
107
+			&& class_exists('EE_Registry')
108 108
 		) {
109
-			Kint::dump(  EE_Registry::instance()->SSN->id() );
110
-			Kint::dump( EE_Registry::instance()->SSN );
109
+			Kint::dump(EE_Registry::instance()->SSN->id());
110
+			Kint::dump(EE_Registry::instance()->SSN);
111 111
 			//			Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() );
112 112
 			$this->espresso_list_hooked_functions();
113 113
 			$this->show_times();
@@ -124,27 +124,27 @@  discard block
 block discarded – undo
124 124
 	 * @param string $tag
125 125
 	 * @return void
126 126
 	 */
127
-	public function espresso_list_hooked_functions( $tag='' ){
127
+	public function espresso_list_hooked_functions($tag = '') {
128 128
 		global $wp_filter;
129 129
 		echo '<br/><br/><br/><h3>Hooked Functions</h3>';
130
-		if ( $tag ) {
131
-			$hook[$tag]=$wp_filter[$tag];
132
-			if ( ! is_array( $hook[$tag] )) {
133
-				trigger_error( "Nothing found for '$tag' hook", E_USER_WARNING );
130
+		if ($tag) {
131
+			$hook[$tag] = $wp_filter[$tag];
132
+			if ( ! is_array($hook[$tag])) {
133
+				trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
134 134
 				return;
135 135
 			}
136
-			echo '<h5>For Tag: '. $tag .'</h5>';
136
+			echo '<h5>For Tag: '.$tag.'</h5>';
137 137
 		}
138 138
 		else {
139
-			$hook=$wp_filter;
140
-			ksort( $hook );
139
+			$hook = $wp_filter;
140
+			ksort($hook);
141 141
 		}
142
-		foreach( $hook as $tag_name => $priorities ) {
142
+		foreach ($hook as $tag_name => $priorities) {
143 143
 			echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag_name</strong><br />";
144
-			ksort( $priorities );
145
-			foreach( $priorities as $priority => $function ){
144
+			ksort($priorities);
145
+			foreach ($priorities as $priority => $function) {
146 146
 				echo $priority;
147
-				foreach( $function as $name => $properties ) {
147
+				foreach ($function as $name => $properties) {
148 148
 					echo "\t$name<br />";
149 149
 				}
150 150
 			}
@@ -159,15 +159,15 @@  discard block
 block discarded – undo
159 159
 	 * @param string $hook_name
160 160
 	 * @return array
161 161
 	 */
162
-	public static function registered_filter_callbacks( $hook_name = '' ) {
162
+	public static function registered_filter_callbacks($hook_name = '') {
163 163
 		$filters = array();
164 164
 		global $wp_filter;
165
-		if ( isset( $wp_filter[ $hook_name ] ) ) {
166
-			$filters[ $hook_name ] = array();
167
-			foreach ( $wp_filter[ $hook_name ] as $priority => $callbacks ) {
168
-				$filters[ $hook_name ][ $priority ] = array();
169
-				foreach ( $callbacks as $callback ) {
170
-					$filters[ $hook_name ][ $priority ][] = $callback['function'];
165
+		if (isset($wp_filter[$hook_name])) {
166
+			$filters[$hook_name] = array();
167
+			foreach ($wp_filter[$hook_name] as $priority => $callbacks) {
168
+				$filters[$hook_name][$priority] = array();
169
+				foreach ($callbacks as $callback) {
170
+					$filters[$hook_name][$priority][] = $callback['function'];
171 171
 				}
172 172
 			}
173 173
 		}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	/**
180 180
 	 * reset_times
181 181
 	 */
182
-	public function reset_times(){
182
+	public function reset_times() {
183 183
 		$this->_times = array();
184 184
 	}
185 185
 
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 	 * 	start_timer
190 190
 	 * @param null $timer_name
191 191
 	 */
192
-	public function start_timer( $timer_name = NULL ){
193
-		$this->_start_times[$timer_name] = microtime( TRUE );
192
+	public function start_timer($timer_name = NULL) {
193
+		$this->_start_times[$timer_name] = microtime(TRUE);
194 194
 	}
195 195
 
196 196
 
@@ -199,15 +199,15 @@  discard block
 block discarded – undo
199 199
 	 * stop_timer
200 200
 	 * @param string $timer_name
201 201
 	 */
202
-	public function stop_timer( $timer_name = '' ){
202
+	public function stop_timer($timer_name = '') {
203 203
 		$timer_name = $timer_name !== '' ? $timer_name : get_called_class();
204
-		if( isset( $this->_start_times[ $timer_name ] ) ){
205
-			$start_time = $this->_start_times[ $timer_name ];
206
-			unset( $this->_start_times[ $timer_name ] );
207
-		}else{
208
-			$start_time = array_pop( $this->_start_times );
204
+		if (isset($this->_start_times[$timer_name])) {
205
+			$start_time = $this->_start_times[$timer_name];
206
+			unset($this->_start_times[$timer_name]);
207
+		} else {
208
+			$start_time = array_pop($this->_start_times);
209 209
 		}
210
-		$this->_times[ $timer_name ] =  number_format( microtime( true ) - $start_time, 8 );
210
+		$this->_times[$timer_name] = number_format(microtime(true) - $start_time, 8);
211 211
 	}
212 212
 
213 213
 
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
 	 * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
218 218
 	 * @return void
219 219
 	 */
220
-	public function measure_memory( $label, $output_now = false ) {
221
-		$memory_used = $this->convert( memory_get_peak_usage( true ) );
222
-		$this->_memory_usage_points[ $label ] = $memory_used;
223
-		if( $output_now ) {
220
+	public function measure_memory($label, $output_now = false) {
221
+		$memory_used = $this->convert(memory_get_peak_usage(true));
222
+		$this->_memory_usage_points[$label] = $memory_used;
223
+		if ($output_now) {
224 224
 			echo "\r\n<br>$label : $memory_used";
225 225
 		}
226 226
 	}
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 	 * @param int $size
231 231
 	 * @return string
232 232
 	 */
233
-	public function convert( $size ) {
234
-		$unit=array('b','kb','mb','gb','tb','pb');
235
-		return @round( $size / pow( 1024, $i = floor( log( $size, 1024 ) ) ), 2 ) . ' ' . $unit[ absint( $i ) ];
233
+	public function convert($size) {
234
+		$unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
235
+		return @round($size / pow(1024, $i = floor(log($size, 1024))), 2).' '.$unit[absint($i)];
236 236
 	}
237 237
 
238 238
 
@@ -242,25 +242,25 @@  discard block
 block discarded – undo
242 242
 	 * @param bool $output_now
243 243
 	 * @return string
244 244
 	 */
245
-	public function show_times($output_now=true){
245
+	public function show_times($output_now = true) {
246 246
 		$output = '';
247
-		if ( ! empty( $this->_times )) {
247
+		if ( ! empty($this->_times)) {
248 248
 			$total = 0;
249 249
 			$output .= '<h2 style="margin:1em .5em 0;">Times:</h2>';
250 250
 			$output .= '<span style="color:#9999CC; font-size:.8em; margin:0 1.5em 0;">( in milliseconds )</span><br />';
251
-			foreach( $this->_times as $timer_name => $total_time ) {
252
-				$output .= $this->format_time( $timer_name, $total_time );
251
+			foreach ($this->_times as $timer_name => $total_time) {
252
+				$output .= $this->format_time($timer_name, $total_time);
253 253
 				$total += $total_time;
254 254
 			}
255 255
 			$output .= '<br />';
256 256
 			$output .= '<h4 style="margin:1em .5em 0;">TOTAL TIME</h4>';
257
-			$output .= $this->format_time( '', $total );
257
+			$output .= $this->format_time('', $total);
258 258
 			$output .= '<br />';
259 259
 		}
260
-		if ( ! empty( $this->_memory_usage_points )) {
261
-			$output .= '<h2 style="margin:1em .5em 0;">Memory</h2>' . implode( '<br />', $this->_memory_usage_points );
260
+		if ( ! empty($this->_memory_usage_points)) {
261
+			$output .= '<h2 style="margin:1em .5em 0;">Memory</h2>'.implode('<br />', $this->_memory_usage_points);
262 262
 		}
263
-		if( $output_now ){
263
+		if ($output_now) {
264 264
 			echo $output;
265 265
 			return '';
266 266
 		}
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 	 * @param float $total_time
275 275
 	 * @return string
276 276
 	 */
277
-	public function format_time( $timer_name, $total_time ) {
277
+	public function format_time($timer_name, $total_time) {
278 278
 		$total_time = $total_time * 1000;
279
-		switch ( $total_time ) {
279
+		switch ($total_time) {
280 280
 			case $total_time < 0.01 :
281 281
 				$color = '#8A549A';
282 282
 				$bold = 'normal';
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 			. '; font-weight:'
308 308
 			. $bold
309 309
 			. '; font-size:1.2em;">'
310
-			. str_pad( number_format( $total_time, 5 ), 11, '0', STR_PAD_LEFT )
310
+			. str_pad(number_format($total_time, 5), 11, '0', STR_PAD_LEFT)
311 311
 			. '</span> '
312 312
 			. $timer_name
313 313
 			. '<br />';
@@ -321,25 +321,25 @@  discard block
 block discarded – undo
321 321
 	 * 	@return void
322 322
 	 */
323 323
 	public static function ee_plugin_activation_errors() {
324
-		if ( WP_DEBUG ) {
324
+		if (WP_DEBUG) {
325 325
 			$activation_errors = ob_get_contents();
326
-			if ( ! empty( $activation_errors ) ) {
327
-				$activation_errors = date( 'Y-m-d H:i:s' ) . "\n" . $activation_errors;
326
+			if ( ! empty($activation_errors)) {
327
+				$activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors;
328 328
 			}
329
-			espresso_load_required( 'EEH_File', EE_HELPERS . 'EEH_File.helper.php' );
330
-			if ( class_exists( 'EEH_File' )) {
329
+			espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php');
330
+			if (class_exists('EEH_File')) {
331 331
 				try {
332
-					EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' );
333
-					EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors );
334
-				} catch( EE_Error $e ){
335
-					EE_Error::add_error( sprintf( __(  'The Event Espresso activation errors file could not be setup because: %s', 'event_espresso' ), $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ );
332
+					EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html');
333
+					EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors);
334
+				} catch (EE_Error $e) {
335
+					EE_Error::add_error(sprintf(__('The Event Espresso activation errors file could not be setup because: %s', 'event_espresso'), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
336 336
 				}
337 337
 			} else {
338 338
 				// old school attempt
339
-				file_put_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors );
339
+				file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors);
340 340
 			}
341
-			$activation_errors = get_option( 'ee_plugin_activation_errors', '' ) . $activation_errors;
342
-			update_option( 'ee_plugin_activation_errors', $activation_errors );
341
+			$activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors;
342
+			update_option('ee_plugin_activation_errors', $activation_errors);
343 343
 		}
344 344
 	}
345 345
 
@@ -355,22 +355,22 @@  discard block
 block discarded – undo
355 355
 	 * @param int     $error_type
356 356
 	 * @uses trigger_error()
357 357
 	 */
358
-	public function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) {
359
-		do_action( 'AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
360
-		$version = $version === null ? '' : sprintf( __('(This message was added in version %s of Event Espresso.', 'event_espresso' ), $version );
361
-		$error_message = sprintf( esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s','event_espresso' ), $function, '<strong>', '</strong>', $message, $version );
358
+	public function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) {
359
+		do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
360
+		$version = $version === null ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version);
361
+		$error_message = sprintf(esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), $function, '<strong>', '</strong>', $message, $version);
362 362
 
363 363
 		//don't trigger error if doing ajax, instead we'll add a transient EE_Error notice that in theory should show on the next request.
364
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
365
-			$error_message .= ' ' . esc_html__( 'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ', 'event_espresso' );
364
+		if (defined('DOING_AJAX') && DOING_AJAX) {
365
+			$error_message .= ' '.esc_html__('This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ', 'event_espresso');
366 366
 			$error_message .= '<ul><li>';
367
-			$error_message .= implode( '</li><li>', EE_Registry::instance()->REQ->params() );
367
+			$error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params());
368 368
 			$error_message .= '</ul>';
369
-			EE_Error::add_error( $error_message, 'debug::doing_it_wrong', $function, '42' );
369
+			EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42');
370 370
 			//now we set this on the transient so it shows up on the next request.
371
-			EE_Error::get_notices( false, true );
371
+			EE_Error::get_notices(false, true);
372 372
 		} else {
373
-			trigger_error( $error_message, $error_type );
373
+			trigger_error($error_message, $error_type);
374 374
 		}
375 375
 	}
376 376
 
@@ -392,22 +392,22 @@  discard block
 block discarded – undo
392 392
 	 * @param string $debug_index
393 393
 	 * @param string $debug_key
394 394
 	 */
395
-	public static function log( $class='', $func = '', $line = '', $info = array(), $display_request = false,  $debug_index = '', $debug_key = 'EE_DEBUG_SPCO' ) {
396
-		if ( WP_DEBUG && false ) {
397
-			$debug_key = $debug_key . '_' . EE_Session::instance()->id();
398
-			$debug_data = get_option( $debug_key, array() );
395
+	public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') {
396
+		if (WP_DEBUG && false) {
397
+			$debug_key = $debug_key.'_'.EE_Session::instance()->id();
398
+			$debug_data = get_option($debug_key, array());
399 399
 			$default_data = array(
400
-				$class => $func . '() : ' . $line,
400
+				$class => $func.'() : '.$line,
401 401
 				'REQ'  => $display_request ? $_REQUEST : '',
402 402
 			);
403 403
 			// don't serialize objects
404
-			$info = self::strip_objects( $info );
405
-			$index = ! empty( $debug_index ) ? $debug_index : 0;
406
-			if ( ! isset( $debug_data[$index] ) ) {
404
+			$info = self::strip_objects($info);
405
+			$index = ! empty($debug_index) ? $debug_index : 0;
406
+			if ( ! isset($debug_data[$index])) {
407 407
 				$debug_data[$index] = array();
408 408
 			}
409
-			$debug_data[$index][microtime()] = array_merge( $default_data, $info );
410
-			update_option( $debug_key, $debug_data );
409
+			$debug_data[$index][microtime()] = array_merge($default_data, $info);
410
+			update_option($debug_key, $debug_data);
411 411
 		}
412 412
 	}
413 413
 
@@ -419,26 +419,26 @@  discard block
 block discarded – undo
419 419
 	 * @param array $info
420 420
 	 * @return array
421 421
 	 */
422
-	public static function strip_objects( $info = array() ) {
423
-		foreach ( $info as $key => $value ) {
424
-			if ( is_array( $value ) ) {
425
-				$info[ $key ] = self::strip_objects( $value );
426
-			} else if ( is_object( $value ) ) {
427
-				$object_class = get_class( $value );
428
-				$info[ $object_class ] = array();
429
-				$info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : spl_object_hash( $value );
430
-				if ( method_exists( $value, 'ID' ) ) {
431
-					$info[ $object_class ][ 'ID' ] = $value->ID();
422
+	public static function strip_objects($info = array()) {
423
+		foreach ($info as $key => $value) {
424
+			if (is_array($value)) {
425
+				$info[$key] = self::strip_objects($value);
426
+			} else if (is_object($value)) {
427
+				$object_class = get_class($value);
428
+				$info[$object_class] = array();
429
+				$info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
430
+				if (method_exists($value, 'ID')) {
431
+					$info[$object_class]['ID'] = $value->ID();
432 432
 				}
433
-				if ( method_exists( $value, 'status' ) ) {
434
-					$info[ $object_class ][ 'status' ] = $value->status();
435
-				} else if ( method_exists( $value, 'status_ID' ) ) {
436
-					$info[ $object_class ][ 'status' ] = $value->status_ID();
433
+				if (method_exists($value, 'status')) {
434
+					$info[$object_class]['status'] = $value->status();
435
+				} else if (method_exists($value, 'status_ID')) {
436
+					$info[$object_class]['status'] = $value->status_ID();
437 437
 				}
438
-				unset( $info[ $key ] );
438
+				unset($info[$key]);
439 439
 			}
440 440
 		}
441
-		return (array)$info;
441
+		return (array) $info;
442 442
 	}
443 443
 
444 444
 
@@ -451,23 +451,23 @@  discard block
 block discarded – undo
451 451
 	 * @param int    $header
452 452
 	 * @param bool   $die
453 453
 	 */
454
-	public static function printv( $var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) {
454
+	public static function printv($var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false) {
455 455
 		$var_name = ! $var_name ? 'string' : $var_name;
456 456
 		$heading_tag = 'h';
457
-		$heading_tag .= is_int( $header ) ? $header : 5;
458
-		$var_name = ucwords( str_replace( '$', '', $var_name ) );
459
-		$is_method = method_exists( $var_name, $var );
460
-		$var_name = ucwords( str_replace( '_', ' ', $var_name ) );
457
+		$heading_tag .= is_int($header) ? $header : 5;
458
+		$var_name = ucwords(str_replace('$', '', $var_name));
459
+		$is_method = method_exists($var_name, $var);
460
+		$var_name = ucwords(str_replace('_', ' ', $var_name));
461 461
 		$margin = is_admin() ? ' 180px' : '0';
462
-		$result = '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0' . $margin . ';"><b>' . $var_name . '</b>';
462
+		$result = '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0'.$margin.';"><b>'.$var_name.'</b>';
463 463
 		$result .= $is_method
464
-			? '<span style="color:#999">::</span><span style="color:#E76700">' . $var . '()</span><br />'
465
-			: '<span style="color:#999"> : </span><span style="color:#E76700">' . $var . '</span><br />';
466
-		$result .= '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' . $file;
467
-		$result .= '<br />line no: ' . $line . '</span>';
468
-		$result .= '</' . $heading_tag . '>';
469
-		if ( $die ) {
470
-			die( $result );
464
+			? '<span style="color:#999">::</span><span style="color:#E76700">'.$var.'()</span><br />'
465
+			: '<span style="color:#999"> : </span><span style="color:#E76700">'.$var.'</span><br />';
466
+		$result .= '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'.$file;
467
+		$result .= '<br />line no: '.$line.'</span>';
468
+		$result .= '</'.$heading_tag.'>';
469
+		if ($die) {
470
+			die($result);
471 471
 		} else {
472 472
 			echo $result;
473 473
 		}
@@ -482,36 +482,36 @@  discard block
 block discarded – undo
482 482
 	 * @param int $header
483 483
 	 * @param bool $die
484 484
 	 */
485
-	public static function printr( $var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) {
485
+	public static function printr($var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false) {
486 486
 		// return;
487
-		$file = str_replace( rtrim( ABSPATH, '\\/' ), '', $file );
487
+		$file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
488 488
 		//$print_r = false;
489
-		if ( is_string( $var ) ) {
490
-			EEH_Debug_Tools::printv( $var, $var_name, $file, $line, $header, $die );
489
+		if (is_string($var)) {
490
+			EEH_Debug_Tools::printv($var, $var_name, $file, $line, $header, $die);
491 491
 			return;
492
-		} else if ( is_object( $var ) ) {
492
+		} else if (is_object($var)) {
493 493
 			$var_name = ! $var_name ? 'object' : $var_name;
494 494
 			//$print_r = true;
495
-		} else if ( is_array( $var ) ) {
495
+		} else if (is_array($var)) {
496 496
 			$var_name = ! $var_name ? 'array' : $var_name;
497 497
 			//$print_r = true;
498
-		} else if ( is_numeric( $var ) ) {
498
+		} else if (is_numeric($var)) {
499 499
 			$var_name = ! $var_name ? 'numeric' : $var_name;
500
-		} else if ( is_null( $var ) ) {
500
+		} else if (is_null($var)) {
501 501
 			$var_name = ! $var_name ? 'null' : $var_name;
502 502
 		}
503 503
 		$heading_tag = 'h';
504
-		$heading_tag .= is_int( $header ) ? $header : 5;
505
-		$var_name = ucwords( str_replace( array( '$', '_' ), array( '', ' ' ), $var_name ) );
504
+		$heading_tag .= is_int($header) ? $header : 5;
505
+		$var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
506 506
 		$margin = is_admin() ? ' 180px' : '0';
507
-		$result = '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0'.$margin.';"><b>' . $var_name . '</b>';
507
+		$result = '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0'.$margin.';"><b>'.$var_name.'</b>';
508 508
 		$result .= '<span style="color:#999;"> : </span><span style="color:#E76700;">';
509 509
 		$result .= '<pre style="color:#999; padding:1em; background: #fff">';
510
-		$result .= var_export( $var, true );
511
-		$result .= '</pre></span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;'.$margin.'">' . $file;
512
-		$result .= '<br />line no: ' . $line . '</span></' . $heading_tag . '>';
513
-		if ( $die ) {
514
-			die( $result );
510
+		$result .= var_export($var, true);
511
+		$result .= '</pre></span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;'.$margin.'">'.$file;
512
+		$result .= '<br />line no: '.$line.'</span></'.$heading_tag.'>';
513
+		if ($die) {
514
+			die($result);
515 515
 		} else {
516 516
 			echo $result;
517 517
 		}
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
  * borrowed from Kint Debugger
529 529
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
530 530
  */
531
-if ( class_exists('Kint') && ! function_exists( 'dump_wp_query' ) ) {
532
-	function dump_wp_query(){
531
+if (class_exists('Kint') && ! function_exists('dump_wp_query')) {
532
+	function dump_wp_query() {
533 533
 		global $wp_query;
534 534
 		d($wp_query);
535 535
 	}
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
  * borrowed from Kint Debugger
540 540
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
541 541
  */
542
-if ( class_exists('Kint') && ! function_exists( 'dump_wp' ) ) {
543
-	function dump_wp(){
542
+if (class_exists('Kint') && ! function_exists('dump_wp')) {
543
+	function dump_wp() {
544 544
 		global $wp;
545 545
 		d($wp);
546 546
 	}
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
  * borrowed from Kint Debugger
551 551
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
552 552
  */
553
-if ( class_exists('Kint') && ! function_exists( 'dump_post' ) ) {
554
-	function dump_post(){
553
+if (class_exists('Kint') && ! function_exists('dump_post')) {
554
+	function dump_post() {
555 555
 		global $post;
556 556
 		d($post);
557 557
 	}
Please login to merge, or discard this patch.
core/EE_Cron_Tasks.core.php 2 patches
Indentation   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @param int $PAY_ID
157 157
 	 */
158 158
 	public static function setup_update_for_transaction_with_payment( $TXN_ID = 0, $PAY_ID = 0 ) {
159
-            do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' );
159
+			do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' );
160 160
 		if ( absint( $TXN_ID )) {
161 161
 			self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID;
162 162
 			add_action(
@@ -289,7 +289,6 @@  discard block
 block discarded – undo
289 289
 
290 290
 	/**
291 291
 	 * finalize_abandoned_transactions
292
-	 
293 292
 	 * loops through the self::$_abandoned_transactions array
294 293
 	 * and attempts to finalize any TXNs that have not been completed
295 294
 	 * but have had their sessions expired, most likely due to a user not
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @return EE_Cron_Tasks
29 29
 	 */
30 30
 	public static function instance() {
31
-		if ( ! self::$_instance instanceof EE_Cron_Tasks ) {
31
+		if ( ! self::$_instance instanceof EE_Cron_Tasks) {
32 32
 			self::$_instance = new self();
33 33
 		}
34 34
 		return self::$_instance;
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 	 * @return EE_Cron_Tasks
42 42
 	 */
43 43
 	private function __construct() {
44
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__ );
44
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
45 45
 		// verify that WP Cron is enabled
46
-		if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON && is_admin() ) {
46
+		if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON && is_admin()) {
47 47
 			EE_Error::add_persistent_admin_notice(
48 48
 				'wp_cron_disabled',
49 49
 				sprintf(
@@ -58,26 +58,26 @@  discard block
 block discarded – undo
58 58
 		// UPDATE TRANSACTION WITH PAYMENT
59 59
 		add_action(
60 60
 			'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
61
-			array( 'EE_Cron_Tasks', 'setup_update_for_transaction_with_payment' ),
61
+			array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'),
62 62
 			10, 2
63 63
 		);
64 64
 		// FINALIZE ABANDONED TRANSACTIONS
65 65
 		add_action(
66 66
 			'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
67
-			array( 'EE_Cron_Tasks', 'check_for_abandoned_transactions' ),
67
+			array('EE_Cron_Tasks', 'check_for_abandoned_transactions'),
68 68
 			10, 1
69 69
 		);
70 70
 		// CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA
71 71
 		add_action(
72 72
 				'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
73
-				array( 'EE_Cron_Tasks', 'clean_out_junk_transactions' )
73
+				array('EE_Cron_Tasks', 'clean_out_junk_transactions')
74 74
 		);
75 75
 		// logging
76 76
 		add_action(
77 77
 			'AHEE__EE_System__load_core_configuration__complete',
78
-			array( 'EE_Cron_Tasks', 'log_scheduled_ee_crons' )
78
+			array('EE_Cron_Tasks', 'log_scheduled_ee_crons')
79 79
 		);
80
-		EE_Registry::instance()->load_lib( 'Messages_Scheduler' );
80
+		EE_Registry::instance()->load_lib('Messages_Scheduler');
81 81
 	}
82 82
 
83 83
 
@@ -92,17 +92,17 @@  discard block
 block discarded – undo
92 92
 			'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
93 93
 			'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
94 94
 		);
95
-		$crons = get_option( 'cron' );
96
-		if ( ! is_array( $crons ) ) {
95
+		$crons = get_option('cron');
96
+		if ( ! is_array($crons)) {
97 97
 			return;
98 98
 		}
99
-		foreach ( $crons as $timestamp => $cron ) {
100
-			foreach ( $ee_crons as $ee_cron ) {
101
-				if ( isset( $cron[ $ee_cron ] ) ) {
102
-					do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron' );
103
-					foreach ( $cron[ $ee_cron ] as $ee_cron_details ) {
104
-						if ( ! empty( $ee_cron_details[ 'args' ] )) {
105
-							do_action( 'AHEE_log', __CLASS__, __FUNCTION__, print_r( $ee_cron_details[ 'args' ], true ), "$ee_cron args" );
99
+		foreach ($crons as $timestamp => $cron) {
100
+			foreach ($ee_crons as $ee_cron) {
101
+				if (isset($cron[$ee_cron])) {
102
+					do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron');
103
+					foreach ($cron[$ee_cron] as $ee_cron_details) {
104
+						if ( ! empty($ee_cron_details['args'])) {
105
+							do_action('AHEE_log', __CLASS__, __FUNCTION__, print_r($ee_cron_details['args'], true), "$ee_cron args");
106 106
 						}
107 107
 					}
108 108
 				}
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 		$TXN_ID,
140 140
 		$PAY_ID
141 141
 	) {
142
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__ );
142
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
143 143
 		// validate $TXN_ID and $timestamp
144
-		$TXN_ID = absint( $TXN_ID );
145
-		$timestamp = absint( $timestamp );
146
-		if ( $TXN_ID && $timestamp ) {
144
+		$TXN_ID = absint($TXN_ID);
145
+		$timestamp = absint($timestamp);
146
+		if ($TXN_ID && $timestamp) {
147 147
 			wp_schedule_single_event(
148 148
 				$timestamp,
149 149
 				'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
150
-				array( $TXN_ID, $PAY_ID )
150
+				array($TXN_ID, $PAY_ID)
151 151
 			);
152 152
 		}
153 153
 	}
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
 	 * @param int  $TXN_ID
170 170
 	 * @param int $PAY_ID
171 171
 	 */
172
-	public static function setup_update_for_transaction_with_payment( $TXN_ID = 0, $PAY_ID = 0 ) {
173
-            do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' );
174
-		if ( absint( $TXN_ID )) {
175
-			self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID;
172
+	public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0) {
173
+            do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
174
+		if (absint($TXN_ID)) {
175
+			self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID;
176 176
 			add_action(
177 177
 				'shutdown',
178
-				array( 'EE_Cron_Tasks', 'update_transaction_with_payment' ),
178
+				array('EE_Cron_Tasks', 'update_transaction_with_payment'),
179 179
 				5
180 180
 			);
181 181
 		}
@@ -194,18 +194,18 @@  discard block
 block discarded – undo
194 194
 	 * @throws \EE_Error
195 195
 	 */
196 196
 	public static function update_transaction_with_payment() {
197
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__ );
197
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
198 198
 		// are there any TXNs that need cleaning up ?
199
-		if ( ! empty( self::$_update_transactions_with_payment ) ) {
199
+		if ( ! empty(self::$_update_transactions_with_payment)) {
200 200
 			/** @type EE_Payment_Processor $payment_processor */
201
-			$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
201
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
202 202
 			// set revisit flag for payment processor
203
-			$payment_processor->set_revisit( false );
203
+			$payment_processor->set_revisit(false);
204 204
 			// load EEM_Transaction
205
-			EE_Registry::instance()->load_model( 'Transaction' );
206
-			foreach ( self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID ) {
205
+			EE_Registry::instance()->load_model('Transaction');
206
+			foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) {
207 207
 				// reschedule the cron if we can't hit the db right now
208
-				if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) {
208
+				if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
209 209
 					// reset cron job for updating the TXN
210 210
 					EE_Cron_Tasks::schedule_update_transaction_with_payment(
211 211
 						time() + EE_Cron_Tasks::reschedule_timeout,
@@ -214,14 +214,14 @@  discard block
 block discarded – undo
214 214
 					);
215 215
 					continue;
216 216
 				}
217
-				$transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
218
-				$payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID );
217
+				$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
218
+				$payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
219 219
 				// verify transaction
220
-				if ( $transaction instanceof EE_Transaction && $payment instanceof EE_Payment ) {
220
+				if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) {
221 221
 					// now try to update the TXN with any payments
222
-					$payment_processor->update_txn_based_on_payment( $transaction, $payment, true, true );
222
+					$payment_processor->update_txn_based_on_payment($transaction, $payment, true, true);
223 223
 				}
224
-				unset( self::$_update_transactions_with_payment[ $TXN_ID ] );
224
+				unset(self::$_update_transactions_with_payment[$TXN_ID]);
225 225
 			}
226 226
 		}
227 227
 	}
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
 		$TXN_ID
259 259
 	) {
260 260
 		// validate $TXN_ID and $timestamp
261
-		$TXN_ID = absint( $TXN_ID );
262
-		$timestamp = absint( $timestamp );
263
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' );
264
-		if ( $TXN_ID && $timestamp ) {
261
+		$TXN_ID = absint($TXN_ID);
262
+		$timestamp = absint($timestamp);
263
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
264
+		if ($TXN_ID && $timestamp) {
265 265
 			wp_schedule_single_event(
266 266
 				$timestamp,
267 267
 				'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
268
-				array( $TXN_ID )
268
+				array($TXN_ID)
269 269
 			);
270 270
 		}
271 271
 	}
@@ -287,13 +287,13 @@  discard block
 block discarded – undo
287 287
 	 *
288 288
 	 * @param int $TXN_ID
289 289
 	 */
290
-	public static function check_for_abandoned_transactions(	$TXN_ID = 0 ) {
291
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' );
292
-		if ( absint( $TXN_ID )) {
293
-			self::$_abandoned_transactions[]  = $TXN_ID;
290
+	public static function check_for_abandoned_transactions($TXN_ID = 0) {
291
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
292
+		if (absint($TXN_ID)) {
293
+			self::$_abandoned_transactions[] = $TXN_ID;
294 294
 			add_action(
295 295
 				'shutdown',
296
-				array( 'EE_Cron_Tasks', 'finalize_abandoned_transactions' ),
296
+				array('EE_Cron_Tasks', 'finalize_abandoned_transactions'),
297 297
 				5
298 298
 			);
299 299
 		}
@@ -312,21 +312,21 @@  discard block
 block discarded – undo
312 312
 	 * @throws \EE_Error
313 313
 	 */
314 314
 	public static function finalize_abandoned_transactions() {
315
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__ );
315
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
316 316
 		// are there any TXNs that need cleaning up ?
317
-		if ( ! empty( self::$_abandoned_transactions ) ) {
317
+		if ( ! empty(self::$_abandoned_transactions)) {
318 318
 			/** @type EE_Transaction_Processor $transaction_processor */
319
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
319
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
320 320
 			// set revisit flag for txn processor
321
-			$transaction_processor->set_revisit( false );
321
+			$transaction_processor->set_revisit(false);
322 322
 			/** @type EE_Payment_Processor $payment_processor */
323
-			$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
323
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
324 324
 			// load EEM_Transaction
325
-			EE_Registry::instance()->load_model( 'Transaction' );
326
-			foreach ( self::$_abandoned_transactions as $TXN_ID ) {
327
-				do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' );
325
+			EE_Registry::instance()->load_model('Transaction');
326
+			foreach (self::$_abandoned_transactions as $TXN_ID) {
327
+				do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
328 328
 				// reschedule the cron if we can't hit the db right now
329
-				if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) {
329
+				if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
330 330
 					// reset cron job for finalizing the TXN
331 331
 					EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check(
332 332
 						time() + EE_Cron_Tasks::reschedule_timeout,
@@ -334,17 +334,17 @@  discard block
 block discarded – undo
334 334
 					);
335 335
 					continue;
336 336
 				}
337
-				$transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
337
+				$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
338 338
 				// verify transaction
339
-				if ( $transaction instanceof EE_Transaction ) {
339
+				if ($transaction instanceof EE_Transaction) {
340 340
 					// don't finalize the TXN if it has already been completed
341
-					if ( $transaction_processor->all_reg_steps_completed( $transaction ) === true ) {
341
+					if ($transaction_processor->all_reg_steps_completed($transaction) === true) {
342 342
 						continue;
343 343
 					}
344 344
 					// let's simulate an IPN here which will trigger any notifications that need to go out
345
-					$payment_processor->update_txn_based_on_payment( $transaction, $transaction->last_payment(), true, true );
345
+					$payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true, true);
346 346
 				}
347
-				unset( self::$_abandoned_transactions[ $TXN_ID ] );
347
+				unset(self::$_abandoned_transactions[$TXN_ID]);
348 348
 			}
349 349
 		}
350 350
 	}
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	//when a transaction is initially made, schedule this check.
361 361
 	//if it has NO REG data by the time it has expired, forget about it
362 362
 	public static function clean_out_junk_transactions() {
363
-		if( EE_Maintenance_Mode::instance()->models_can_query() ) {
363
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
364 364
 			EEM_Transaction::instance('')->delete_junk_transactions();
365 365
 			EEM_Registration::instance('')->delete_registrations_with_no_transaction();
366 366
 			EEM_Line_Item::instance('')->delete_line_items_with_no_transaction();
Please login to merge, or discard this patch.
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
  /**
3
- *
4
- * Class EE_SPCO_Reg_Step_Attendee_Information
5
- *
6
- * Description
7
- *
8
- * @package 			Event Espresso
9
- * @subpackage 	core
10
- * @author 				Brent Christensen
11
- * @since 				4.5.0
12
- *
13
- */
3
+  *
4
+  * Class EE_SPCO_Reg_Step_Attendee_Information
5
+  *
6
+  * Description
7
+  *
8
+  * @package 			Event Espresso
9
+  * @subpackage 	core
10
+  * @author 				Brent Christensen
11
+  * @since 				4.5.0
12
+  *
13
+  */
14 14
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step {
15 15
 
16 16
 	/**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 				// generate hidden input
172 172
 				if (
173 173
 					isset( $subsections[ $primary_registrant ] )
174
-				     && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
174
+					 && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
175 175
 				) {
176 176
 					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
177 177
 				}
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 					if ( isset( $valid_data[ $reg_url_link ] ) ) {
903 903
 						// do we need to copy basic info from primary attendee ?
904 904
 						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] )
905
-						                && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
905
+										&& absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
906 906
 							? true
907 907
 							: false;
908 908
 						// filter form input data for this registration
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 			? $form_input
1080 1080
 			: $form_input . '-' . $registration->reg_url_link();
1081 1081
 		$answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] )
1082
-		                 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1082
+						 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1083 1083
 			? true
1084 1084
 			: false;
1085 1085
 		//rename form_inputs if they are EE_Attendee properties
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
 		}
1320 1320
 		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1321 1321
 			if ( ! isset( $attendee_data[ $critical_attendee_detail ] )
1322
-			     || empty( $attendee_data[ $critical_attendee_detail ] )
1322
+				 || empty( $attendee_data[ $critical_attendee_detail ] )
1323 1323
 			) {
1324 1324
 				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1325 1325
 					$critical_attendee_detail
Please login to merge, or discard this patch.
Spacing   +233 added lines, -234 removed lines patch added patch discarded remove patch
@@ -42,21 +42,21 @@  discard block
 block discarded – undo
42 42
 	 * @param    EE_Checkout $checkout
43 43
 	 * @return    \EE_SPCO_Reg_Step_Attendee_Information
44 44
 	 */
45
-	public function __construct( EE_Checkout $checkout ) {
45
+	public function __construct(EE_Checkout $checkout) {
46 46
 		$this->_slug = 'attendee_information';
47 47
 		$this->_name = __('Attendee Information', 'event_espresso');
48
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
48
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php';
49 49
 		$this->checkout = $checkout;
50 50
 		$this->_reset_success_message();
51 51
 		$this->set_instructions(
52
-			__( 'Please answer the following registration questions before proceeding.', 'event_espresso' )
52
+			__('Please answer the following registration questions before proceeding.', 'event_espresso')
53 53
 		);
54 54
 	}
55 55
 
56 56
 
57 57
 
58 58
 	public function translate_js_strings() {
59
-		EE_Registry::$i18n_js_strings['required_field'] = __( ' is a required question.', 'event_espresso' );
59
+		EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso');
60 60
 		EE_Registry::$i18n_js_strings['required_multi_field'] = __(
61 61
 			' is a required question. Please enter a value for at least one of the options.',
62 62
 			'event_espresso'
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		// calculate taxes
117 117
 		$Line_Item_Display->display_line_item(
118 118
 			$this->checkout->cart->get_grand_total(),
119
-			array( 'set_tax_rate' => true )
119
+			array('set_tax_rate' => true)
120 120
 		);
121 121
 		/** @var $subsections EE_Form_Section_Proper[] */
122 122
 		$subsections = array(
@@ -128,51 +128,51 @@  discard block
 block discarded – undo
128 128
 			'ticket_count' 	=> array()
129 129
 		);
130 130
 		// grab the saved registrations from the transaction
131
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
132
-		if ( $registrations ) {
133
-			foreach ( $registrations as $registration ) {
131
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
132
+		if ($registrations) {
133
+			foreach ($registrations as $registration) {
134 134
 				// can this registration be processed during this visit ?
135 135
 				if (
136 136
 					$registration instanceof EE_Registration
137
-					&& $this->checkout->visit_allows_processing_of_this_registration( $registration )
137
+					&& $this->checkout->visit_allows_processing_of_this_registration($registration)
138 138
 				) {
139
-					$subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form( $registration );
140
-					if ( ! $this->checkout->admin_request ) {
141
-						$template_args['registrations'][ $registration->reg_url_link() ] = $registration;
142
-						$template_args['ticket_count'][ $registration->ticket()->ID() ] = isset(
143
-							$template_args['ticket_count'][ $registration->ticket()->ID() ]
139
+					$subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
140
+					if ( ! $this->checkout->admin_request) {
141
+						$template_args['registrations'][$registration->reg_url_link()] = $registration;
142
+						$template_args['ticket_count'][$registration->ticket()->ID()] = isset(
143
+							$template_args['ticket_count'][$registration->ticket()->ID()]
144 144
 						)
145
-							? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1
145
+							? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
146 146
 							: 1;
147 147
 						$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
148 148
 							$this->checkout->cart->get_grand_total(),
149 149
 							'Ticket',
150
-							array( $registration->ticket()->ID() )
150
+							array($registration->ticket()->ID())
151 151
 						);
152
-						$ticket_line_item = is_array( $ticket_line_item )
153
-							? reset( $ticket_line_item )
152
+						$ticket_line_item = is_array($ticket_line_item)
153
+							? reset($ticket_line_item)
154 154
 							: $ticket_line_item;
155
-						$template_args['ticket_line_item'][ $registration->ticket()->ID() ] = $Line_Item_Display->display_line_item(
155
+						$template_args['ticket_line_item'][$registration->ticket()->ID()] = $Line_Item_Display->display_line_item(
156 156
 							$ticket_line_item
157 157
 						);
158 158
 					}
159
-					if ( $registration->is_primary_registrant() ) {
159
+					if ($registration->is_primary_registrant()) {
160 160
 						$primary_registrant = $registration->reg_url_link();
161 161
 					}
162 162
 				}
163 163
 			}
164 164
 			// print_copy_info ?
165
-			if ( $primary_registrant && ! $this->checkout->admin_request && count( $registrations ) > 1 ) {
165
+			if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) {
166 166
 				// TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info
167 167
 				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
168 168
 					? $this->_copy_attendee_info_form()
169 169
 					: $this->_auto_copy_attendee_info();
170 170
 				// generate hidden input
171 171
 				if (
172
-					isset( $subsections[ $primary_registrant ] )
173
-				     && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
172
+					isset($subsections[$primary_registrant])
173
+				     && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper
174 174
 				) {
175
-					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
175
+					$subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false);
176 176
 				}
177 177
 			}
178 178
 
@@ -184,8 +184,7 @@  discard block
 block discarded – undo
184 184
 				'html_id' 					=> $this->reg_form_name(),
185 185
 				'subsections' 			=> $subsections,
186 186
 				'layout_strategy'		=> $this->checkout->admin_request ?
187
-					new EE_Div_Per_Section_Layout() :
188
-					new EE_Template_Layout(
187
+					new EE_Div_Per_Section_Layout() : new EE_Template_Layout(
189 188
 						array(
190 189
 							'layout_template_file' 	=> $this->_template, // layout_template
191 190
 							'template_args' 				=> $template_args
@@ -203,11 +202,11 @@  discard block
 block discarded – undo
203 202
 	 * @return EE_Form_Section_Proper
204 203
 	 * @throws \EE_Error
205 204
 	 */
206
-	private function _registrations_reg_form( EE_Registration $registration ) {
205
+	private function _registrations_reg_form(EE_Registration $registration) {
207 206
 		static $attendee_nmbr = 1;
208 207
 		// array of params to pass to parent constructor
209 208
 		$form_args = array(
210
-			'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
209
+			'html_id'         => 'ee-registration-'.$registration->reg_url_link(),
211 210
 			'html_class'      => 'ee-reg-form-attendee-dv',
212 211
 			'html_style'      => $this->checkout->admin_request
213 212
 				? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
@@ -216,24 +215,24 @@  discard block
 block discarded – undo
216 215
 			'layout_strategy' => new EE_Fieldset_Section_Layout(
217 216
 				array(
218 217
 					'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
219
-					'legend_text'  => sprintf( __( 'Attendee %d', 'event_espresso' ), $attendee_nmbr )
218
+					'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr)
220 219
 				)
221 220
 			)
222 221
 		);
223 222
 		// verify that registration has valid event
224
-		if ( $registration->event() instanceof EE_Event ) {
223
+		if ($registration->event() instanceof EE_Event) {
225 224
 			$query_params = array(
226 225
 				array(
227 226
 					'Event.EVT_ID' => $registration->event()->ID(),
228 227
 					'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false
229 228
 				),
230
-				'order_by'=>array( 'QSG_order'=>'ASC' )
229
+				'order_by'=>array('QSG_order'=>'ASC')
231 230
 			);
232
-			$question_groups = $registration->event()->question_groups( $query_params );
233
-			if ( $question_groups ) {
234
-				foreach ( $question_groups as $question_group ) {
235
-					if ( $question_group instanceof EE_Question_Group ) {
236
-						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
231
+			$question_groups = $registration->event()->question_groups($query_params);
232
+			if ($question_groups) {
233
+				foreach ($question_groups as $question_group) {
234
+					if ($question_group instanceof EE_Question_Group) {
235
+						$form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form(
237 236
 							$registration,
238 237
 							$question_group
239 238
 						);
@@ -246,10 +245,10 @@  discard block
 block discarded – undo
246 245
 				// if we have question groups for additional attendees, then display the copy options
247 246
 				$this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info;
248 247
 			} else {
249
-				$form_args['subsections'][ 'attendee_info_not_required_' . $registration->reg_url_link(
250
-				) ] = new EE_Form_Section_HTML(
248
+				$form_args['subsections']['attendee_info_not_required_'.$registration->reg_url_link(
249
+				)] = new EE_Form_Section_HTML(
251 250
 					EEH_Template::locate_template(
252
-						SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_not_required.template.php',
251
+						SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_not_required.template.php',
253 252
 						apply_filters(
254 253
 							'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__attendee_info_not_required_template_args',
255 254
 							array()
@@ -265,12 +264,12 @@  discard block
 block discarded – undo
265 264
 				);
266 265
 			}
267 266
 		}
268
-		if ( $registration->is_primary_registrant() ) {
267
+		if ($registration->is_primary_registrant()) {
269 268
 			// generate hidden input
270
-			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( $registration );
269
+			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration);
271 270
 		}
272 271
 		$attendee_nmbr++;
273
-		return new EE_Form_Section_Proper( $form_args );
272
+		return new EE_Form_Section_Proper($form_args);
274 273
 	}
275 274
 
276 275
 
@@ -291,7 +290,7 @@  discard block
 block discarded – undo
291 290
 		// generate hidden input
292 291
 		return new EE_Hidden_Input(
293 292
 			array(
294
-				'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
293
+				'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(),
295 294
 				'default' => $additional_attendee_reg_info
296 295
 			)
297 296
 		);
@@ -305,26 +304,26 @@  discard block
 block discarded – undo
305 304
 	 * @return EE_Form_Section_Proper
306 305
 	 * @throws \EE_Error
307 306
 	 */
308
-	private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){
307
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) {
309 308
 		// array of params to pass to parent constructor
310 309
 		$form_args = array(
311
-			'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
310
+			'html_id'         => 'ee-reg-form-qstn-grp-'.$question_group->identifier(),
312 311
 			'html_class'      => $this->checkout->admin_request
313 312
 				? 'form-table ee-reg-form-qstn-grp-dv'
314 313
 				: 'ee-reg-form-qstn-grp-dv',
315
-			'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
314
+			'html_label_id'   => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl',
316 315
 			'subsections'     => array(
317
-				'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group )
316
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group)
318 317
 			),
319 318
 			'layout_strategy' => $this->checkout->admin_request
320 319
 				? new EE_Admin_Two_Column_Layout()
321 320
 				: new EE_Div_Per_Section_Layout()
322 321
 		);
323 322
 		// where params
324
-		$query_params = array( 'QST_deleted' => 0 );
323
+		$query_params = array('QST_deleted' => 0);
325 324
 		// don't load admin only questions on the frontend
326
-		if ( ! $this->checkout->admin_request ) {
327
-			$query_params['QST_admin_only'] = array( '!=', true );
325
+		if ( ! $this->checkout->admin_request) {
326
+			$query_params['QST_admin_only'] = array('!=', true);
328 327
 		}
329 328
 		$questions = $question_group->get_many_related(
330 329
 			'Question',
@@ -346,10 +345,10 @@  discard block
 block discarded – undo
346 345
 			)
347 346
 		);
348 347
 		// loop thru questions
349
-		foreach ( $questions as $question ) {
350
-			if( $question instanceof EE_Question ){
348
+		foreach ($questions as $question) {
349
+			if ($question instanceof EE_Question) {
351 350
 				$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
352
-				$form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question );
351
+				$form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
353 352
 			}
354 353
 		}
355 354
 		$form_args['subsections'] = apply_filters(
@@ -370,7 +369,7 @@  discard block
 block discarded – undo
370 369
 			)
371 370
 		);
372 371
 //		d( $form_args );
373
-		$question_group_reg_form = new EE_Form_Section_Proper( $form_args );
372
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
374 373
 		return apply_filters(
375 374
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
376 375
 			$question_group_reg_form,
@@ -387,11 +386,11 @@  discard block
 block discarded – undo
387 386
 	 * @param EE_Question_Group $question_group
388 387
 	 * @return 	EE_Form_Section_HTML
389 388
 	 */
390
-	private function _question_group_header( EE_Question_Group $question_group ){
389
+	private function _question_group_header(EE_Question_Group $question_group) {
391 390
 		$html = '';
392 391
 		// group_name
393
-		if ( $question_group->show_group_name() && $question_group->name() !== '' ) {
394
-			if ( $this->checkout->admin_request ) {
392
+		if ($question_group->show_group_name() && $question_group->name() !== '') {
393
+			if ($this->checkout->admin_request) {
395 394
 				$html .= EEH_HTML::br();
396 395
 				$html .= EEH_HTML::h3(
397 396
 					$question_group->name(),
@@ -405,7 +404,7 @@  discard block
 block discarded – undo
405 404
 			}
406 405
 		}
407 406
 		// group_desc
408
-		if ( $question_group->show_group_desc() && $question_group->desc() !== '' ) {
407
+		if ($question_group->show_group_desc() && $question_group->desc() !== '') {
409 408
 			$html .= EEH_HTML::p(
410 409
 				$question_group->desc(),
411 410
 				'',
@@ -415,7 +414,7 @@  discard block
 block discarded – undo
415 414
 			);
416 415
 
417 416
 		}
418
-		return new EE_Form_Section_HTML( $html );
417
+		return new EE_Form_Section_HTML($html);
419 418
 	}
420 419
 
421 420
 
@@ -425,7 +424,7 @@  discard block
 block discarded – undo
425 424
 	 * @return    EE_Form_Section_Proper
426 425
 	 * @throws \EE_Error
427 426
 	 */
428
-	private function _copy_attendee_info_form(){
427
+	private function _copy_attendee_info_form() {
429 428
 		// array of params to pass to parent constructor
430 429
 		return new EE_Form_Section_Proper(
431 430
 			array(
@@ -454,7 +453,7 @@  discard block
 block discarded – undo
454 453
 	private function _auto_copy_attendee_info() {
455 454
 		return new EE_Form_Section_HTML(
456 455
 			EEH_Template::locate_template(
457
-				SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
456
+				SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php',
458 457
 				apply_filters(
459 458
 					'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
460 459
 					array()
@@ -478,32 +477,32 @@  discard block
 block discarded – undo
478 477
 		$copy_attendee_info_inputs = array();
479 478
 		$prev_ticket = NULL;
480 479
 		// grab the saved registrations from the transaction
481
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
482
-		foreach ( $registrations as $registration ) {
480
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
481
+		foreach ($registrations as $registration) {
483 482
 			// for all  attendees other than the primary attendee
484
-			if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) {
483
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
485 484
 				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
486
-				if ( $registration->ticket()->ID() !== $prev_ticket ) {
485
+				if ($registration->ticket()->ID() !== $prev_ticket) {
487 486
 					$item_name = $registration->ticket()->name();
488 487
 					$item_name .= $registration->ticket()->description() !== ''
489
-						? ' - ' . $registration->ticket()->description()
488
+						? ' - '.$registration->ticket()->description()
490 489
 						: '';
491
-					$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML(
492
-						'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
490
+					$copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML(
491
+						'<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>'
493 492
 					);
494 493
 					$prev_ticket = $registration->ticket()->ID();
495 494
 				}
496 495
 
497
-				$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new
496
+				$copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new
498 497
 				EE_Checkbox_Multi_Input(
499 498
 					array(
500 499
 						$registration->ID() => sprintf(
501
-							__( 'Attendee #%s', 'event_espresso' ),
500
+							__('Attendee #%s', 'event_espresso'),
502 501
 							$registration->count()
503 502
 						)
504 503
 					),
505 504
 					array(
506
-						'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
505
+						'html_id'                 => 'spco-copy-attendee-chk-'.$registration->reg_url_link(),
507 506
 						'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
508 507
 						'display_html_label_text' => false
509 508
 					)
@@ -523,7 +522,7 @@  discard block
 block discarded – undo
523 522
 	 * @return    EE_Form_Input_Base
524 523
 	 * @throws \EE_Error
525 524
 	 */
526
-	private function _additional_primary_registrant_inputs( EE_Registration $registration ){
525
+	private function _additional_primary_registrant_inputs(EE_Registration $registration) {
527 526
 		// generate hidden input
528 527
 		return new EE_Hidden_Input(
529 528
 			array(
@@ -542,7 +541,7 @@  discard block
 block discarded – undo
542 541
 	 * @return    EE_Form_Input_Base
543 542
 	 * @throws \EE_Error
544 543
 	 */
545
-	public function reg_form_question( EE_Registration $registration, EE_Question $question ){
544
+	public function reg_form_question(EE_Registration $registration, EE_Question $question) {
546 545
 
547 546
 		// if this question was for an attendee detail, then check for that answer
548 547
 		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
@@ -551,32 +550,32 @@  discard block
 block discarded – undo
551 550
 		);
552 551
 		$answer = $answer_value === null
553 552
 			? EEM_Answer::instance()->get_one(
554
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
553
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
555 554
 			)
556 555
 			: null;
557 556
 		// if NOT returning to edit an existing registration
558 557
 		// OR if this question is for an attendee property
559 558
 		// OR we still don't have an EE_Answer object
560
-		if( $answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link() ) {
559
+		if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
561 560
 			// create an EE_Answer object for storing everything in
562
-			$answer = EE_Answer::new_instance ( array(
561
+			$answer = EE_Answer::new_instance(array(
563 562
 				'QST_ID'=> $question->ID(),
564 563
 				'REG_ID'=> $registration->ID()
565 564
 			));
566 565
 		}
567 566
 		// verify instance
568
-		if( $answer instanceof EE_Answer ){
569
-			if ( ! empty( $answer_value )) {
570
-				$answer->set( 'ANS_value', $answer_value );
567
+		if ($answer instanceof EE_Answer) {
568
+			if ( ! empty($answer_value)) {
569
+				$answer->set('ANS_value', $answer_value);
571 570
 			}
572
-			$answer->cache( 'Question', $question );
571
+			$answer->cache('Question', $question);
573 572
 			//remember system ID had a bug where sometimes it could be null
574
-			$answer_cache_id =$question->is_system_question()
575
-				? $question->system_ID() . '-' . $registration->reg_url_link()
576
-				: $question->ID() . '-' . $registration->reg_url_link();			
577
-			$registration->cache( 'Answer', $answer, $answer_cache_id );
573
+			$answer_cache_id = $question->is_system_question()
574
+				? $question->system_ID().'-'.$registration->reg_url_link()
575
+				: $question->ID().'-'.$registration->reg_url_link();			
576
+			$registration->cache('Answer', $answer, $answer_cache_id);
578 577
 		}
579
-		return $this->_generate_question_input( $registration, $question, $answer );
578
+		return $this->_generate_question_input($registration, $question, $answer);
580 579
 
581 580
 	}
582 581
 
@@ -589,46 +588,46 @@  discard block
 block discarded – undo
589 588
 	 * @return EE_Form_Input_Base
590 589
 	 * @throws \EE_Error
591 590
 	 */
592
-	private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){
591
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) {
593 592
 		$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
594
-		$this->_required_questions[ $identifier ] = $question->required() ? true : false;
593
+		$this->_required_questions[$identifier] = $question->required() ? true : false;
595 594
 		add_filter(
596 595
 			'FHEE__EE_Question__generate_form_input__country_options',
597
-			array( $this, 'use_cached_countries_for_form_input' ),
596
+			array($this, 'use_cached_countries_for_form_input'),
598 597
 			10,
599 598
 			4
600 599
 		);
601 600
 		add_filter(
602 601
 			'FHEE__EE_Question__generate_form_input__state_options',
603
-			array( $this, 'use_cached_states_for_form_input' ),
602
+			array($this, 'use_cached_states_for_form_input'),
604 603
 			10,
605 604
 			4
606 605
 		);
607 606
 		$input_constructor_args = array(
608
-			'html_name'     => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
609
-			'html_id'       => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
610
-			'html_class'    => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
611
-			'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
607
+			'html_name'     => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']',
608
+			'html_id'       => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
609
+			'html_class'    => 'ee-reg-qstn ee-reg-qstn-'.$identifier,
610
+			'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
612 611
 			'html_label_class'	=> 'ee-reg-qstn',
613 612
 		);
614
-		$input_constructor_args['html_label_id'] 	.= '-lbl';
615
-		if ( $answer instanceof EE_Answer && $answer->ID() ) {
616
-			$input_constructor_args[ 'html_name' ] .= '[' . $answer->ID() . ']';
617
-			$input_constructor_args[ 'html_id' ] .= '-' . $answer->ID();
618
-			$input_constructor_args[ 'html_label_id' ] .= '-' . $answer->ID();
613
+		$input_constructor_args['html_label_id'] .= '-lbl';
614
+		if ($answer instanceof EE_Answer && $answer->ID()) {
615
+			$input_constructor_args['html_name'] .= '['.$answer->ID().']';
616
+			$input_constructor_args['html_id'] .= '-'.$answer->ID();
617
+			$input_constructor_args['html_label_id'] .= '-'.$answer->ID();
619 618
 		}
620
-		$form_input =  $question->generate_form_input(
619
+		$form_input = $question->generate_form_input(
621 620
 			$registration,
622 621
 			$answer,
623 622
 			$input_constructor_args
624 623
 		);
625 624
 		remove_filter(
626 625
 			'FHEE__EE_Question__generate_form_input__country_options',
627
-			array( $this, 'use_cached_countries_for_form_input' )
626
+			array($this, 'use_cached_countries_for_form_input')
628 627
 		);
629 628
 		remove_filter(
630 629
 			'FHEE__EE_Question__generate_form_input__state_options',
631
-			array( $this, 'use_cached_states_for_form_input' )
630
+			array($this, 'use_cached_states_for_form_input')
632 631
 		);
633 632
 		return $form_input;
634 633
 	}
@@ -642,23 +641,23 @@  discard block
 block discarded – undo
642 641
 	 * @return array 2d keys are country IDs, values are their names
643 642
 	 * @throws \EE_Error
644 643
 	 */
645
-	public function use_cached_countries_for_form_input( $countries_list, $question, $registration, $answer ) {
646
-		$country_options = array( '' => '' );
644
+	public function use_cached_countries_for_form_input($countries_list, $question, $registration, $answer) {
645
+		$country_options = array('' => '');
647 646
 		// get possibly cached list of countries
648 647
 		$countries = $this->checkout->action === 'process_reg_step'
649 648
 			? EEM_Country::instance()->get_all_countries()
650 649
 			: EEM_Country::instance()->get_all_active_countries();
651
-		if ( ! empty( $countries )) {
652
-			foreach( $countries as $country ){
653
-				if ( $country instanceof EE_Country ) {
654
-					$country_options[ $country->ID() ] = $country->name();
650
+		if ( ! empty($countries)) {
651
+			foreach ($countries as $country) {
652
+				if ($country instanceof EE_Country) {
653
+					$country_options[$country->ID()] = $country->name();
655 654
 				}
656 655
 			}
657 656
 		}
658
-		if( $question instanceof EE_Question
659
-			&& $registration instanceof EE_Registration ) {
657
+		if ($question instanceof EE_Question
658
+			&& $registration instanceof EE_Registration) {
660 659
 			$answer = EEM_Answer::instance()->get_one(
661
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
660
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
662 661
 			);
663 662
 		} else {
664 663
 			$answer = EE_Answer::new_instance();
@@ -685,15 +684,15 @@  discard block
 block discarded – undo
685 684
 	 * @return array 2d keys are state IDs, values are their names
686 685
 	 * @throws \EE_Error
687 686
 	 */
688
-	public function use_cached_states_for_form_input( $states_list, $question, $registration, $answer ) {
689
-		$state_options = array( '' => array( '' => ''));
687
+	public function use_cached_states_for_form_input($states_list, $question, $registration, $answer) {
688
+		$state_options = array('' => array('' => ''));
690 689
 		$states = $this->checkout->action === 'process_reg_step'
691 690
 			? EEM_State::instance()->get_all_states()
692 691
 			: EEM_State::instance()->get_all_active_states();
693
-		if ( ! empty( $states )) {
694
-			foreach( $states as $state ){
695
-				if ( $state instanceof EE_State ) {
696
-					$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
692
+		if ( ! empty($states)) {
693
+			foreach ($states as $state) {
694
+				if ($state instanceof EE_State) {
695
+					$state_options[$state->country()->name()][$state->ID()] = $state->name();
697 696
 				}
698 697
 			}
699 698
 		}
@@ -721,24 +720,24 @@  discard block
 block discarded – undo
721 720
 	 * @throws \EE_Error
722 721
 	 */
723 722
 	public function process_reg_step() {
724
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
723
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
725 724
 		// grab validated data from form
726 725
 		$valid_data = $this->checkout->current_step->valid_data();
727 726
 		// EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
728 727
 		// EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
729 728
 		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
730
-		if ( empty( $valid_data ))  {
729
+		if (empty($valid_data)) {
731 730
 			EE_Error::add_error(
732
-				__( 'No valid question responses were received.', 'event_espresso' ),
731
+				__('No valid question responses were received.', 'event_espresso'),
733 732
 				__FILE__,
734 733
 				__FUNCTION__,
735 734
 				__LINE__
736 735
 			);
737 736
 			return false;
738 737
 		}
739
-		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) {
738
+		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
740 739
 			EE_Error::add_error(
741
-				__( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ),
740
+				__('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'),
742 741
 				__FILE__,
743 742
 				__FUNCTION__,
744 743
 				__LINE__
@@ -746,11 +745,11 @@  discard block
 block discarded – undo
746 745
 			return false;
747 746
 		}
748 747
 		// get cached registrations
749
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
748
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
750 749
 		// verify we got the goods
751
-		if ( empty( $registrations )) {
750
+		if (empty($registrations)) {
752 751
 			EE_Error::add_error(
753
-				__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ),
752
+				__('Your form data could not be applied to any valid registrations.', 'event_espresso'),
754 753
 				__FILE__,
755 754
 				__FUNCTION__,
756 755
 				__LINE__
@@ -758,15 +757,15 @@  discard block
 block discarded – undo
758 757
 			return false;
759 758
 		}
760 759
 		// extract attendee info from form data and save to model objects
761
-		$registrations_processed = $this->_process_registrations( $registrations, $valid_data );
760
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
762 761
 		// if first pass thru SPCO,
763 762
 		// then let's check processed registrations against the total number of tickets in the cart
764
-		if ( $registrations_processed === false ) {
763
+		if ($registrations_processed === false) {
765 764
 			// but return immediately if the previous step exited early due to errors
766 765
 			return false;
767
-		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) {
766
+		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
768 767
 			// generate a correctly translated string for all possible singular/plural combinations
769
-			if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) {
768
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
770 769
 				$error_msg = sprintf(
771 770
 					__(
772 771
 						'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
@@ -775,7 +774,7 @@  discard block
 block discarded – undo
775 774
 					$this->checkout->total_ticket_count,
776 775
 					$registrations_processed
777 776
 				);
778
-			} else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) {
777
+			} else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
779 778
 				$error_msg = sprintf(
780 779
 					__(
781 780
 						'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
@@ -794,17 +793,17 @@  discard block
 block discarded – undo
794 793
 					$registrations_processed
795 794
 				);
796 795
 			}
797
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
796
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
798 797
 			return false;
799 798
 		}
800 799
 		// mark this reg step as completed
801 800
 		$this->set_completed();
802 801
 		$this->_set_success_message(
803
-			__( 'The Attendee Information Step has been successfully completed.', 'event_espresso' )
802
+			__('The Attendee Information Step has been successfully completed.', 'event_espresso')
804 803
 		);
805 804
 		//do action in case a plugin wants to do something with the data submitted in step 1.
806 805
 		//passes EE_Single_Page_Checkout, and it's posted data
807
-		do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data );
806
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
808 807
 		return true;
809 808
 	}
810 809
 
@@ -818,9 +817,9 @@  discard block
 block discarded – undo
818 817
 	 * @return boolean | int
819 818
 	 * @throws \EE_Error
820 819
 	 */
821
-	private function _process_registrations( $registrations = array(), $valid_data = array() ) {
820
+	private function _process_registrations($registrations = array(), $valid_data = array()) {
822 821
 		// load resources and set some defaults
823
-		EE_Registry::instance()->load_model( 'Attendee' );
822
+		EE_Registry::instance()->load_model('Attendee');
824 823
 		// holder for primary registrant attendee object
825 824
 		$this->checkout->primary_attendee_obj = NULL;
826 825
 		// array for tracking reg form data for the primary registrant
@@ -837,9 +836,9 @@  discard block
 block discarded – undo
837 836
 		// attendee counter
838 837
 		$att_nmbr = 0;
839 838
 		// grab the saved registrations from the transaction
840
-		foreach ( $registrations  as $registration ) {
839
+		foreach ($registrations  as $registration) {
841 840
 			// verify EE_Registration object
842
-			if ( ! $registration instanceof EE_Registration ) {
841
+			if ( ! $registration instanceof EE_Registration) {
843 842
 				EE_Error::add_error(
844 843
 					__(
845 844
 						'An invalid Registration object was discovered when attempting to process your registration information.',
@@ -854,12 +853,12 @@  discard block
 block discarded – undo
854 853
 			/** @var string $reg_url_link */
855 854
 			$reg_url_link = $registration->reg_url_link();
856 855
 			// reg_url_link exists ?
857
-			if ( ! empty( $reg_url_link ) ) {
856
+			if ( ! empty($reg_url_link)) {
858 857
 				// should this registration be processed during this visit ?
859
-				if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) {
858
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
860 859
 					// if NOT revisiting, then let's save the registration now,
861 860
 					// so that we have a REG_ID to use when generating other objects
862
-					if ( ! $this->checkout->revisit ) {
861
+					if ( ! $this->checkout->revisit) {
863 862
 						$registration->save();
864 863
 					}
865 864
 					/**
@@ -869,7 +868,7 @@  discard block
 block discarded – undo
869 868
 					 * @var bool   if true is returned by the plugin then the
870 869
 					 *      		registration processing is halted.
871 870
 					 */
872
-					if ( apply_filters(
871
+					if (apply_filters(
873 872
 						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
874 873
 						false,
875 874
 						$att_nmbr,
@@ -877,38 +876,38 @@  discard block
 block discarded – undo
877 876
 						$registrations,
878 877
 						$valid_data,
879 878
 						$this
880
-					) ) {
879
+					)) {
881 880
 						return false;
882 881
 					}
883 882
 
884 883
 					// Houston, we have a registration!
885 884
 					$att_nmbr++;
886
-					$this->_attendee_data[ $reg_url_link ] = array();
885
+					$this->_attendee_data[$reg_url_link] = array();
887 886
 					// grab any existing related answer objects
888 887
 					$this->_registration_answers = $registration->answers();
889 888
 					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
890
-					if ( isset( $valid_data[ $reg_url_link ] ) ) {
889
+					if (isset($valid_data[$reg_url_link])) {
891 890
 						// do we need to copy basic info from primary attendee ?
892
-						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] )
893
-						                && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
891
+						$copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info'])
892
+						                && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0
894 893
 							? true
895 894
 							: false;
896 895
 						// filter form input data for this registration
897
-						$valid_data[ $reg_url_link ] = (array)apply_filters(
896
+						$valid_data[$reg_url_link] = (array) apply_filters(
898 897
 							'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
899
-							$valid_data[ $reg_url_link ]
898
+							$valid_data[$reg_url_link]
900 899
 						);
901 900
 						// EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ );
902
-						if ( isset( $valid_data['primary_attendee'] )) {
903
-							$primary_registrant['line_item_id'] =  ! empty( $valid_data['primary_attendee'] )
901
+						if (isset($valid_data['primary_attendee'])) {
902
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
904 903
 								? $valid_data['primary_attendee']
905 904
 								: false;
906
-							unset( $valid_data['primary_attendee'] );
905
+							unset($valid_data['primary_attendee']);
907 906
 						}
908 907
 						// now loop through our array of valid post data && process attendee reg forms
909
-						foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) {
910
-							if ( ! in_array( $form_section, $non_input_form_sections )) {
911
-								foreach ( $form_inputs as $form_input => $input_value ) {
908
+						foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
909
+							if ( ! in_array($form_section, $non_input_form_sections)) {
910
+								foreach ($form_inputs as $form_input => $input_value) {
912 911
 									// \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
913 912
 									// check for critical inputs
914 913
 									if (
@@ -922,16 +921,16 @@  discard block
 block discarded – undo
922 921
 									// store a bit of data about the primary attendee
923 922
 									if (
924 923
 										$att_nmbr === 1
925
-										&& ! empty( $input_value )
924
+										&& ! empty($input_value)
926 925
 										&& $reg_url_link === $primary_registrant['line_item_id']
927 926
 									) {
928
-										$primary_registrant[ $form_input ] = $input_value;
927
+										$primary_registrant[$form_input] = $input_value;
929 928
 									} else if (
930 929
 										$copy_primary
931 930
 										&& $input_value === null
932
-										&& isset( $primary_registrant[ $form_input ] )
931
+										&& isset($primary_registrant[$form_input])
933 932
 									) {
934
-										$input_value = $primary_registrant[ $form_input ];
933
+										$input_value = $primary_registrant[$form_input];
935 934
 									}
936 935
 									// now attempt to save the input data
937 936
 									if (
@@ -973,57 +972,57 @@  discard block
 block discarded – undo
973 972
 						// have we met before?
974 973
 						$attendee = $this->_find_existing_attendee(
975 974
 							$registration,
976
-							$this->_attendee_data[ $reg_url_link ]
975
+							$this->_attendee_data[$reg_url_link]
977 976
 						);
978 977
 						// did we find an already existing record for this attendee ?
979
-						if ( $attendee instanceof EE_Attendee ) {
978
+						if ($attendee instanceof EE_Attendee) {
980 979
 							$attendee = $this->_update_existing_attendee_data(
981 980
 								$attendee,
982
-								$this->_attendee_data[ $reg_url_link ]
981
+								$this->_attendee_data[$reg_url_link]
983 982
 							);
984 983
 						} else {
985 984
 							// ensure critical details are set for additional attendees
986
-							$this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
985
+							$this->_attendee_data[$reg_url_link] = $att_nmbr > 1
987 986
 								? $this->_copy_critical_attendee_details_from_primary_registrant(
988
-									$this->_attendee_data[ $reg_url_link ]
987
+									$this->_attendee_data[$reg_url_link]
989 988
 								)
990
-								: $this->_attendee_data[ $reg_url_link ];
989
+								: $this->_attendee_data[$reg_url_link];
991 990
 							$attendee = $this->_create_new_attendee(
992 991
 								$registration,
993
-								$this->_attendee_data[ $reg_url_link ]
992
+								$this->_attendee_data[$reg_url_link]
994 993
 							);
995 994
 						}
996 995
 						// who's #1 ?
997
-						if ( $att_nmbr === 1 ) {
996
+						if ($att_nmbr === 1) {
998 997
 							$this->checkout->primary_attendee_obj = $attendee;
999 998
 						}
1000 999
 					}
1001 1000
 					// EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1002 1001
 					// add relation to registration, set attendee ID, and cache attendee
1003
-					$this->_associate_attendee_with_registration( $registration, $attendee );
1002
+					$this->_associate_attendee_with_registration($registration, $attendee);
1004 1003
 					// \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1005
-					if ( ! $registration->attendee() instanceof EE_Attendee ) {
1006
-						EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ );
1004
+					if ( ! $registration->attendee() instanceof EE_Attendee) {
1005
+						EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__);
1007 1006
 						return false;
1008 1007
 					}
1009 1008
 					/** @type EE_Registration_Processor $registration_processor */
1010
-					$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
1009
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1011 1010
 					// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
1012
-					$registration_processor->toggle_incomplete_registration_status_to_default( $registration, false );
1011
+					$registration_processor->toggle_incomplete_registration_status_to_default($registration, false);
1013 1012
 					/** @type EE_Transaction_Processor $transaction_processor */
1014
-					$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1013
+					$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1015 1014
 					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1016
-					$transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction );
1015
+					$transaction_processor->toggle_failed_transaction_status($this->checkout->transaction);
1017 1016
 					// if we've gotten this far, then let's save what we have
1018 1017
 					$registration->save();
1019 1018
 					// add relation between TXN and registration
1020
-					$this->_associate_registration_with_transaction( $registration );
1019
+					$this->_associate_registration_with_transaction($registration);
1021 1020
 				} // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) {
1022 1021
 
1023
-			}  else {
1024
-				EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1022
+			} else {
1023
+				EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1025 1024
 				// remove malformed data
1026
-				unset( $valid_data[ $reg_url_link ] );
1025
+				unset($valid_data[$reg_url_link]);
1027 1026
 				return false;
1028 1027
 			}
1029 1028
 
@@ -1052,26 +1051,26 @@  discard block
 block discarded – undo
1052 1051
 		// \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1053 1052
 		// allow for plugins to hook in and do their own processing of the form input.
1054 1053
 		// For plugins to bypass normal processing here, they just need to return a boolean value.
1055
-		if ( apply_filters(
1054
+		if (apply_filters(
1056 1055
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1057 1056
 			false,
1058 1057
 			$registration,
1059 1058
 			$form_input,
1060 1059
 			$input_value,
1061 1060
 			$this
1062
-		) ) {
1061
+		)) {
1063 1062
 			return true;
1064 1063
 		}
1065 1064
 		// $answer_cache_id is the key used to find the EE_Answer we want
1066 1065
 		$answer_cache_id = $this->checkout->reg_url_link
1067 1066
 			? $form_input
1068
-			: $form_input . '-' . $registration->reg_url_link();
1069
-		$answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] )
1070
-		                 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1067
+			: $form_input.'-'.$registration->reg_url_link();
1068
+		$answer_is_obj = isset($this->_registration_answers[$answer_cache_id])
1069
+		                 && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
1071 1070
 			? true
1072 1071
 			: false;
1073 1072
 		//rename form_inputs if they are EE_Attendee properties
1074
-		switch( (string)$form_input ) {
1073
+		switch ((string) $form_input) {
1075 1074
 
1076 1075
 			case 'state' :
1077 1076
 			case 'STA_ID' :
@@ -1086,32 +1085,32 @@  discard block
 block discarded – undo
1086 1085
 				break;
1087 1086
 
1088 1087
 			default :
1089
-				$ATT_input = 'ATT_' . $form_input;
1088
+				$ATT_input = 'ATT_'.$form_input;
1090 1089
 				//EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1091
-				$attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? true : false;
1092
-				$form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1090
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1091
+				$form_input = $attendee_property ? 'ATT_'.$form_input : $form_input;
1093 1092
 		}
1094 1093
 		// EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1095 1094
 		// EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1096 1095
 		// EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1097 1096
 		// if this form input has a corresponding attendee property
1098
-		if ( $attendee_property ) {
1099
-			$this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1100
-			if ( $answer_is_obj ) {
1097
+		if ($attendee_property) {
1098
+			$this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
1099
+			if ($answer_is_obj) {
1101 1100
 				// and delete the corresponding answer since we won't be storing this data in that object
1102
-				$registration->_remove_relation_to( $this->_registration_answers[ $answer_cache_id ], 'Answer' );
1103
-				$this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1101
+				$registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer');
1102
+				$this->_registration_answers[$answer_cache_id]->delete_permanently();
1104 1103
 			}
1105 1104
 			return true;
1106
-		} elseif ( $answer_is_obj ) {
1105
+		} elseif ($answer_is_obj) {
1107 1106
 			// save this data to the answer object
1108
-			$this->_registration_answers[ $answer_cache_id ]->set_value( $input_value );
1109
-			$result = $this->_registration_answers[ $answer_cache_id ]->save();
1107
+			$this->_registration_answers[$answer_cache_id]->set_value($input_value);
1108
+			$result = $this->_registration_answers[$answer_cache_id]->save();
1110 1109
 			return $result !== false ? true : false;
1111 1110
 		} else {
1112
-			foreach ( $this->_registration_answers as $answer ) {
1113
-				if ( $answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id ) {
1114
-					$answer->set_value( $input_value );
1111
+			foreach ($this->_registration_answers as $answer) {
1112
+				if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1113
+					$answer->set_value($input_value);
1115 1114
 					$result = $answer->save();
1116 1115
 					return $result !== false ? true : false;
1117 1116
 				}
@@ -1133,15 +1132,15 @@  discard block
 block discarded – undo
1133 1132
 		$form_input = '',
1134 1133
 		$input_value = ''
1135 1134
 	) {
1136
-		if ( empty( $input_value ) ) {
1135
+		if (empty($input_value)) {
1137 1136
 			// if the form input isn't marked as being required, then just return
1138
-			if ( ! isset( $this->_required_questions[ $form_input ] ) || ! $this->_required_questions[ $form_input ] ) {
1137
+			if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1139 1138
 				return true;
1140 1139
 			}
1141
-			switch ( $form_input ) {
1140
+			switch ($form_input) {
1142 1141
 				case 'fname' :
1143 1142
 					EE_Error::add_error(
1144
-						__( 'First Name is a required value.', 'event_espresso' ),
1143
+						__('First Name is a required value.', 'event_espresso'),
1145 1144
 						__FILE__,
1146 1145
 						__FUNCTION__,
1147 1146
 						__LINE__
@@ -1150,7 +1149,7 @@  discard block
 block discarded – undo
1150 1149
 					break;
1151 1150
 				case 'lname' :
1152 1151
 					EE_Error::add_error(
1153
-						__( 'Last Name is a required value.', 'event_espresso' ),
1152
+						__('Last Name is a required value.', 'event_espresso'),
1154 1153
 						__FILE__,
1155 1154
 						__FUNCTION__,
1156 1155
 						__LINE__
@@ -1159,7 +1158,7 @@  discard block
 block discarded – undo
1159 1158
 					break;
1160 1159
 				case 'email' :
1161 1160
 					EE_Error::add_error(
1162
-						__( 'Please enter a valid email address.', 'event_espresso' ),
1161
+						__('Please enter a valid email address.', 'event_espresso'),
1163 1162
 						__FILE__,
1164 1163
 						__FUNCTION__,
1165 1164
 						__LINE__
@@ -1192,21 +1191,21 @@  discard block
 block discarded – undo
1192 1191
 	 * @param array           $attendee_data
1193 1192
 	 * @return boolean
1194 1193
 	 */
1195
-	private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) {
1194
+	private function _find_existing_attendee(EE_Registration $registration, $attendee_data = array()) {
1196 1195
 		$existing_attendee = null;
1197 1196
 		// does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
1198
-		$ATT_fname = isset( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_fname'] )
1197
+		$ATT_fname = isset($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_fname'])
1199 1198
 			? $attendee_data['ATT_fname']
1200 1199
 			: '';
1201
-		$ATT_lname = isset( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_lname'] )
1200
+		$ATT_lname = isset($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_lname'])
1202 1201
 			? $attendee_data['ATT_lname']
1203 1202
 			: '';
1204
-		$ATT_email = isset( $attendee_data['ATT_email'] ) && ! empty( $attendee_data['ATT_email'] )
1203
+		$ATT_email = isset($attendee_data['ATT_email']) && ! empty($attendee_data['ATT_email'])
1205 1204
 			? $attendee_data['ATT_email']
1206 1205
 			: '';
1207 1206
 		// but only if those have values
1208
-		if ( $ATT_fname && $ATT_lname && $ATT_email ) {
1209
-			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array(
1207
+		if ($ATT_fname && $ATT_lname && $ATT_email) {
1208
+			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array(
1210 1209
 				'ATT_fname' => $ATT_fname,
1211 1210
 				'ATT_lname' => $ATT_lname,
1212 1211
 				'ATT_email' => $ATT_email
@@ -1230,13 +1229,13 @@  discard block
 block discarded – undo
1230 1229
 	 * @return \EE_Attendee
1231 1230
 	 * @throws \EE_Error
1232 1231
 	 */
1233
-	private function _update_existing_attendee_data( EE_Attendee $existing_attendee, $attendee_data = array() ) {
1232
+	private function _update_existing_attendee_data(EE_Attendee $existing_attendee, $attendee_data = array()) {
1234 1233
 		// first remove fname, lname, and email from attendee data
1235
-		$dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1234
+		$dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email');
1236 1235
 		// now loop thru what's left and add to attendee CPT
1237
-		foreach ( $attendee_data as $property_name => $property_value ) {
1238
-			if ( ! in_array( $property_name, $dont_set ) && EEM_Attendee::instance()->has_field( $property_name )) {
1239
-				$existing_attendee->set( $property_name, $property_value );
1236
+		foreach ($attendee_data as $property_name => $property_value) {
1237
+			if ( ! in_array($property_name, $dont_set) && EEM_Attendee::instance()->has_field($property_name)) {
1238
+				$existing_attendee->set($property_name, $property_value);
1240 1239
 			}
1241 1240
 		}
1242 1241
 		// better save that now
@@ -1254,11 +1253,11 @@  discard block
 block discarded – undo
1254 1253
 	 * @return void
1255 1254
 	 * @throws \EE_Error
1256 1255
 	 */
1257
-	private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) {
1256
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) {
1258 1257
 		// add relation to attendee
1259
-		$registration->_add_relation_to( $attendee, 'Attendee' );
1260
-		$registration->set_attendee_id( $attendee->ID() );
1261
-		$registration->update_cache_after_object_save( 'Attendee', $attendee );
1258
+		$registration->_add_relation_to($attendee, 'Attendee');
1259
+		$registration->set_attendee_id($attendee->ID());
1260
+		$registration->update_cache_after_object_save('Attendee', $attendee);
1262 1261
 	}
1263 1262
 
1264 1263
 
@@ -1270,10 +1269,10 @@  discard block
 block discarded – undo
1270 1269
 	 * @return void
1271 1270
 	 * @throws \EE_Error
1272 1271
 	 */
1273
-	private function _associate_registration_with_transaction( EE_Registration $registration ) {
1272
+	private function _associate_registration_with_transaction(EE_Registration $registration) {
1274 1273
 		// add relation to attendee
1275
-		$this->checkout->transaction->_add_relation_to( $registration, 'Registration' );
1276
-		$this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration );
1274
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1275
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1277 1276
 	}
1278 1277
 
1279 1278
 
@@ -1286,14 +1285,14 @@  discard block
 block discarded – undo
1286 1285
 	 * @return array
1287 1286
 	 * @throws \EE_Error
1288 1287
 	 */
1289
-	private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) {
1288
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) {
1290 1289
 		// bare minimum critical details include first name, last name, email address
1291
-		$critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1290
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1292 1291
 		// add address info to critical details?
1293
-		if ( apply_filters(
1292
+		if (apply_filters(
1294 1293
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1295 1294
 			false
1296
-		) ) {
1295
+		)) {
1297 1296
 			$address_details = array(
1298 1297
 				'ATT_address',
1299 1298
 				'ATT_address2',
@@ -1303,13 +1302,13 @@  discard block
 block discarded – undo
1303 1302
 				'ATT_zip',
1304 1303
 				'ATT_phone'
1305 1304
 			);
1306
-			$critical_attendee_details = array_merge( $critical_attendee_details, $address_details );
1305
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1307 1306
 		}
1308
-		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1309
-			if ( ! isset( $attendee_data[ $critical_attendee_detail ] )
1310
-			     || empty( $attendee_data[ $critical_attendee_detail ] )
1307
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1308
+			if ( ! isset($attendee_data[$critical_attendee_detail])
1309
+			     || empty($attendee_data[$critical_attendee_detail])
1311 1310
 			) {
1312
-				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1311
+				$attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
1313 1312
 					$critical_attendee_detail
1314 1313
 				);
1315 1314
 			}
@@ -1327,11 +1326,11 @@  discard block
 block discarded – undo
1327 1326
 	 * @return \EE_Attendee
1328 1327
 	 * @throws \EE_Error
1329 1328
 	 */
1330
-	private function _create_new_attendee( EE_Registration $registration, $attendee_data = array() ) {
1329
+	private function _create_new_attendee(EE_Registration $registration, $attendee_data = array()) {
1331 1330
 		// create new attendee object
1332
-		$new_attendee = EE_Attendee::new_instance( $attendee_data );
1331
+		$new_attendee = EE_Attendee::new_instance($attendee_data);
1333 1332
 		// set author to event creator
1334
-		$new_attendee->set( 'ATT_author', $registration->event()->wp_user() );
1333
+		$new_attendee->set('ATT_author', $registration->event()->wp_user());
1335 1334
 		$new_attendee->save();
1336 1335
 		return $new_attendee;
1337 1336
 	}
@@ -1348,7 +1347,7 @@  discard block
 block discarded – undo
1348 1347
 	 */
1349 1348
 	public function update_reg_step() {
1350 1349
 		// save everything
1351
-		if ( $this->process_reg_step() ) {
1350
+		if ($this->process_reg_step()) {
1352 1351
 			$this->checkout->redirect = true;
1353 1352
 			$this->checkout->redirect_url = add_query_arg(
1354 1353
 				array(
@@ -1357,7 +1356,7 @@  discard block
 block discarded – undo
1357 1356
 				),
1358 1357
 				$this->checkout->thank_you_page_url
1359 1358
 			);
1360
-			$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1359
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1361 1360
 			return true;
1362 1361
 		}
1363 1362
 		return false;
Please login to merge, or discard this patch.
core/db_classes/EE_Transaction.class.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 * Gets all the attendees for this transaction (handy for use with EE_Attendee's get_registrations_for_event function
413 413
 	 * for getting attendees and how many registrations they each have for an event)
414 414
 	 *
415
-	 * @return mixed EE_Attendee[] by default, int if $output is set to 'COUNT'
415
+	 * @return EE_Base_Class[] EE_Attendee[] by default, int if $output is set to 'COUNT'
416 416
 	 * @throws \EE_Error
417 417
 	 */
418 418
 	public function attendees() {
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 	 * Gets all the extra meta info on this payment
694 694
 	 *
695 695
 	 * @param array $query_params like EEM_Base::get_all
696
-	 * @return EE_Extra_Meta
696
+	 * @return EE_Base_Class[]
697 697
 	 * @throws \EE_Error
698 698
 	 */
699 699
 	public function extra_meta( $query_params = array() ) {
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 	 * Sets PMD_ID
871 871
 	 *
872 872
 	 * @param int $PMD_ID
873
-	 * @return boolean
873
+	 * @return boolean|null
874 874
 	 * @throws \EE_Error
875 875
 	 */
876 876
 	public function set_payment_method_ID($PMD_ID) {
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * EE_Transaction class
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 	 * @return EE_Transaction
26 26
 	 * @throws \EE_Error
27 27
 	 */
28
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
29
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
28
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
29
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
30 30
 		return $has_object
31 31
 			? $has_object
32
-			: new self( $props_n_values, false, $timezone, $date_formats );
32
+			: new self($props_n_values, false, $timezone, $date_formats);
33 33
 	}
34 34
 
35 35
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	 * @return EE_Transaction
42 42
 	 * @throws \EE_Error
43 43
 	 */
44
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
45
-		return new self( $props_n_values, TRUE, $timezone );
44
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
45
+		return new self($props_n_values, TRUE, $timezone);
46 46
 	}
47 47
 
48 48
 
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function lock() {
60 60
 		// attempt to set lock, but if that fails...
61
-		if ( ! $this->add_extra_meta( 'lock', time(), true )  ) {
61
+		if ( ! $this->add_extra_meta('lock', time(), true)) {
62 62
 			// then attempt to remove the lock in case it is expired
63
-			if ( $this->_remove_expired_lock() ) {
63
+			if ($this->_remove_expired_lock()) {
64 64
 				// if removal was successful, then try setting lock again
65 65
 				$this->lock();
66 66
 			} else {
67 67
 				// but if the lock can not be removed, then throw an exception
68 68
 				throw new EE_Error(
69 69
 					sprintf(
70
-						__( 'Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso' ),
70
+						__('Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso'),
71 71
 						$this->ID()
72 72
 					)
73 73
 				);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * @throws \EE_Error
87 87
 	 */
88 88
 	public function unlock() {
89
-		return $this->delete_extra_meta( 'lock' );
89
+		return $this->delete_extra_meta('lock');
90 90
 	}
91 91
 
92 92
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function is_locked() {
109 109
 		// if TXN is not locked, then return false immediately
110
-		if ( ! $this->_get_lock() ) {
110
+		if ( ! $this->_get_lock()) {
111 111
 			return false;
112 112
 		}
113 113
 		// if not, then let's try and remove the lock in case it's expired...
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @throws \EE_Error
129 129
 	 */
130 130
 	protected function _get_lock() {
131
-		return (int)$this->get_extra_meta( 'lock', true, 0 );
131
+		return (int) $this->get_extra_meta('lock', true, 0);
132 132
 	}
133 133
 
134 134
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	protected function _remove_expired_lock() {
145 145
 		$locked = $this->_get_lock();
146
-		if ( $locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked ) {
146
+		if ($locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked) {
147 147
 			return $this->unlock();
148 148
 		}
149 149
 		return 0;
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @param        float $total total value of transaction
159 159
 	 * @throws \EE_Error
160 160
 	 */
161
-	public function set_total( $total = 0.00 ) {
162
-		$this->set( 'TXN_total', (float)$total );
161
+	public function set_total($total = 0.00) {
162
+		$this->set('TXN_total', (float) $total);
163 163
 	}
164 164
 
165 165
 
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 * @param        float $total_paid total amount paid to date (sum of all payments)
172 172
 	 * @throws \EE_Error
173 173
 	 */
174
-	public function set_paid( $total_paid = 0.00 ) {
175
-		$this->set( 'TXN_paid', (float)$total_paid );
174
+	public function set_paid($total_paid = 0.00) {
175
+		$this->set('TXN_paid', (float) $total_paid);
176 176
 	}
177 177
 
178 178
 
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 * @param        string $status whether the transaction is open, declined, accepted, or any number of custom values that can be set
185 185
 	 * @throws \EE_Error
186 186
 	 */
187
-	public function set_status( $status = '' ) {
188
-		$this->set( 'STS_ID', $status );
187
+	public function set_status($status = '') {
188
+		$this->set('STS_ID', $status);
189 189
 	}
190 190
 
191 191
 
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 * @param        string $hash_salt required for some payment gateways
198 198
 	 * @throws \EE_Error
199 199
 	 */
200
-	public function set_hash_salt( $hash_salt = '' ) {
201
-		$this->set( 'TXN_hash_salt', $hash_salt );
200
+	public function set_hash_salt($hash_salt = '') {
201
+		$this->set('TXN_hash_salt', $hash_salt);
202 202
 	}
203 203
 
204 204
 
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
 	 * @param array $txn_reg_steps
210 210
 	 * @throws \EE_Error
211 211
 	 */
212
-	public function set_reg_steps( array $txn_reg_steps ) {
213
-		$this->set( 'TXN_reg_steps', $txn_reg_steps );
212
+	public function set_reg_steps(array $txn_reg_steps) {
213
+		$this->set('TXN_reg_steps', $txn_reg_steps);
214 214
 	}
215 215
 
216 216
 
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	 * @throws \EE_Error
223 223
 	 */
224 224
 	public function reg_steps() {
225
-		$TXN_reg_steps = $this->get( 'TXN_reg_steps' );
226
-		return is_array( $TXN_reg_steps ) ? (array)$TXN_reg_steps : array();
225
+		$TXN_reg_steps = $this->get('TXN_reg_steps');
226
+		return is_array($TXN_reg_steps) ? (array) $TXN_reg_steps : array();
227 227
 	}
228 228
 
229 229
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * @throws \EE_Error
234 234
 	 */
235 235
 	public function pretty_total() {
236
-		return $this->get_pretty( 'TXN_total' );
236
+		return $this->get_pretty('TXN_total');
237 237
 	}
238 238
 
239 239
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * @throws \EE_Error
246 246
 	 */
247 247
 	public function pretty_paid() {
248
-		return $this->get_pretty( 'TXN_paid' );
248
+		return $this->get_pretty('TXN_paid');
249 249
 	}
250 250
 
251 251
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @throws \EE_Error
259 259
 	 */
260 260
 	public function remaining() {
261
-		return (float)( $this->total() - $this->paid() );
261
+		return (float) ($this->total() - $this->paid());
262 262
 	}
263 263
 
264 264
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @throws \EE_Error
272 272
 	 */
273 273
 	public function total() {
274
-		return (float)$this->get( 'TXN_total' );
274
+		return (float) $this->get('TXN_total');
275 275
 	}
276 276
 
277 277
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @throws \EE_Error
285 285
 	 */
286 286
 	public function paid() {
287
-		return (float)$this->get( 'TXN_paid' );
287
+		return (float) $this->get('TXN_paid');
288 288
 	}
289 289
 
290 290
 
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
 	 * @throws \EE_Error
297 297
 	 */
298 298
 	public function get_cart_session() {
299
-		$session_data = (array)$this->get( 'TXN_session_data' );
300
-		return isset( $session_data[ 'cart' ] ) && $session_data[ 'cart' ] instanceof EE_Cart
301
-			? $session_data[ 'cart' ]
299
+		$session_data = (array) $this->get('TXN_session_data');
300
+		return isset($session_data['cart']) && $session_data['cart'] instanceof EE_Cart
301
+			? $session_data['cart']
302 302
 			: null;
303 303
 	}
304 304
 
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
 	 * @throws \EE_Error
312 312
 	 */
313 313
 	public function session_data() {
314
-		$session_data = $this->get( 'TXN_session_data' );
315
-		if ( empty( $session_data ) ) {
314
+		$session_data = $this->get('TXN_session_data');
315
+		if (empty($session_data)) {
316 316
 			$session_data = array(
317 317
 				'id'            => null,
318 318
 				'user_id'       => null,
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 	 * @param        EE_Session|array $session_data
336 336
 	 * @throws \EE_Error
337 337
 	 */
338
-	public function set_txn_session_data( $session_data ) {
339
-		if ( $session_data instanceof EE_Session ) {
340
-			$this->set( 'TXN_session_data', $session_data->get_session_data( NULL, TRUE ));
338
+	public function set_txn_session_data($session_data) {
339
+		if ($session_data instanceof EE_Session) {
340
+			$this->set('TXN_session_data', $session_data->get_session_data(NULL, TRUE));
341 341
 		} else {
342
-			$this->set( 'TXN_session_data', $session_data );
342
+			$this->set('TXN_session_data', $session_data);
343 343
 		}
344 344
 	}
345 345
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @throws \EE_Error
353 353
 	 */
354 354
 	public function hash_salt_() {
355
-		return $this->get( 'TXN_hash_salt' );
355
+		return $this->get('TXN_hash_salt');
356 356
 	}
357 357
 
358 358
 
@@ -372,13 +372,13 @@  discard block
 block discarded – undo
372 372
 	 * @return    string | int
373 373
 	 * @throws \EE_Error
374 374
 	 */
375
-	public function datetime( $format = FALSE, $gmt = FALSE ) {
376
-		if ( $format ) {
377
-			return $this->get_pretty( 'TXN_timestamp' );
378
-		} else if ( $gmt ) {
379
-			return $this->get_raw( 'TXN_timestamp' );
375
+	public function datetime($format = FALSE, $gmt = FALSE) {
376
+		if ($format) {
377
+			return $this->get_pretty('TXN_timestamp');
378
+		} else if ($gmt) {
379
+			return $this->get_raw('TXN_timestamp');
380 380
 		} else {
381
-			return $this->get( 'TXN_timestamp' );
381
+			return $this->get('TXN_timestamp');
382 382
 		}
383 383
 	}
384 384
 
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 	 * @return EE_Registration[]
393 393
 	 * @throws \EE_Error
394 394
 	 */
395
-	public function registrations( $query_params = array(), $get_cached = FALSE ) {
396
-		$query_params = ( empty( $query_params ) || ! is_array( $query_params ) )
395
+	public function registrations($query_params = array(), $get_cached = FALSE) {
396
+		$query_params = (empty($query_params) || ! is_array($query_params))
397 397
 			? array(
398 398
 				'order_by' => array(
399 399
 					'Event.EVT_name' => 'ASC',
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 			)
404 404
 			: $query_params;
405 405
 		$query_params = $get_cached ? array() : $query_params;
406
-		return $this->get_many_related( 'Registration', $query_params );
406
+		return $this->get_many_related('Registration', $query_params);
407 407
 	}
408 408
 
409 409
 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 	 * @throws \EE_Error
417 417
 	 */
418 418
 	public function attendees() {
419
-		return $this->get_many_related( 'Attendee', array( array( 'Registration.Transaction.TXN_ID' => $this->ID() ) ) );
419
+		return $this->get_many_related('Attendee', array(array('Registration.Transaction.TXN_ID' => $this->ID())));
420 420
 	}
421 421
 
422 422
 
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 	 * @return EE_Payment[]
429 429
 	 * @throws \EE_Error
430 430
 	 */
431
-	public function payments( $query_params = array() ) {
432
-		return $this->get_many_related( 'Payment', $query_params );
431
+	public function payments($query_params = array()) {
432
+		return $this->get_many_related('Payment', $query_params);
433 433
 	}
434 434
 
435 435
 
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 * @throws \EE_Error
442 442
 	 */
443 443
 	public function approved_payments() {
444
-		EE_Registry::instance()->load_model( 'Payment' );
445
-		return $this->get_many_related( 'Payment', array( array( 'STS_ID' => EEM_Payment::status_id_approved ), 'order_by' => array( 'PAY_timestamp' => 'DESC' ) ) );
444
+		EE_Registry::instance()->load_model('Payment');
445
+		return $this->get_many_related('Payment', array(array('STS_ID' => EEM_Payment::status_id_approved), 'order_by' => array('PAY_timestamp' => 'DESC')));
446 446
 	}
447 447
 
448 448
 
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	 * @return string
455 455
 	 * @throws \EE_Error
456 456
 	 */
457
-	public function e_pretty_status( $show_icons = FALSE ) {
458
-		echo $this->pretty_status( $show_icons );
457
+	public function e_pretty_status($show_icons = FALSE) {
458
+		echo $this->pretty_status($show_icons);
459 459
 	}
460 460
 
461 461
 
@@ -467,10 +467,10 @@  discard block
 block discarded – undo
467 467
 	 * @return string
468 468
 	 * @throws \EE_Error
469 469
 	 */
470
-	public function pretty_status( $show_icons = FALSE ) {
471
-		$status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' );
470
+	public function pretty_status($show_icons = FALSE) {
471
+		$status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence');
472 472
 		$icon = '';
473
-		switch ( $this->status_ID() ) {
473
+		switch ($this->status_ID()) {
474 474
 			case EEM_Transaction::complete_status_code:
475 475
 				$icon = $show_icons ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' : '';
476 476
 				break;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 				$icon = $show_icons ? '<span class="dashicons dashicons-plus ee-icon-size-16 orange-text"></span>' : '';
488 488
 				break;
489 489
 		}
490
-		return $icon . $status[ $this->status_ID() ];
490
+		return $icon.$status[$this->status_ID()];
491 491
 	}
492 492
 
493 493
 
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 	 * @throws \EE_Error
500 500
 	 */
501 501
 	public function status_ID() {
502
-		return $this->get( 'STS_ID' );
502
+		return $this->get('STS_ID');
503 503
 	}
504 504
 
505 505
 
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 	 * @throws \EE_Error
512 512
 	 */
513 513
 	public function is_free() {
514
-		return EEH_Money::compare_floats( $this->get( 'TXN_total' ), 0, '==' );
514
+		return EEH_Money::compare_floats($this->get('TXN_total'), 0, '==');
515 515
 	}
516 516
 
517 517
 
@@ -591,12 +591,12 @@  discard block
 block discarded – undo
591 591
 	 * @return string
592 592
 	 * @throws \EE_Error
593 593
 	 */
594
-	public function invoice_url( $type = 'html' ) {
594
+	public function invoice_url($type = 'html') {
595 595
 		$REG = $this->primary_registration();
596
-		if ( ! $REG instanceof EE_Registration ) {
596
+		if ( ! $REG instanceof EE_Registration) {
597 597
 			return '';
598 598
 		}
599
-		return $REG->invoice_url( $type );
599
+		return $REG->invoice_url($type);
600 600
 	}
601 601
 
602 602
 
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 * @throws \EE_Error
609 609
 	 */
610 610
 	public function primary_registration() {
611
-		return $this->get_first_related( 'Registration', array( array( 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT ) ) );
611
+		return $this->get_first_related('Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT)));
612 612
 	}
613 613
 
614 614
 
@@ -620,12 +620,12 @@  discard block
 block discarded – undo
620 620
 	 * @return string
621 621
 	 * @throws \EE_Error
622 622
 	 */
623
-	public function receipt_url( $type = 'html' ) {
623
+	public function receipt_url($type = 'html') {
624 624
 		$REG = $this->primary_registration();
625
-		if ( ! $REG instanceof EE_Registration ) {
625
+		if ( ! $REG instanceof EE_Registration) {
626 626
 			return '';
627 627
 		}
628
-		return $REG->receipt_url( $type );
628
+		return $REG->receipt_url($type);
629 629
 	}
630 630
 
631 631
 
@@ -653,15 +653,15 @@  discard block
 block discarded – undo
653 653
 	 * @return boolean
654 654
 	 * @throws \EE_Error
655 655
 	 */
656
-	public function update_based_on_payments(){
656
+	public function update_based_on_payments() {
657 657
 		EE_Error::doing_it_wrong(
658
-			__CLASS__ . '::' . __FUNCTION__,
659
-			sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ),
658
+			__CLASS__.'::'.__FUNCTION__,
659
+			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
660 660
 			'4.6.0'
661 661
 		);
662 662
 		/** @type EE_Transaction_Processor $transaction_processor */
663
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
664
-		return  $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $this );
663
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
664
+		return  $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($this);
665 665
 	}
666 666
 
667 667
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 	 * @throws \EE_Error
672 672
 	 */
673 673
 	public function gateway_response_on_transaction() {
674
-		$payment = $this->get_first_related( 'Payment' );
674
+		$payment = $this->get_first_related('Payment');
675 675
 		return $payment instanceof EE_Payment ? $payment->gateway_response() : '';
676 676
 	}
677 677
 
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 	 * @throws \EE_Error
685 685
 	 */
686 686
 	public function status_obj() {
687
-		return $this->get_first_related( 'Status' );
687
+		return $this->get_first_related('Status');
688 688
 	}
689 689
 
690 690
 
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
 	 * @return EE_Extra_Meta
697 697
 	 * @throws \EE_Error
698 698
 	 */
699
-	public function extra_meta( $query_params = array() ) {
700
-		return $this->get_many_related( 'Extra_Meta', $query_params );
699
+	public function extra_meta($query_params = array()) {
700
+		return $this->get_many_related('Extra_Meta', $query_params);
701 701
 	}
702 702
 
703 703
 
@@ -709,8 +709,8 @@  discard block
 block discarded – undo
709 709
 	 * @return EE_Base_Class the relation was added to
710 710
 	 * @throws \EE_Error
711 711
 	 */
712
-	public function add_registration( EE_Registration $registration ) {
713
-		return $this->_add_relation_to( $registration, 'Registration' );
712
+	public function add_registration(EE_Registration $registration) {
713
+		return $this->_add_relation_to($registration, 'Registration');
714 714
 	}
715 715
 
716 716
 
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
 	 * @return EE_Base_Class that was removed from being related
724 724
 	 * @throws \EE_Error
725 725
 	 */
726
-	public function remove_registration_with_id( $registration_or_id ) {
727
-		return $this->_remove_relation_to( $registration_or_id, 'Registration' );
726
+	public function remove_registration_with_id($registration_or_id) {
727
+		return $this->_remove_relation_to($registration_or_id, 'Registration');
728 728
 	}
729 729
 
730 730
 
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 	 * @throws \EE_Error
737 737
 	 */
738 738
 	public function items_purchased() {
739
-		return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_line_item ) ) );
739
+		return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_line_item)));
740 740
 	}
741 741
 
742 742
 
@@ -748,8 +748,8 @@  discard block
 block discarded – undo
748 748
 	 * @return EE_Base_Class the relation was added to
749 749
 	 * @throws \EE_Error
750 750
 	 */
751
-	public function add_line_item( EE_Line_Item $line_item ) {
752
-		return $this->_add_relation_to( $line_item, 'Line_Item' );
751
+	public function add_line_item(EE_Line_Item $line_item) {
752
+		return $this->_add_relation_to($line_item, 'Line_Item');
753 753
 	}
754 754
 
755 755
 
@@ -761,8 +761,8 @@  discard block
 block discarded – undo
761 761
 	 * @return EE_Line_Item[]
762 762
 	 * @throws \EE_Error
763 763
 	 */
764
-	public function line_items( $query_params = array() ) {
765
-		return $this->get_many_related( 'Line_Item', $query_params );
764
+	public function line_items($query_params = array()) {
765
+		return $this->get_many_related('Line_Item', $query_params);
766 766
 	}
767 767
 
768 768
 
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 	 * @throws \EE_Error
775 775
 	 */
776 776
 	public function tax_items() {
777
-		return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_tax ) ) );
777
+		return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax)));
778 778
 	}
779 779
 
780 780
 
@@ -787,9 +787,9 @@  discard block
 block discarded – undo
787 787
 	 * @throws \EE_Error
788 788
 	 */
789 789
 	public function total_line_item() {
790
-		$item =  $this->get_first_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_total ) ) );
791
-		if( ! $item ){
792
-			$item = EEH_Line_Item::create_total_line_item( $this );
790
+		$item = $this->get_first_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_total)));
791
+		if ( ! $item) {
792
+			$item = EEH_Line_Item::create_total_line_item($this);
793 793
 		}
794 794
 		return $item;
795 795
 	}
@@ -805,10 +805,10 @@  discard block
 block discarded – undo
805 805
 	 */
806 806
 	public function tax_total() {
807 807
 		$tax_line_item = $this->tax_total_line_item();
808
-		if ( $tax_line_item ) {
809
-			return (float)$tax_line_item->total();
808
+		if ($tax_line_item) {
809
+			return (float) $tax_line_item->total();
810 810
 		} else {
811
-			return (float)0;
811
+			return (float) 0;
812 812
 		}
813 813
 	}
814 814
 
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 	 * @throws \EE_Error
822 822
 	 */
823 823
 	public function tax_total_line_item() {
824
-		return EEH_Line_Item::get_taxes_subtotal( $this->total_line_item() );
824
+		return EEH_Line_Item::get_taxes_subtotal($this->total_line_item());
825 825
 	}
826 826
 
827 827
 
@@ -832,20 +832,20 @@  discard block
 block discarded – undo
832 832
 	 * @return EE_Form_Section_Proper
833 833
 	 * @throws \EE_Error
834 834
 	 */
835
-	public function billing_info(){
835
+	public function billing_info() {
836 836
 		$payment_method = $this->payment_method();
837
-		if ( !$payment_method){
837
+		if ( ! $payment_method) {
838 838
 			EE_Error::add_error(__("Could not find billing info for transaction because no gateway has been used for it yet", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
839 839
 			return false;
840 840
 		}
841 841
 		$primary_reg = $this->primary_registration();
842
-		if ( ! $primary_reg ) {
843
-			EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ );
842
+		if ( ! $primary_reg) {
843
+			EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
844 844
 			return FALSE;
845 845
 		}
846 846
 		$attendee = $primary_reg->attendee();
847
-		if ( ! $attendee ) {
848
-			EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ );
847
+		if ( ! $attendee) {
848
+			EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
849 849
 			return FALSE;
850 850
 		}
851 851
 		return $attendee->billing_info_for_payment_method($payment_method);
@@ -886,15 +886,15 @@  discard block
 block discarded – undo
886 886
 	 * @return EE_Payment_Method
887 887
 	 * @throws \EE_Error
888 888
 	 */
889
-	public function payment_method(){
889
+	public function payment_method() {
890 890
 		$pm = $this->get_first_related('Payment_Method');
891
-		if( $pm instanceof EE_Payment_Method ){
891
+		if ($pm instanceof EE_Payment_Method) {
892 892
 			return $pm;
893
-		}else{
893
+		} else {
894 894
 			$last_payment = $this->last_payment();
895
-			if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){
895
+			if ($last_payment instanceof EE_Payment && $last_payment->payment_method()) {
896 896
 				return $last_payment->payment_method();
897
-			}else{
897
+			} else {
898 898
 				return NULL;
899 899
 			}
900 900
 		}
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 	 * @throws \EE_Error
910 910
 	 */
911 911
 	public function last_payment() {
912
-		return $this->get_first_related( 'Payment', array( 'order_by' => array( 'PAY_ID' => 'desc' ) ) );
912
+		return $this->get_first_related('Payment', array('order_by' => array('PAY_ID' => 'desc')));
913 913
 	}
914 914
 
915 915
 
@@ -920,8 +920,8 @@  discard block
 block discarded – undo
920 920
 	 * @return EE_Line_Item[]
921 921
 	 * @throws \EE_Error
922 922
 	 */
923
-	public function non_ticket_line_items(){
924
-		return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction( $this->ID() );
923
+	public function non_ticket_line_items() {
924
+		return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction($this->ID());
925 925
 	}
926 926
 
927 927
 
Please login to merge, or discard this patch.
core/db_models/EEM_Base.model.php 4 patches
Braces   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
542 542
 				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
543 543
 			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
544
-		}else{
544
+		} else{
545 545
 			return array();
546 546
 		}
547 547
 }
@@ -766,13 +766,13 @@  discard block
 block discarded – undo
766 766
 				$last_model_name = end( $models_to_follow_to_wp_users );
767 767
 				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
768 768
 				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
769
-			}else{
769
+			} else{
770 770
 				$model_with_fk_to_wp_users = $this;
771 771
 				$model_chain_to_wp_user = '';
772 772
 			}
773 773
 			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
774 774
 			return $model_chain_to_wp_user . $wp_user_field->get_name();
775
-		}catch( EE_Error $e ) {
775
+		} catch( EE_Error $e ) {
776 776
 			return false;
777 777
 		}
778 778
 	}
@@ -800,11 +800,11 @@  discard block
 block discarded – undo
800 800
 	public function is_owned() {
801 801
 		if( $this->model_chain_to_wp_user() ){
802 802
 			return true;
803
-		}else{
803
+		} else{
804 804
 			try{
805 805
 				$this->get_foreign_key_to( 'WP_User' );
806 806
 				return true;
807
-			}catch( EE_Error $e ){
807
+			} catch( EE_Error $e ){
808 808
 				return false;
809 809
 			}
810 810
 		}
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
901 901
 			}
902 902
 			$columns_to_select_string = implode(", ",$select_sql_array);
903
-		}else{
903
+		} else{
904 904
 			$columns_to_select_string = $columns_to_select;
905 905
 		}
906 906
 		return $columns_to_select_string;
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
 		}
957 957
 		if( $this->has_primary_key_field ( ) ) {
958 958
 			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
959
-		}else{
959
+		} else{
960 960
 			//no primary key, so the $id must be from the get_index_primary_key_string()
961 961
 			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
962 962
 		}
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 		$items = $this->get_all($query_params);
983 983
 		if(empty($items)){
984 984
 			return null;
985
-		}else{
985
+		} else{
986 986
 			return array_shift($items);
987 987
 		}
988 988
 	}
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1371 1371
 				if( $this->has_primary_key_field() ){
1372 1372
 					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1373
-				}else{
1373
+				} else{
1374 1374
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work)
1375 1375
 					$main_table_pk_value = null;
1376 1376
 				}
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
 		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1410 1410
 			if( $this->has_primary_key_field() ){
1411 1411
 				$model_objs_affected_ids = $this->get_col( $query_params );
1412
-			}else{
1412
+			} else{
1413 1413
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1414 1414
 				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1415 1415
 				$model_objs_affected_ids = array();
@@ -1473,9 +1473,9 @@  discard block
 block discarded – undo
1473 1473
 
1474 1474
 		if( $field_to_select ){
1475 1475
 			$field = $this->field_settings_for( $field_to_select );
1476
-		}elseif( $this->has_primary_key_field ( ) ){
1476
+		} elseif( $this->has_primary_key_field ( ) ){
1477 1477
 			$field = $this->get_primary_key_field();
1478
-		}else{
1478
+		} else{
1479 1479
 			//no primary key, just grab the first column
1480 1480
 			$field = reset( $this->field_settings());
1481 1481
 		}
@@ -1502,7 +1502,7 @@  discard block
 block discarded – undo
1502 1502
 		$col = $this->get_col( $query_params, $field_to_select );
1503 1503
 		if( ! empty( $col ) ) {
1504 1504
 			return reset( $col );
1505
-		}else{
1505
+		} else{
1506 1506
 			return NULL;
1507 1507
 		}
1508 1508
 	}
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
 
1630 1630
 			//		/echo "delete sql:$SQL";
1631 1631
 			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1632
-		}else{
1632
+		} else{
1633 1633
 			$rows_deleted = 0;
1634 1634
 		}
1635 1635
 
@@ -1673,7 +1673,7 @@  discard block
 block discarded – undo
1673 1673
 		//first, if $ignore_this_model_obj was supplied, get its model
1674 1674
 		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1675 1675
 			$ignored_model = $ignore_this_model_obj->get_model();
1676
-		}else{
1676
+		} else{
1677 1677
 			$ignored_model = null;
1678 1678
 		}
1679 1679
 		//now check all the relations of $this_model_obj_or_id and see if there
@@ -1686,7 +1686,7 @@  discard block
 block discarded – undo
1686 1686
 				if($ignored_model && $relation_name === $ignored_model->get_this_model_name()){
1687 1687
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1688 1688
 					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1689
-				}else{
1689
+				} else{
1690 1690
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1691 1691
 				}
1692 1692
 
@@ -1759,7 +1759,7 @@  discard block
 block discarded – undo
1759 1759
 			}
1760 1760
 
1761 1761
 			return !empty($query) ? implode(' AND ', $query ) : '';
1762
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1762
+		} elseif(count($this->get_combined_primary_key_fields()) > 1){
1763 1763
 			$ways_to_identify_a_row = array();
1764 1764
 			$fields = $this->get_combined_primary_key_fields();
1765 1765
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
@@ -1771,7 +1771,7 @@  discard block
 block discarded – undo
1771 1771
 				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1772 1772
 			}
1773 1773
 			return implode(" OR ",$ways_to_identify_a_row);
1774
-		}else{
1774
+		} else{
1775 1775
 			//so there's no primary key and no combined key...
1776 1776
 			//sorry, can't help you
1777 1777
 			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
@@ -1795,10 +1795,10 @@  discard block
 block discarded – undo
1795 1795
 		if($field_to_count){
1796 1796
 			$field_obj = $this->field_settings_for($field_to_count);
1797 1797
 			$column_to_count = $field_obj->get_qualified_column();
1798
-		}elseif($this->has_primary_key_field ()){
1798
+		} elseif($this->has_primary_key_field ()){
1799 1799
 			$pk_field_obj = $this->get_primary_key_field();
1800 1800
 			$column_to_count = $pk_field_obj->get_qualified_column();
1801
-		}else{//there's no primary key
1801
+		} else{//there's no primary key
1802 1802
 			$column_to_count = '*';
1803 1803
 		}
1804 1804
 
@@ -1823,7 +1823,7 @@  discard block
 block discarded – undo
1823 1823
 		if($field_to_sum){
1824 1824
 			$field_obj = $this->field_settings_for($field_to_sum);
1825 1825
 
1826
-		}else{
1826
+		} else{
1827 1827
 			$field_obj = $this->get_primary_key_field();
1828 1828
 		}
1829 1829
 		$column_to_count = $field_obj->get_qualified_column();
@@ -1833,7 +1833,7 @@  discard block
 block discarded – undo
1833 1833
 		$data_type = $field_obj->get_wpdb_data_type();
1834 1834
 		if( $data_type === '%d' || $data_type === '%s' ){
1835 1835
 			return (float)$return_value;
1836
-		}else{//must be %f
1836
+		} else{//must be %f
1837 1837
 			return (float)$return_value;
1838 1838
 		}
1839 1839
 	}
@@ -1871,10 +1871,10 @@  discard block
 block discarded – undo
1871 1871
 			$wpdb->show_errors( $old_show_errors_value );
1872 1872
 			if( ! empty( $wpdb->last_error ) ){
1873 1873
 				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1874
-			}elseif( $result === false ){
1874
+			} elseif( $result === false ){
1875 1875
 				throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) );
1876 1876
 			}
1877
-		}elseif( $result === false ) {
1877
+		} elseif( $result === false ) {
1878 1878
 			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1879 1879
 		}
1880 1880
 		return $result;
@@ -2206,7 +2206,7 @@  discard block
 block discarded – undo
2206 2206
 		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2207 2207
 		if( $results ){
2208 2208
 			return array_shift($results);
2209
-		}else{
2209
+		} else{
2210 2210
 			return null;
2211 2211
 		}
2212 2212
 
@@ -2277,7 +2277,7 @@  discard block
 block discarded – undo
2277 2277
 			 */
2278 2278
 			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2279 2279
 			return $new_id;
2280
-		}else{
2280
+		} else{
2281 2281
 			return FALSE;
2282 2282
 		}
2283 2283
 	}
@@ -2335,9 +2335,9 @@  discard block
 block discarded – undo
2335 2335
 	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2336 2336
 		if($obj_or_fields_array instanceof EE_Base_Class){
2337 2337
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2338
-		}elseif( is_array($obj_or_fields_array)){
2338
+		} elseif( is_array($obj_or_fields_array)){
2339 2339
 			$fields_n_values = $obj_or_fields_array;
2340
-		}else{
2340
+		} else{
2341 2341
 			throw new EE_Error(
2342 2342
 				sprintf(
2343 2343
 					__(
@@ -2362,7 +2362,7 @@  discard block
 block discarded – undo
2362 2362
 		//if there is nothing to base this search on, then we shouldn't find anything
2363 2363
 		if( empty( $query_params ) ){
2364 2364
 			return array();
2365
-		}else{
2365
+		} else{
2366 2366
 			return $this->get_one($query_params);
2367 2367
 		}
2368 2368
 	}
@@ -2443,12 +2443,12 @@  discard block
 block discarded – undo
2443 2443
 		if($this->has_primary_key_field()){
2444 2444
 			if($this->get_primary_key_field()->is_auto_increment()){
2445 2445
 				return $wpdb->insert_id;
2446
-			}else{
2446
+			} else{
2447 2447
 				//it's not an auto-increment primary key, so
2448 2448
 				//it must have been supplied
2449 2449
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2450 2450
 			}
2451
-		}else{
2451
+		} else{
2452 2452
 			//we can't return a  primary key because there is none. instead return
2453 2453
 			//a unique string indicating this model
2454 2454
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2500,7 +2500,7 @@  discard block
 block discarded – undo
2500 2500
 					//leave the value alone
2501 2501
 			}
2502 2502
 			return $value;
2503
-		}else{
2503
+		} else{
2504 2504
 			return $value;
2505 2505
 		}
2506 2506
 	}
@@ -2669,10 +2669,10 @@  discard block
 block discarded – undo
2669 2669
 					if (! is_array($possibly_array_of_params)){
2670 2670
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
2671 2671
 							$param,$possibly_array_of_params));
2672
-					}else{
2672
+					} else{
2673 2673
 						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2674 2674
 					}
2675
-				}elseif($query_param_type === 0 //ie WHERE
2675
+				} elseif($query_param_type === 0 //ie WHERE
2676 2676
 						&& is_array($possibly_array_of_params)
2677 2677
 						&& isset($possibly_array_of_params[2])
2678 2678
 						&& $possibly_array_of_params[2] == true){
@@ -2950,7 +2950,7 @@  discard block
 block discarded – undo
2950 2950
 	private function _extract_order($should_be_order_string){
2951 2951
 		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2952 2952
 			return $should_be_order_string;
2953
-		}else{
2953
+		} else{
2954 2954
 			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
2955 2955
 		}
2956 2956
 	}
@@ -3029,7 +3029,7 @@  discard block
 block discarded – undo
3029 3029
 		foreach($default_where_conditions as $key => $val){
3030 3030
 			if( isset($provided_where_conditions[$key])){
3031 3031
 				$none_overridden = false;
3032
-			}else{
3032
+			} else{
3033 3033
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
3034 3034
 			}
3035 3035
 		}
@@ -3155,7 +3155,7 @@  discard block
 block discarded – undo
3155 3155
 		if(array_key_exists($query_param,$this_model_fields)){
3156 3156
 			if($allow_fields){
3157 3157
 				return;
3158
-			}else{
3158
+			} else{
3159 3159
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
3160 3160
 						$query_param,get_class($this),$query_param_type,$original_query_param));
3161 3161
 			}
@@ -3164,7 +3164,7 @@  discard block
 block discarded – undo
3164 3164
 		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
3165 3165
 			if($allow_logic_query_params){
3166 3166
 				return;
3167
-			}else{
3167
+			} else{
3168 3168
 				throw new EE_Error(
3169 3169
 					sprintf(
3170 3170
 						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
@@ -3195,12 +3195,12 @@  discard block
 block discarded – undo
3195 3195
 					//we should actually end in a field name, not a model like this!
3196 3196
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
3197 3197
 					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
3198
-				}else{
3198
+				} else{
3199 3199
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
3200 3200
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
3201 3201
 					return;
3202 3202
 				}
3203
-			}elseif($query_param === $valid_related_model_name){
3203
+			} elseif($query_param === $valid_related_model_name){
3204 3204
 				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3205 3205
 				return;
3206 3206
 			}
@@ -3265,7 +3265,7 @@  discard block
 block discarded – undo
3265 3265
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3266 3266
 		if($SQL){
3267 3267
 			return " WHERE ". $SQL;
3268
-		}else{
3268
+		} else{
3269 3269
 			return '';
3270 3270
 		}
3271 3271
 	}
@@ -3284,7 +3284,7 @@  discard block
 block discarded – undo
3284 3284
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3285 3285
 		if($SQL){
3286 3286
 			return " HAVING ". $SQL;
3287
-		}else{
3287
+		} else{
3288 3288
 			return '';
3289 3289
 		}
3290 3290
 
@@ -3307,7 +3307,7 @@  discard block
 block discarded – undo
3307 3307
 			$model_instance=call_user_func($model_name."::instance");
3308 3308
 			/* @var $model_instance EEM_Base */
3309 3309
 			return $model_instance->field_settings_for($field_name);
3310
-		}else{
3310
+		} else{
3311 3311
 			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3312 3312
 		}
3313 3313
 	}
@@ -3340,14 +3340,14 @@  discard block
 block discarded – undo
3340 3340
 						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3341 3341
 						break;
3342 3342
 				}
3343
-			}else{
3343
+			} else{
3344 3344
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3345 3345
 
3346 3346
 				//if it's not a normal field, maybe it's a custom selection?
3347 3347
 				if( ! $field_obj){
3348 3348
 					if(isset( $this->_custom_selections[$query_param][1])){
3349 3349
 						$field_obj = $this->_custom_selections[$query_param][1];
3350
-					}else{
3350
+					} else{
3351 3351
 						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3352 3352
 					}
3353 3353
 				}
@@ -3372,11 +3372,11 @@  discard block
 block discarded – undo
3372 3372
 		if( $field ){
3373 3373
 			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3374 3374
 			return $table_alias_prefix . $field->get_qualified_column();
3375
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3375
+		} elseif(array_key_exists($query_param,$this->_custom_selections)){
3376 3376
 			//maybe it's custom selection item?
3377 3377
 			//if so, just use it as the "column name"
3378 3378
 			return $query_param;
3379
-		}else{
3379
+		} else{
3380 3380
 			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
3381 3381
 		}
3382 3382
 	}
@@ -3393,7 +3393,7 @@  discard block
 block discarded – undo
3393 3393
 		$pos_of_star = strpos($condition_query_param_key, '*');
3394 3394
 		if($pos_of_star === FALSE){
3395 3395
 			return $condition_query_param_key;
3396
-		}else{
3396
+		} else{
3397 3397
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3398 3398
 			return $condition_query_param_sans_star;
3399 3399
 		}
@@ -3578,7 +3578,7 @@  discard block
 block discarded – undo
3578 3578
 		global $wpdb;
3579 3579
 		if($field_obj instanceof EE_Model_Field_Base){
3580 3580
 			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3581
-		}else{//$field_obj should really just be a data type
3581
+		} else{//$field_obj should really just be a data type
3582 3582
 			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3583 3583
 				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
3584 3584
 			}
@@ -3607,14 +3607,14 @@  discard block
 block discarded – undo
3607 3607
 		if($number_of_parts === 1){
3608 3608
 			$field_name = $last_query_param_part;
3609 3609
 			$model_obj = $this;
3610
-		}else{// $number_of_parts >= 2
3610
+		} else{// $number_of_parts >= 2
3611 3611
 			//the last part is the column name, and there are only 2parts. therefore...
3612 3612
 			$field_name = $last_query_param_part;
3613 3613
 			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3614 3614
 		}
3615 3615
 		try{
3616 3616
 			return $model_obj->field_settings_for($field_name);
3617
-		}catch(EE_Error $e){
3617
+		} catch(EE_Error $e){
3618 3618
 			return null;
3619 3619
 		}
3620 3620
 	}
@@ -3633,7 +3633,7 @@  discard block
 block discarded – undo
3633 3633
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3634 3634
 		if($field){
3635 3635
 			return $field->get_qualified_column();
3636
-		}else{
3636
+		} else{
3637 3637
 			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
3638 3638
 		}
3639 3639
 	}
@@ -3704,7 +3704,7 @@  discard block
 block discarded – undo
3704 3704
 					//the FROM statement, BUT the primary table isn't. So we want
3705 3705
 					//to add the inverse join sql
3706 3706
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3707
-				}else{
3707
+				} else{
3708 3708
 					//just add a regular JOIN to this table from the primary table
3709 3709
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3710 3710
 				}
@@ -3817,7 +3817,7 @@  discard block
 block discarded – undo
3817 3817
 		$fieldSettings = $this->field_settings(true);
3818 3818
 		if( isset($fieldSettings[$fieldName])){
3819 3819
 			return true;
3820
-		}else{
3820
+		} else{
3821 3821
 			return false;
3822 3822
 		}
3823 3823
 	}
@@ -3831,7 +3831,7 @@  discard block
 block discarded – undo
3831 3831
 		$relations = $this->relation_settings();
3832 3832
 		if(isset($relations[$relation_name])){
3833 3833
 			return true;
3834
-		}else{
3834
+		} else{
3835 3835
 			return false;
3836 3836
 		}
3837 3837
 	}
@@ -3882,7 +3882,7 @@  discard block
 block discarded – undo
3882 3882
 			try{
3883 3883
 				$this->get_primary_key_field();
3884 3884
 				$this->_has_primary_key_field = true;
3885
-			}catch(EE_Error $e){
3885
+			} catch(EE_Error $e){
3886 3886
 				$this->_has_primary_key_field = false;
3887 3887
 			}
3888 3888
 		}
@@ -3961,7 +3961,7 @@  discard block
 block discarded – undo
3961 3961
 				}
3962 3962
 			}
3963 3963
 			return $this->_cached_fields;
3964
-		}else{
3964
+		} else{
3965 3965
 			if( $this->_cached_fields_non_db_only === NULL ){
3966 3966
 				$this->_cached_fields_non_db_only = array();
3967 3967
 				foreach($this->_fields as $fields_corresponding_to_table){
@@ -4097,7 +4097,7 @@  discard block
 block discarded – undo
4097 4097
 			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
4098 4098
 				return NULL;
4099 4099
 			}
4100
-		}else if($this->unique_indexes()){
4100
+		} else if($this->unique_indexes()){
4101 4101
 			$first_column = reset($this_model_fields_n_values);
4102 4102
 			if(empty($first_column)){
4103 4103
 				return NULL;
@@ -4112,7 +4112,7 @@  discard block
 block discarded – undo
4112 4112
 				// add this new object to the entity map
4113 4113
 				$classInstance = $this->add_to_entity_map( $classInstance );
4114 4114
 			}
4115
-		}else{
4115
+		} else{
4116 4116
 			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4117 4117
 		}
4118 4118
 
@@ -4199,7 +4199,7 @@  discard block
 block discarded – undo
4199 4199
 						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
4200 4200
 					}
4201 4201
 				}
4202
-			}else{
4202
+			} else{
4203 4203
 				//the table's rows existed. Use their values
4204 4204
 				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4205 4205
 					if( ! $field_obj->is_db_only_field() ){
@@ -4229,7 +4229,7 @@  discard block
 block discarded – undo
4229 4229
 		//or is it a db-only field? (not relating to the model)
4230 4230
 		if( isset( $cols_n_values[ $qualified_column ] ) ){
4231 4231
 			$value = $cols_n_values[ $qualified_column ];
4232
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
4232
+		} elseif( isset( $cols_n_values[ $regular_column ] ) ){
4233 4233
 			$value = $cols_n_values[ $regular_column ];
4234 4234
 		}
4235 4235
 		return $value;
@@ -4263,7 +4263,7 @@  discard block
 block discarded – undo
4263 4263
 				}
4264 4264
 			}
4265 4265
 			return $obj_in_map;
4266
-		}else{
4266
+		} else{
4267 4267
 			return $this->get_one_by_ID( $id );
4268 4268
 		}
4269 4269
 	}
@@ -4298,7 +4298,7 @@  discard block
 block discarded – undo
4298 4298
 				}
4299 4299
 			}
4300 4300
 			return $obj_in_map;
4301
-		}else{
4301
+		} else{
4302 4302
 			$this->add_to_entity_map( $replacing_model_obj );
4303 4303
 			return $replacing_model_obj;
4304 4304
 		}
@@ -4443,13 +4443,13 @@  discard block
 block discarded – undo
4443 4443
 		if( $base_class_obj_or_id instanceof $className ){
4444 4444
 			/** @var $base_class_obj_or_id EE_Base_Class */
4445 4445
 			$id = $base_class_obj_or_id->ID();
4446
-		}elseif(is_int($base_class_obj_or_id)){
4446
+		} elseif(is_int($base_class_obj_or_id)){
4447 4447
 			//assume it's an ID
4448 4448
 			$id = $base_class_obj_or_id;
4449
-		}elseif(is_string($base_class_obj_or_id)){
4449
+		} elseif(is_string($base_class_obj_or_id)){
4450 4450
 			//assume its a string representation of the object
4451 4451
 			$id = $base_class_obj_or_id;
4452
-		}else{
4452
+		} else{
4453 4453
 			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4454 4454
 		}
4455 4455
 		return $id;
@@ -4596,9 +4596,9 @@  discard block
 block discarded – undo
4596 4596
 
4597 4597
 		if($model_object_or_attributes_array instanceof EE_Base_Class){
4598 4598
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4599
-		}elseif(is_array($model_object_or_attributes_array)){
4599
+		} elseif(is_array($model_object_or_attributes_array)){
4600 4600
 			$attributes_array = $model_object_or_attributes_array;
4601
-		}else{
4601
+		} else{
4602 4602
 			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
4603 4603
 		}
4604 4604
 		//even copies obviously won't have the same ID, so remove the primary key
@@ -4608,7 +4608,7 @@  discard block
 block discarded – undo
4608 4608
 		}
4609 4609
 		if(isset($query_params[0])){
4610 4610
 			$query_params[0] = array_merge($attributes_array,$query_params);
4611
-		}else{
4611
+		} else{
4612 4612
 			$query_params[0] = $attributes_array;
4613 4613
 		}
4614 4614
 		return $this->get_all($query_params);
@@ -4633,7 +4633,7 @@  discard block
 block discarded – undo
4633 4633
 		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4634 4634
 		if(is_array($copies)){
4635 4635
 			return array_shift($copies);
4636
-		}else{
4636
+		} else{
4637 4637
 			return null;
4638 4638
 		}
4639 4639
 	}
@@ -4667,7 +4667,7 @@  discard block
 block discarded – undo
4667 4667
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4668 4668
 		if($sql_operator){
4669 4669
 			return $sql_operator;
4670
-		}else{
4670
+		} else{
4671 4671
 			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
4672 4672
 		}
4673 4673
 	}
@@ -4872,7 +4872,7 @@  discard block
 block discarded – undo
4872 4872
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4873 4873
 		if( in_array( $context, $valid_cap_contexts ) ) {
4874 4874
 			return true;
4875
-		}else{
4875
+		} else{
4876 4876
 			throw new EE_Error(
4877 4877
 				sprintf(
4878 4878
 					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
Please login to merge, or discard this patch.
Doc Comments   +17 added lines, -14 removed lines patch added patch discarded remove patch
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 	 * Returns the name of the field's name that points to the WP_User table
765 765
 	 *  on this model (or follows the _model_chain_to_wp_user and uses that model's
766 766
 	 * foreign key to the WP_User table)
767
-	 * @return string|boolean string on success, boolean false when there is no
767
+	 * @return string|false string on success, boolean false when there is no
768 768
 	 * foreign key to the WP_User table
769 769
 	 */
770 770
 	public function wp_user_field_name() {
@@ -859,6 +859,7 @@  discard block
 block discarded – undo
859 859
 	 * If you would like to use these custom selections in WHERE, GROUP_BY, or HAVING clauses, you must instead provide an array.
860 860
 	 * Array keys are the aliases used to refer to this selection, and values are to be numerically-indexed arrays, where 0 is the selection
861 861
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
862
+	 * @param string $columns_to_select
862 863
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
863 864
 	 * @throws \EE_Error
864 865
 	 */
@@ -1203,7 +1204,7 @@  discard block
 block discarded – undo
1203 1204
 	 * @param bool   $pretty          Whether to return the pretty formats (true) or not (false).
1204 1205
 	 * @throws EE_Error   If the given field_name is not of the EE_Datetime_Field type.
1205 1206
 	 *
1206
-	 * @return array formats in an array with the date format first, and the time format last.
1207
+	 * @return string[] formats in an array with the date format first, and the time format last.
1207 1208
 	 */
1208 1209
 	public function get_formats_for( $field_name, $pretty = false ) {
1209 1210
 		$field_settings = $this->field_settings_for( $field_name );
@@ -1238,7 +1239,7 @@  discard block
 block discarded – undo
1238 1239
 	 *
1239 1240
 	 * @throws EE_Error   	If the given field_name is not of the EE_Datetime_Field type.
1240 1241
 	 *
1241
-	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1242
+	 * @return string|null  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1242 1243
 	 *                    	     exception is triggered.
1243 1244
 	 */
1244 1245
 	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
@@ -1549,7 +1550,7 @@  discard block
 block discarded – undo
1549 1550
 	 * Wrapper for EEM_Base::delete_permanently()
1550 1551
 	 *
1551 1552
 	 * @param mixed $id
1552
-	 * @return boolean whether the row got deleted or not
1553
+	 * @return integer whether the row got deleted or not
1553 1554
 	 * @throws \EE_Error
1554 1555
 	 */
1555 1556
 	public function delete_permanently_by_ID( $id ) {
@@ -1568,7 +1569,7 @@  discard block
 block discarded – undo
1568 1569
 	 * Wrapper for EEM_Base::delete()
1569 1570
 	 *
1570 1571
 	 * @param mixed $id
1571
-	 * @return boolean whether the row got deleted or not
1572
+	 * @return integer whether the row got deleted or not
1572 1573
 	 * @throws \EE_Error
1573 1574
 	 */
1574 1575
 	public function delete_by_ID( $id ){
@@ -1964,7 +1965,7 @@  discard block
 block discarded – undo
1964 1965
 	/**
1965 1966
 	 * Verifies the EE addons' database is up-to-date and records that we've done it on
1966 1967
 	 * EEM_Base::$_db_verification_level
1967
-	 * @param $wpdb_method
1968
+	 * @param string $wpdb_method
1968 1969
 	 * @param $arguments_to_provide
1969 1970
 	 * @return string
1970 1971
 	 */
@@ -2059,6 +2060,7 @@  discard block
 block discarded – undo
2059 2060
 	 * @return boolean of success
2060 2061
 	 * @throws \EE_Error
2061 2062
 	 * @param array  $where_query  This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
2063
+	 * @param EE_Base_Class $id_or_obj
2062 2064
 	 */
2063 2065
 	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
2064 2066
 		$relation_obj = $this->related_settings_for($relationName);
@@ -2068,7 +2070,7 @@  discard block
 block discarded – undo
2068 2070
 
2069 2071
 
2070 2072
 	/**
2071
-	 * @param mixed           $id_or_obj
2073
+	 * @param EE_Base_Class           $id_or_obj
2072 2074
 	 * @param string          $relationName
2073 2075
 	 * @param array           $where_query_params
2074 2076
 	 * @param EE_Base_Class[] objects to which relations were removed
@@ -2107,7 +2109,7 @@  discard block
 block discarded – undo
2107 2109
 	 * However, if the model objects can't be deleted because of blocking related model objects, then
2108 2110
 	 * they aren't deleted. (Unless the thing that would have been deleted can be soft-deleted, that still happens).
2109 2111
 	 *
2110
-	 * @param EE_Base_Class|int|string $id_or_obj
2112
+	 * @param EE_Base_Class $id_or_obj
2111 2113
 	 * @param string                   $model_name
2112 2114
 	 * @param array                    $query_params
2113 2115
 	 * @return int how many deleted
@@ -2127,7 +2129,7 @@  discard block
 block discarded – undo
2127 2129
 	 * the model objects can't be hard deleted because of blocking related model objects,
2128 2130
 	 * just does a soft-delete on them instead.
2129 2131
 	 *
2130
-	 * @param EE_Base_Class|int|string $id_or_obj
2132
+	 * @param EE_Base_Class $id_or_obj
2131 2133
 	 * @param string                   $model_name
2132 2134
 	 * @param array                    $query_params
2133 2135
 	 * @return int how many deleted
@@ -2176,6 +2178,7 @@  discard block
 block discarded – undo
2176 2178
 	 * @param string $model_name   like 'Event', or 'Registration'
2177 2179
 	 * @param array  $query_params like EEM_Base::get_all's
2178 2180
 	 * @param string $field_to_sum name of field to count by. By default, uses primary key
2181
+	 * @param EE_Base_Class $id_or_obj
2179 2182
 	 * @return float
2180 2183
 	 * @throws \EE_Error
2181 2184
 	 */
@@ -2581,7 +2584,7 @@  discard block
 block discarded – undo
2581 2584
 	/**
2582 2585
 	 * Finds all the fields that correspond to the given table
2583 2586
 	 * @param string $table_alias, array key in EEM_Base::_tables
2584
-	 * @return EE_Model_Field_Base[]
2587
+	 * @return EE_Model_Field_Base
2585 2588
 	 */
2586 2589
 	public function _get_fields_for_table($table_alias){
2587 2590
 		return $this->_fields[$table_alias];
@@ -3844,8 +3847,8 @@  discard block
 block discarded – undo
3844 3847
 	/**
3845 3848
 	 * gets the field object of type 'primary_key' from the fieldsSettings attribute.
3846 3849
 	 * Eg, on EE_Answer that would be ANS_ID field object
3847
-	 * @param $field_obj
3848
-	 * @return EE_Model_Field_Base
3850
+	 * @param EE_Model_Field_Base $field_obj
3851
+	 * @return boolean
3849 3852
 	 */
3850 3853
 	public function is_primary_key_field( $field_obj ){
3851 3854
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
@@ -3940,7 +3943,7 @@  discard block
 block discarded – undo
3940 3943
 	 * Gets the actual table for the table alias
3941 3944
 	 * @param string $table_alias eg Event, Event_Meta, Registration, Transaction, but maybe
3942 3945
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3943
-	 * @return EE_Table_Base
3946
+	 * @return string
3944 3947
 	 */
3945 3948
 	public function get_table_for_alias($table_alias){
3946 3949
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
@@ -4483,7 +4486,7 @@  discard block
 block discarded – undo
4483 4486
 	}
4484 4487
 	/**
4485 4488
 	 * Read comments for assume_values_already_prepared_by_model_object()
4486
-	 * @return int
4489
+	 * @return boolean
4487 4490
 	 */
4488 4491
 	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4489 4492
 		return $this->_values_already_prepared_by_model_object;
Please login to merge, or discard this patch.
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -615,11 +615,11 @@  discard block
 block discarded – undo
615 615
 	 * Gets all the EE_Base_Class objects which match the $query_params, by querying the DB.
616 616
 	 *
617 617
 	 * @param array $query_params {
618
-     *	@var array $0 (where) array {
618
+	 *	@var array $0 (where) array {
619 619
 	 *		eg: array('QST_display_text'=>'Are you bob?','QST_admin_text'=>'Determine if user is bob')
620
-			* becomes
620
+	 * becomes
621 621
 	 *		SQL >> "...WHERE QST_display_text = 'Are you bob?' AND QST_admin_text = 'Determine if user is bob'...")
622
-     *		To add WHERE conditions based on related models (and even models-related-to-related-models) prepend the model's name
622
+	 *		To add WHERE conditions based on related models (and even models-related-to-related-models) prepend the model's name
623 623
 	 *		onto the field name. Eg, EEM_Event::instance()->get_all(array(array('Venue.VNU_ID'=>12)));
624 624
 	 *		becomes
625 625
 	 *		SQL >> "SELECT * FROM wp_posts AS Event_CPT
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 	 *		SQL >> "...WHERE QST_display_text LIKE '%bob%' AND QST_ID < 34 AND QST_wp_user IN (1,2,7,23)...".
640 640
 	 *        Valid operators so far: =, !=, <, <=, >, >=, LIKE, NOT LIKE, IN (followed by numeric-indexed array),
641 641
 	 *          NOT IN (dido), BETWEEN (followed by an array with exactly 2 date strings), IS NULL, and IS NOT NULL
642
-     *		Values can be a string, int, or float. They can also be arrays IFF the operator is IN.
642
+	 *		Values can be a string, int, or float. They can also be arrays IFF the operator is IN.
643 643
 	 *        Also, values can actually be field names. To indicate the value is a field,
644 644
 	 *          simply provide a third array item (true) to the operator-value array like so:
645 645
 	 *		eg: array( 'DTT_reg_limit' => array('>', 'DTT_sold', TRUE) )
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 	 *		Note: you can also use related model field names like you would any other field name.
649 649
 	 *		eg: array('Datetime.DTT_reg_limit'=>array('=','Datetime.DTT_sold',TRUE)
650 650
 	 *		could be used if you were querying EEM_Tickets (because Datetime is directly related to tickets)
651
-     *		Also, by default all the where conditions are AND'd together.
651
+	 *		Also, by default all the where conditions are AND'd together.
652 652
 	 *		To override this, add an array key 'OR' (or 'AND') and the array to be OR'd together
653 653
 	 *		eg: array('OR'=>array('TXN_ID' => 23 , 'TXN_timestamp__>' => 345678912))
654 654
 	 *		becomes
@@ -663,17 +663,17 @@  discard block
 block discarded – undo
663 663
 	 *		eg array('OR'=>array('NOT'=>array('TXN_total' => 50, 'TXN_paid'=>23)),AND=>array('TXN_ID'=>1,'STS_ID'=>'TIN')
664 664
 	 *		becomes
665 665
 	 *		SQL >> "...where ! (TXN_total =50 OR TXN_paid =23) AND TXN_ID=1 AND STS_ID='TIN'"
666
-     *		They can be nested indefinitely.
666
+	 *		They can be nested indefinitely.
667 667
 	 *		eg: array('OR'=>array('TXN_total' => 23, 'NOT'=> array( 'TXN_timestamp'=> 345678912, 'AND'=>array('TXN_paid' => 53, 'STS_ID' => 'TIN'))))
668 668
 	 *		becomes
669 669
 	 *		SQL >> "...WHERE TXN_total = 23 OR ! (TXN_timestamp = 345678912 OR (TXN_paid = 53 AND STS_ID = 'TIN'))..."
670
-     *		GOTCHA:
670
+	 *		GOTCHA:
671 671
 	 *		because this is an array, array keys must be unique, making it impossible to place two or more where conditions applying to the same field.
672 672
 	 *		eg: array('PAY_timestamp'=>array('>',$start_date),'PAY_timestamp'=>array('<',$end_date),'PAY_timestamp'=>array('!=',$special_date)),
673 673
 	 *		as PHP enforces that the array keys must be unique, thus removing the first two array entries with key 'PAY_timestamp'.
674 674
 	 *		becomes
675 675
 	 *		SQL >> "PAY_timestamp !=  4234232", ignoring the first two PAY_timestamp conditions).
676
-     *		To overcome this, you can add a '*' character to the end of the field's name, followed by anything.
676
+	 *		To overcome this, you can add a '*' character to the end of the field's name, followed by anything.
677 677
 	 *		These will be removed when generating the SQL string, but allow for the array keys to be unique.
678 678
 	 *		eg: you could rewrite the previous query as:
679 679
 	 *		array('PAY_timestamp'=>array('>',$start_date),'PAY_timestamp*1st'=>array('<',$end_date),'PAY_timestamp*2nd'=>array('!=',$special_date))
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 	 *		You will probably only want to do this in hopes of increasing efficiency, as related models which belongs to the current model
707 707
 	 *		(ie, the current model has a foreign key to them, like how Registration belongs to Attendee) can be cached in order
708 708
 	 *		to avoid future queries
709
-     *	@var string $default_where_conditions can be set to 'none', 'this_model_only', 'other_models_only', or 'all'. set this to 'none' to disable all default where conditions. Eg, usually soft-deleted objects are filtered-out
709
+	 *	@var string $default_where_conditions can be set to 'none', 'this_model_only', 'other_models_only', or 'all'. set this to 'none' to disable all default where conditions. Eg, usually soft-deleted objects are filtered-out
710 710
 	 *		if you want to include them, set this query param to 'none'. If you want to ONLY disable THIS model's default where conditions
711 711
 	 *		set it to 'other_models_only'. If you only want this model's default where conditions added to the query, use 'this_model_only'.
712 712
 	 *		If you want to use all default where conditions (default), set to 'all'.
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 	 *                                      can indicate just the columns you
1079 1079
 	 *                                      want and a single array indexed by
1080 1080
 	 *                                      the columns will be returned.
1081
- * @return EE_Base_Class|null|array()
1081
+	 * @return EE_Base_Class|null|array()
1082 1082
 	 * @throws EE_Error
1083 1083
 	 */
1084 1084
 	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
 				//make sure there's no related objects blocking its deletion (if we're checking)
1727 1727
 				if (
1728 1728
 					$allow_blocking
1729
-				    && $this->delete_is_blocked_by_related_models(
1729
+					&& $this->delete_is_blocked_by_related_models(
1730 1730
 						$delete_object[ $primary_table->get_fully_qualified_pk_column() ]
1731 1731
 					)
1732 1732
 				) {
@@ -2873,8 +2873,8 @@  discard block
 block discarded – undo
2873 2873
 		}
2874 2874
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2875 2875
 		if ( ! array_key_exists( 'order_by', $query_params )
2876
-		     && array_key_exists( 'order', $query_params )
2877
-		     && ! empty( $query_params['order'] )
2876
+			 && array_key_exists( 'order', $query_params )
2877
+			 && ! empty( $query_params['order'] )
2878 2878
 		) {
2879 2879
 			$pk_field = $this->get_primary_key_field();
2880 2880
 			$order = $this->_extract_order( $query_params['order'] );
@@ -4409,7 +4409,7 @@  discard block
 block discarded – undo
4409 4409
 				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4410 4410
 			} else if (
4411 4411
 				$primary_key_field instanceof EE_Primary_Key_String_Field
4412
-			    && is_string( $base_class_obj_or_id )
4412
+				&& is_string( $base_class_obj_or_id )
4413 4413
 			) {
4414 4414
 				// assume its a string representation of the object
4415 4415
 				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
Please login to merge, or discard this patch.
Spacing   +965 added lines, -965 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @since 				EE4
24 24
  *
25 25
  */
26
-abstract class EEM_Base extends EE_Base{
26
+abstract class EEM_Base extends EE_Base {
27 27
 
28 28
 	//admin posty
29 29
 	//basic -> grants access to mine -> if they don't have it, select none
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 * Flag indicating whether this model has a primary key or not
237 237
 	 * @var boolean
238 238
 	 */
239
-	protected $_has_primary_key_field=null;
239
+	protected $_has_primary_key_field = null;
240 240
 
241 241
 	/**
242 242
 	 * Whether or not this model is based off a table in WP core only (CPTs should set
@@ -298,19 +298,19 @@  discard block
 block discarded – undo
298 298
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
299 299
 	 * @var array
300 300
 	 */
301
-	protected $_between_style_operators = array( 'BETWEEN' );
301
+	protected $_between_style_operators = array('BETWEEN');
302 302
 
303 303
 	/**
304 304
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
305 305
 	 * @var array
306 306
 	 */
307
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
307
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
308 308
 
309 309
 	/**
310 310
 	 * Allowed values for $query_params['order'] for ordering in queries
311 311
 	 * @var array
312 312
 	 */
313
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
313
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
314 314
 
315 315
 	/**
316 316
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
325 325
 	 * @var array
326 326
 	 */
327
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps');
327
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps');
328 328
 
329 329
 	/**
330 330
 	 * All the data types that can be used in $wpdb->prepare statements.
331 331
 	 * @var array
332 332
 	 */
333
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
333
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
334 334
 
335 335
 	/**
336 336
 	 * 	EE_Registry Object
@@ -363,17 +363,17 @@  discard block
 block discarded – undo
363 363
 	/**
364 364
 	 * constant used to show EEM_Base has not yet verified the db on this http request
365 365
 	 */
366
-	const db_verified_none 		= 0;
366
+	const db_verified_none = 0;
367 367
 	/**
368 368
 	 * constant used to show EEM_Base has verified the EE core db on this http request,
369 369
 	 * but not the addons' dbs
370 370
 	 */
371
-	const db_verified_core 		= 1;
371
+	const db_verified_core = 1;
372 372
 	/**
373 373
 	 * constant used to show EEM_Base has verified the addons' dbs (and implicitly
374 374
 	 * the EE core db too)
375 375
 	 */
376
-	const db_verified_addons 	= 2;
376
+	const db_verified_addons = 2;
377 377
 
378 378
 	/**
379 379
 	 * indicates whether an EEM_Base child has already re-verified the DB
@@ -404,13 +404,13 @@  discard block
 block discarded – undo
404 404
 	 * @param null $timezone
405 405
 	 * @throws \EE_Error
406 406
 	 */
407
-	protected function __construct( $timezone = NULL ){
407
+	protected function __construct($timezone = NULL) {
408 408
 		// check that the model has not been loaded too soon
409
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
410
-			throw new EE_Error (
409
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
410
+			throw new EE_Error(
411 411
 				sprintf(
412
-					__( 'The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso' ),
413
-					get_class( $this )
412
+					__('The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso'),
413
+					get_class($this)
414 414
 				)
415 415
 			);
416 416
 		}
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 		 * just use EE_Register_Model_Extension
421 421
 		 * @var EE_Table_Base[] $_tables
422 422
 		 */
423
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
424
-		foreach($this->_tables as $table_alias => $table_obj){
423
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
424
+		foreach ($this->_tables as $table_alias => $table_obj) {
425 425
 			/** @var $table_obj EE_Table_Base */
426 426
 			$table_obj->_construct_finalize_with_alias($table_alias);
427
-			if( $table_obj instanceof EE_Secondary_Table ){
427
+			if ($table_obj instanceof EE_Secondary_Table) {
428 428
 				/** @var $table_obj EE_Secondary_Table */
429 429
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
430 430
 			}
@@ -434,54 +434,54 @@  discard block
 block discarded – undo
434 434
 		 * EE_Register_Model_Extension
435 435
 		 * @param EE_Model_Field_Base[] $_fields
436 436
 		 */
437
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
437
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
438 438
 		$this->_invalidate_field_caches();
439
-		foreach($this->_fields as $table_alias => $fields_for_table){
440
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
441
-				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s",'event_espresso'),$table_alias,implode(",",$this->_fields)));
439
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
440
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
441
+				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s", 'event_espresso'), $table_alias, implode(",", $this->_fields)));
442 442
 			}
443
-			foreach($fields_for_table as $field_name => $field_obj){
443
+			foreach ($fields_for_table as $field_name => $field_obj) {
444 444
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
445 445
 				//primary key field base has a slightly different _construct_finalize
446 446
 				/** @var $field_obj EE_Model_Field_Base */
447
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
447
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
448 448
 			}
449 449
 		}
450 450
 
451 451
 		// everything is related to Extra_Meta
452
-		if( get_class($this) !== 'EEM_Extra_Meta'){
452
+		if (get_class($this) !== 'EEM_Extra_Meta') {
453 453
 			//make extra meta related to everything, but don't block deleting things just
454 454
 			//because they have related extra meta info. For now just orphan those extra meta
455 455
 			//in the future we should automatically delete them
456
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
456
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
457 457
 		}
458 458
 		//and change logs
459
-		if( get_class( $this) !==  'EEM_Change_Log' ) {
460
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
459
+		if (get_class($this) !== 'EEM_Change_Log') {
460
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
461 461
 		}
462 462
 		/**
463 463
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
464 464
 		 * EE_Register_Model_Extension
465 465
 		 * @param EE_Model_Relation_Base[] $_model_relations
466 466
 		 */
467
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
468
-		foreach($this->_model_relations as $model_name => $relation_obj){
467
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
468
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
469 469
 			/** @var $relation_obj EE_Model_Relation_Base */
470 470
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
471 471
 		}
472
-		foreach($this->_indexes as $index_name => $index_obj){
472
+		foreach ($this->_indexes as $index_name => $index_obj) {
473 473
 			/** @var $index_obj EE_Index */
474 474
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
475 475
 		}
476 476
 
477 477
 		$this->set_timezone($timezone);
478 478
 		//finalize default where condition strategy, or set default
479
-		if( ! $this->_default_where_conditions_strategy){
479
+		if ( ! $this->_default_where_conditions_strategy) {
480 480
 			//nothing was set during child constructor, so set default
481 481
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
482 482
 		}
483 483
 		$this->_default_where_conditions_strategy->_finalize_construct($this);
484
-		if( ! $this->_minimum_where_conditions_strategy){
484
+		if ( ! $this->_minimum_where_conditions_strategy) {
485 485
 			//nothing was set during child constructor, so set default
486 486
 			$this->_minimum_where_conditions_strategy = new EE_Default_Where_Conditions();
487 487
 		}
@@ -489,14 +489,14 @@  discard block
 block discarded – undo
489 489
 
490 490
 		//if the cap slug hasn't been set, and we haven't set it to false on purpose
491 491
 		//to indicate to NOT set it, set it to the logical default
492
-		if( $this->_caps_slug === null ) {
493
-			$this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() );
492
+		if ($this->_caps_slug === null) {
493
+			$this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name());
494 494
 		}
495 495
 		//initialize the standard cap restriction generators if none were specified by the child constructor
496
-		if( $this->_cap_restriction_generators !== false ){
497
-			foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){
498
-				if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) {
499
-					$this->_cap_restriction_generators[ $cap_context ] = apply_filters(
496
+		if ($this->_cap_restriction_generators !== false) {
497
+			foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
498
+				if ( ! isset($this->_cap_restriction_generators[$cap_context])) {
499
+					$this->_cap_restriction_generators[$cap_context] = apply_filters(
500 500
 						'FHEE__EEM_Base___construct__standard_cap_restriction_generator',
501 501
 						new EE_Restriction_Generator_Protected(),
502 502
 						$cap_context,
@@ -506,23 +506,23 @@  discard block
 block discarded – undo
506 506
 			}
507 507
 		}
508 508
 		//if there are cap restriction generators, use them to make the default cap restrictions
509
-		if( $this->_cap_restriction_generators !== false ){
510
-			foreach( $this->_cap_restriction_generators as $context => $generator_object ) {
511
-				if( ! $generator_object ){
509
+		if ($this->_cap_restriction_generators !== false) {
510
+			foreach ($this->_cap_restriction_generators as $context => $generator_object) {
511
+				if ( ! $generator_object) {
512 512
 					continue;
513 513
 				}
514
-				if( ! $generator_object instanceof EE_Restriction_Generator_Base ){
514
+				if ( ! $generator_object instanceof EE_Restriction_Generator_Base) {
515 515
 					throw new EE_Error(
516 516
 						sprintf(
517
-							__( 'Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso' ),
517
+							__('Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso'),
518 518
 							$context,
519 519
 							$this->get_this_model_name()
520 520
 						)
521 521
 					);
522 522
 				}
523
-				$action = $this->cap_action_for_context( $context );
524
-				if( ! $generator_object->construction_finalized() ){
525
-					$generator_object->_construct_finalize( $this, $action );
523
+				$action = $this->cap_action_for_context($context);
524
+				if ( ! $generator_object->construction_finalized()) {
525
+					$generator_object->_construct_finalize($this, $action);
526 526
 				}
527 527
 
528 528
 			}
@@ -536,11 +536,11 @@  discard block
 block discarded – undo
536 536
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
537 537
 	 * @return EE_Default_Where_Conditions[]
538 538
 	 */
539
-	protected function _generate_cap_restrictions( $context ){
540
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
541
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
542
-			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
543
-		}else{
539
+	protected function _generate_cap_restrictions($context) {
540
+		if (isset($this->_cap_restriction_generators[$context]) &&
541
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) {
542
+			return $this->_cap_restriction_generators[$context]->generate_restrictions();
543
+		} else {
544 544
 			return array();
545 545
 		}
546 546
 }
@@ -553,16 +553,16 @@  discard block
 block discarded – undo
553 553
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
554 554
 	 *		@return static (as in the concrete child class)
555 555
 	 */
556
-	public static function instance( $timezone = NULL ){
556
+	public static function instance($timezone = NULL) {
557 557
 
558 558
 		// check if instance of Espresso_model already exists
559 559
 		if ( ! static::$_instance instanceof static) {
560 560
 			// instantiate Espresso_model
561
-			static::$_instance = new static( $timezone );
561
+			static::$_instance = new static($timezone);
562 562
 		}
563 563
 
564 564
 		//we might have a timezone set, let set_timezone decide what to do with it
565
-		static::$_instance->set_timezone( $timezone );
565
+		static::$_instance->set_timezone($timezone);
566 566
 
567 567
 		// Espresso_model object
568 568
 		return static::$_instance;
@@ -575,11 +575,11 @@  discard block
 block discarded – undo
575 575
 	 * @param null | string $timezone
576 576
 	 * @return static
577 577
 	 */
578
-	public static function reset(  $timezone = NULL ){
579
-		if ( ! is_null( static::$_instance ) ) {
578
+	public static function reset($timezone = NULL) {
579
+		if ( ! is_null(static::$_instance)) {
580 580
 			static::$_instance = null;
581 581
 
582
-			return self::instance( $timezone );
582
+			return self::instance($timezone);
583 583
 		}
584 584
 		return null;
585 585
 	}
@@ -593,19 +593,19 @@  discard block
 block discarded – undo
593 593
 	 * @return array
594 594
 	 * @throws \EE_Error
595 595
 	 */
596
-	 public function status_array( $translated = FALSE ) {
597
-		 if ( ! array_key_exists( 'Status', $this->_model_relations ) ) {
596
+	 public function status_array($translated = FALSE) {
597
+		 if ( ! array_key_exists('Status', $this->_model_relations)) {
598 598
 			 return array();
599 599
 		 }
600 600
 		 $model_name = $this->get_this_model_name();
601
-		 $status_type = str_replace( ' ', '_', strtolower( str_replace( '_', ' ', $model_name ) ) );
602
-		 $stati = EEM_Status::instance()->get_all( array( array( 'STS_type' => $status_type ) ) );
601
+		 $status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
602
+		 $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
603 603
 		 $status_array = array();
604
-		 foreach ( $stati as $status ) {
605
-			 $status_array[ $status->ID() ] = $status->get( 'STS_code' );
604
+		 foreach ($stati as $status) {
605
+			 $status_array[$status->ID()] = $status->get('STS_code');
606 606
 		 }
607 607
 		 return $translated
608
-			 ? EEM_Status::instance()->localized_status( $status_array, false, 'sentence' )
608
+			 ? EEM_Status::instance()->localized_status($status_array, false, 'sentence')
609 609
 			 : $status_array;
610 610
 	 }
611 611
 
@@ -738,10 +738,10 @@  discard block
 block discarded – undo
738 738
 	 *		));
739 739
 	 * @throws \EE_Error
740 740
 	 */
741
-	public function get_all($query_params = array()){
742
-		if( isset( $query_params[ 'limit' ] )
743
-			&& ! isset( $query_params[ 'group_by' ] ) ) {
744
-			$query_params[ 'group_by' ] = array_keys( $this->get_combined_primary_key_fields() );
741
+	public function get_all($query_params = array()) {
742
+		if (isset($query_params['limit'])
743
+			&& ! isset($query_params['group_by'])) {
744
+			$query_params['group_by'] = array_keys($this->get_combined_primary_key_fields());
745 745
 		}
746 746
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
747 747
 	}
@@ -752,10 +752,10 @@  discard block
 block discarded – undo
752 752
 	 * @param array $query_params @see EEM_Base::get_all()
753 753
 	 * @return array like EEM_Base::get_all
754 754
 	 */
755
-	public function alter_query_params_to_only_include_mine( $query_params = array() ) {
755
+	public function alter_query_params_to_only_include_mine($query_params = array()) {
756 756
 		$wp_user_field_name = $this->wp_user_field_name();
757
-		if( $wp_user_field_name ){
758
-			$query_params[0][ $wp_user_field_name ] = get_current_user_id();
757
+		if ($wp_user_field_name) {
758
+			$query_params[0][$wp_user_field_name] = get_current_user_id();
759 759
 		}
760 760
 		return $query_params;
761 761
 	}
@@ -768,19 +768,19 @@  discard block
 block discarded – undo
768 768
 	 * foreign key to the WP_User table
769 769
 	 */
770 770
 	public function wp_user_field_name() {
771
-		try{
772
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
773
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
774
-				$last_model_name = end( $models_to_follow_to_wp_users );
775
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
776
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
777
-			}else{
771
+		try {
772
+			if ( ! empty($this->_model_chain_to_wp_user)) {
773
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
774
+				$last_model_name = end($models_to_follow_to_wp_users);
775
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
776
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
777
+			} else {
778 778
 				$model_with_fk_to_wp_users = $this;
779 779
 				$model_chain_to_wp_user = '';
780 780
 			}
781
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
782
-			return $model_chain_to_wp_user . $wp_user_field->get_name();
783
-		}catch( EE_Error $e ) {
781
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
782
+			return $model_chain_to_wp_user.$wp_user_field->get_name();
783
+		} catch (EE_Error $e) {
784 784
 			return false;
785 785
 		}
786 786
 	}
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 	 * (or transiently-related model)
795 795
 	 * @return string
796 796
 	 */
797
-	public function model_chain_to_wp_user(){
797
+	public function model_chain_to_wp_user() {
798 798
 		return $this->_model_chain_to_wp_user;
799 799
 	}
800 800
 
@@ -806,13 +806,13 @@  discard block
 block discarded – undo
806 806
 	 * @return boolean
807 807
 	 */
808 808
 	public function is_owned() {
809
-		if( $this->model_chain_to_wp_user() ){
809
+		if ($this->model_chain_to_wp_user()) {
810 810
 			return true;
811
-		}else{
812
-			try{
813
-				$this->get_foreign_key_to( 'WP_User' );
811
+		} else {
812
+			try {
813
+				$this->get_foreign_key_to('WP_User');
814 814
 				return true;
815
-			}catch( EE_Error $e ){
815
+			} catch (EE_Error $e) {
816 816
 				return false;
817 817
 			}
818 818
 		}
@@ -834,17 +834,17 @@  discard block
 block discarded – undo
834 834
 	 * @return array | stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
835 835
 	 * @throws \EE_Error
836 836
 	 */
837
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
837
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
838 838
 		// remember the custom selections, if any, and type cast as array
839 839
 		// (unless $columns_to_select is an object, then just set as an empty array)
840 840
 		// Note: (array) 'some string' === array( 'some string' )
841
-		$this->_custom_selections = ! is_object( $columns_to_select ) ? (array) $columns_to_select : array();
842
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
841
+		$this->_custom_selections = ! is_object($columns_to_select) ? (array) $columns_to_select : array();
842
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
843 843
 		$select_expressions = $columns_to_select !== null
844
-			? $this->_construct_select_from_input( $columns_to_select )
845
-			: $this->_construct_default_select_sql( $model_query_info );
846
-		$SQL = "SELECT $select_expressions " . $this->_construct_2nd_half_of_select_query( $model_query_info );
847
-		return $this->_do_wpdb_query( 'get_results', array( $SQL, $output ) );
844
+			? $this->_construct_select_from_input($columns_to_select)
845
+			: $this->_construct_default_select_sql($model_query_info);
846
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
847
+		return $this->_do_wpdb_query('get_results', array($SQL, $output));
848 848
 	}
849 849
 
850 850
 	/**
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
863 863
 	 * @throws \EE_Error
864 864
 	 */
865
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
865
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
866 866
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
867 867
 	}
868 868
 
@@ -874,12 +874,12 @@  discard block
 block discarded – undo
874 874
 	 * @throws EE_Error
875 875
 	 * @return string
876 876
 	 */
877
-	private function _construct_select_from_input($columns_to_select){
878
-		if(is_array($columns_to_select)){
877
+	private function _construct_select_from_input($columns_to_select) {
878
+		if (is_array($columns_to_select)) {
879 879
 			$select_sql_array = array();
880 880
 
881
-			foreach($columns_to_select as $alias => $selection_and_datatype){
882
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
881
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
882
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
883 883
 					throw new EE_Error(
884 884
 						sprintf(
885 885
 							__(
@@ -891,24 +891,24 @@  discard block
 block discarded – undo
891 891
 						)
892 892
 					);
893 893
 				}
894
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
894
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
895 895
 					throw new EE_Error(
896 896
 						sprintf(
897 897
 							__(
898 898
 								"Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)",
899 899
 								"event_espresso"
900 900
 							),
901
-							$selection_and_datatype[ 1 ],
902
-							$selection_and_datatype[ 0 ],
901
+							$selection_and_datatype[1],
902
+							$selection_and_datatype[0],
903 903
 							$alias,
904
-							implode( ",", $this->_valid_wpdb_data_types )
904
+							implode(",", $this->_valid_wpdb_data_types)
905 905
 						)
906 906
 					);
907 907
 				}
908 908
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
909 909
 			}
910
-			$columns_to_select_string = implode(", ",$select_sql_array);
911
-		}else{
910
+			$columns_to_select_string = implode(", ", $select_sql_array);
911
+		} else {
912 912
 			$columns_to_select_string = $columns_to_select;
913 913
 		}
914 914
 		return $columns_to_select_string;
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
 	 * @return string
924 924
 	 * @throws \EE_Error
925 925
 	 */
926
-	public function primary_key_name(){
926
+	public function primary_key_name() {
927 927
 		return $this->get_primary_key_field()->get_name();
928 928
 	}
929 929
 
@@ -935,14 +935,14 @@  discard block
 block discarded – undo
935 935
 	 * @param mixed $id int or string, depending on the type of the model's primary key
936 936
 	 * @return EE_Base_Class
937 937
 	 */
938
-	public function get_one_by_ID($id){
939
-		if( $this->get_from_entity_map( $id ) ){
940
-			return $this->get_from_entity_map( $id );
938
+	public function get_one_by_ID($id) {
939
+		if ($this->get_from_entity_map($id)) {
940
+			return $this->get_from_entity_map($id);
941 941
 		}
942 942
 		return $this->get_one(
943 943
 			$this->alter_query_params_to_restrict_by_ID(
944 944
 				$id,
945
-				array( 'default_where_conditions' => 'minimum' )
945
+				array('default_where_conditions' => 'minimum')
946 946
 			)
947 947
 		);
948 948
 	}
@@ -958,15 +958,15 @@  discard block
 block discarded – undo
958 958
 	 * @return array of normal query params, @see EEM_Base::get_all
959 959
 	 * @throws \EE_Error
960 960
 	 */
961
-	public function alter_query_params_to_restrict_by_ID( $id, $query_params = array() ) {
962
-		if( ! isset( $query_params[ 0 ] ) ) {
963
-			$query_params[ 0 ] = array();
961
+	public function alter_query_params_to_restrict_by_ID($id, $query_params = array()) {
962
+		if ( ! isset($query_params[0])) {
963
+			$query_params[0] = array();
964 964
 		}
965
-		if( $this->has_primary_key_field ( ) ) {
966
-			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
967
-		}else{
965
+		if ($this->has_primary_key_field( )) {
966
+			$query_params[0][$this->primary_key_name()] = $id;
967
+		} else {
968 968
 			//no primary key, so the $id must be from the get_index_primary_key_string()
969
-			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
969
+			$query_params[0] = array_replace_recursive($query_params[0], $this->parse_index_primary_key_string($id));
970 970
 		}
971 971
 		return $query_params;
972 972
 	}
@@ -981,16 +981,16 @@  discard block
 block discarded – undo
981 981
 	 * @return EE_Base_Class | NULL
982 982
 	 * @throws \EE_Error
983 983
 	 */
984
-	public function get_one($query_params = array()){
985
-		if( ! is_array( $query_params ) ){
986
-			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
984
+	public function get_one($query_params = array()) {
985
+		if ( ! is_array($query_params)) {
986
+			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
987 987
 			$query_params = array();
988 988
 		}
989 989
 		$query_params['limit'] = 1;
990 990
 		$items = $this->get_all($query_params);
991
-		if(empty($items)){
991
+		if (empty($items)) {
992 992
 			return null;
993
-		}else{
993
+		} else {
994 994
 			return array_shift($items);
995 995
 		}
996 996
 	}
@@ -1013,8 +1013,8 @@  discard block
 block discarded – undo
1013 1013
 	 * @return EE_Base_Class[]|array
1014 1014
 	 * @throws \EE_Error
1015 1015
 	 */
1016
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1017
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
1016
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1017
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
1018 1018
 	}
1019 1019
 
1020 1020
 
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
 	 * @return EE_Base_Class[]|array
1036 1036
 	 * @throws \EE_Error
1037 1037
 	 */
1038
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1039
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
1038
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1039
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
1040 1040
 	}
1041 1041
 
1042 1042
 
@@ -1057,9 +1057,9 @@  discard block
 block discarded – undo
1057 1057
 	 * @return EE_Base_Class|null|array()
1058 1058
 	 * @throws \EE_Error
1059 1059
 	 */
1060
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1061
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
1062
-		return empty( $results ) ? null : reset( $results );
1060
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1061
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
1062
+		return empty($results) ? null : reset($results);
1063 1063
 	}
1064 1064
 
1065 1065
 
@@ -1081,9 +1081,9 @@  discard block
 block discarded – undo
1081 1081
  * @return EE_Base_Class|null|array()
1082 1082
 	 * @throws EE_Error
1083 1083
 	 */
1084
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1085
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
1086
-		return empty( $results ) ? null : reset( $results );
1084
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1085
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
1086
+		return empty($results) ? null : reset($results);
1087 1087
 	}
1088 1088
 
1089 1089
 
@@ -1104,42 +1104,42 @@  discard block
 block discarded – undo
1104 1104
 	 * @return EE_Base_Class[]|array
1105 1105
 	 * @throws EE_Error
1106 1106
 	 */
1107
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1107
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1108 1108
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
1109
-		if ( empty( $field_to_order_by ) ) {
1110
-			if ( $this->has_primary_key_field() ) {
1109
+		if (empty($field_to_order_by)) {
1110
+			if ($this->has_primary_key_field()) {
1111 1111
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
1112 1112
 			} else {
1113 1113
 
1114
-				if ( WP_DEBUG ) {
1115
-					throw new EE_Error( __( 'EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso' ) );
1114
+				if (WP_DEBUG) {
1115
+					throw new EE_Error(__('EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso'));
1116 1116
 				}
1117
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
1117
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
1118 1118
 				return array();
1119 1119
 			}
1120 1120
 		}
1121 1121
 
1122
-		if( ! is_array( $query_params ) ){
1123
-			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1122
+		if ( ! is_array($query_params)) {
1123
+			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1124 1124
 			$query_params = array();
1125 1125
 		}
1126 1126
 
1127 1127
 		//let's add the where query param for consecutive look up.
1128
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
1128
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
1129 1129
 		$query_params['limit'] = $limit;
1130 1130
 
1131 1131
 		//set direction
1132
-		$incoming_orderby = isset( $query_params['order_by'] ) ? (array)$query_params['order_by'] : array();
1132
+		$incoming_orderby = isset($query_params['order_by']) ? (array) $query_params['order_by'] : array();
1133 1133
 		$query_params['order_by'] = $operand === '>'
1134
-			? array( $field_to_order_by => 'ASC' ) + $incoming_orderby
1135
-			: array( $field_to_order_by => 'DESC') + $incoming_orderby;
1134
+			? array($field_to_order_by => 'ASC') + $incoming_orderby
1135
+			: array($field_to_order_by => 'DESC') + $incoming_orderby;
1136 1136
 
1137 1137
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
1138
-		if ( empty( $columns_to_select ) ) {
1139
-			return $this->get_all( $query_params );
1138
+		if (empty($columns_to_select)) {
1139
+			return $this->get_all($query_params);
1140 1140
 		} else {
1141 1141
 			//getting just the fields
1142
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
1142
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
1143 1143
 		}
1144 1144
 	}
1145 1145
 
@@ -1150,18 +1150,18 @@  discard block
 block discarded – undo
1150 1150
 	 * This sets the _timezone property after model object has been instantiated.
1151 1151
 	 * @param null | string $timezone valid PHP DateTimeZone timezone string
1152 1152
 	 */
1153
-	public function set_timezone( $timezone ) {
1154
-		if ( $timezone !== null ) {
1153
+	public function set_timezone($timezone) {
1154
+		if ($timezone !== null) {
1155 1155
 			$this->_timezone = $timezone;
1156 1156
 		}
1157 1157
 		//note we need to loop through relations and set the timezone on those objects as well.
1158
-		foreach ( $this->_model_relations as $relation ) {
1159
-			$relation->set_timezone( $timezone );
1158
+		foreach ($this->_model_relations as $relation) {
1159
+			$relation->set_timezone($timezone);
1160 1160
 		}
1161 1161
 		//and finally we do the same for any datetime fields
1162
-		foreach ( $this->_fields as $field ) {
1163
-			if ( $field instanceof EE_Datetime_Field ) {
1164
-				$field->set_timezone( $timezone );
1162
+		foreach ($this->_fields as $field) {
1163
+			if ($field instanceof EE_Datetime_Field) {
1164
+				$field->set_timezone($timezone);
1165 1165
 			}
1166 1166
 		}
1167 1167
 	}
@@ -1176,9 +1176,9 @@  discard block
 block discarded – undo
1176 1176
 	 */
1177 1177
 	public function get_timezone() {
1178 1178
 		//first validate if timezone is set.  If not, then let's set it be whatever is set on the model fields.
1179
-		if ( empty( $this->_timezone ) ) {
1180
-			foreach( $this->_fields as $field ) {
1181
-				if ( $field instanceof EE_Datetime_Field ) {
1179
+		if (empty($this->_timezone)) {
1180
+			foreach ($this->_fields as $field) {
1181
+				if ($field instanceof EE_Datetime_Field) {
1182 1182
 					$this->set_timezone($field->get_timezone());
1183 1183
 					break;
1184 1184
 				}
@@ -1186,8 +1186,8 @@  discard block
 block discarded – undo
1186 1186
 		}
1187 1187
 
1188 1188
 		//if timezone STILL empty then return the default timezone for the site.
1189
-		if ( empty( $this->_timezone ) ) {
1190
-			$this->set_timezone( EEH_DTT_Helper::get_timezone() );
1189
+		if (empty($this->_timezone)) {
1190
+			$this->set_timezone(EEH_DTT_Helper::get_timezone());
1191 1191
 		}
1192 1192
 		return $this->_timezone;
1193 1193
 	}
@@ -1205,19 +1205,19 @@  discard block
 block discarded – undo
1205 1205
 	 *
1206 1206
 	 * @return array formats in an array with the date format first, and the time format last.
1207 1207
 	 */
1208
-	public function get_formats_for( $field_name, $pretty = false ) {
1209
-		$field_settings = $this->field_settings_for( $field_name );
1208
+	public function get_formats_for($field_name, $pretty = false) {
1209
+		$field_settings = $this->field_settings_for($field_name);
1210 1210
 
1211 1211
 		//if not a valid EE_Datetime_Field then throw error
1212
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
1213
-			throw new EE_Error( sprintf( __('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso' ), $field_name ) );
1212
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
1213
+			throw new EE_Error(sprintf(__('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso'), $field_name));
1214 1214
 		}
1215 1215
 
1216 1216
 		//while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on
1217 1217
 		//the field.
1218 1218
 		$this->_timezone = $field_settings->get_timezone();
1219 1219
 
1220
-		return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) );
1220
+		return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty));
1221 1221
 	}
1222 1222
 
1223 1223
 
@@ -1241,25 +1241,25 @@  discard block
 block discarded – undo
1241 1241
 	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1242 1242
 	 *                    	     exception is triggered.
1243 1243
 	 */
1244
-	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
1245
-		$formats = $this->get_formats_for( $field_name );
1244
+	public function current_time_for_query($field_name, $timestamp = false, $what = 'both') {
1245
+		$formats = $this->get_formats_for($field_name);
1246 1246
 
1247
-		$DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) );
1247
+		$DateTime = new DateTime("now", new DateTimeZone($this->_timezone));
1248 1248
 
1249
-		if ( $timestamp ) {
1250
-			return $DateTime->format( 'U' );
1249
+		if ($timestamp) {
1250
+			return $DateTime->format('U');
1251 1251
 		}
1252 1252
 
1253 1253
 		//not returning timestamp, so return formatted string in timezone.
1254
-		switch( $what ) {
1254
+		switch ($what) {
1255 1255
 			case 'time' :
1256
-				return $DateTime->format( $formats[1] );
1256
+				return $DateTime->format($formats[1]);
1257 1257
 				break;
1258 1258
 			case 'date' :
1259
-				return $DateTime->format( $formats[0] );
1259
+				return $DateTime->format($formats[0]);
1260 1260
 				break;
1261 1261
 			default :
1262
-				return $DateTime->format( implode( ' ', $formats ) );
1262
+				return $DateTime->format(implode(' ', $formats));
1263 1263
 				break;
1264 1264
 		}
1265 1265
 	}
@@ -1281,17 +1281,17 @@  discard block
 block discarded – undo
1281 1281
 	 * @return DateTime
1282 1282
 	 * @throws \EE_Error
1283 1283
 	 */
1284
-	public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) {
1284
+	public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') {
1285 1285
 
1286 1286
 		//just using this to ensure the timezone is set correctly internally
1287
-		$this->get_formats_for( $field_name );
1287
+		$this->get_formats_for($field_name);
1288 1288
 
1289 1289
 		//load EEH_DTT_Helper
1290
-		$set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
1290
+		$set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
1291 1291
 
1292
-		$incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) );
1292
+		$incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone));
1293 1293
 
1294
-		return $incomingDateTime->setTimezone( new DateTimeZone( $this->_timezone ) );
1294
+		return $incomingDateTime->setTimezone(new DateTimeZone($this->_timezone));
1295 1295
 	}
1296 1296
 
1297 1297
 
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
1302 1302
 	 * @return EE_Table_Base[]
1303 1303
 	 */
1304
-	public function get_tables(){
1304
+	public function get_tables() {
1305 1305
 		return $this->_tables;
1306 1306
 	}
1307 1307
 
@@ -1337,9 +1337,9 @@  discard block
 block discarded – undo
1337 1337
 	 * @return int how many rows got updated or FALSE if something went wrong with the query (wp returns FALSE or num rows affected which *could* include 0 which DOES NOT mean the query was bad)
1338 1338
 	 * @throws \EE_Error
1339 1339
 	 */
1340
-	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
1341
-		if( ! is_array( $query_params ) ){
1342
-			EE_Error::doing_it_wrong('EEM_Base::update', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1340
+	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
1341
+		if ( ! is_array($query_params)) {
1342
+			EE_Error::doing_it_wrong('EEM_Base::update', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1343 1343
 			$query_params = array();
1344 1344
 		}
1345 1345
 		/**
@@ -1349,7 +1349,7 @@  discard block
 block discarded – undo
1349 1349
 		 * @param array $fields_n_values the updated fields and their new values
1350 1350
 		 * @param array $query_params @see EEM_Base::get_all()
1351 1351
 		 */
1352
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
1352
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
1353 1353
 		/**
1354 1354
 		 * Filters the fields about to be updated given the query parameters. You can provide the
1355 1355
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -1357,10 +1357,10 @@  discard block
 block discarded – undo
1357 1357
 		 * @param EEM_Base $model the model being queried
1358 1358
 		 * @param array $query_params see EEM_Base::get_all()
1359 1359
 		 */
1360
-		$fields_n_values = (array)apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
1360
+		$fields_n_values = (array) apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
1361 1361
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
1362 1362
 		//to do that, for each table, verify that it's PK isn't null.
1363
-		$tables= $this->get_tables();
1363
+		$tables = $this->get_tables();
1364 1364
 
1365 1365
 		//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1366 1366
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1370,29 +1370,29 @@  discard block
 block discarded – undo
1370 1370
 			//we want to make sure the default_where strategy is ignored
1371 1371
 			$this->_ignore_where_strategy = TRUE;
1372 1372
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1373
-			foreach( $wpdb_select_results as $wpdb_result ){
1373
+			foreach ($wpdb_select_results as $wpdb_result) {
1374 1374
 				// type cast stdClass as array
1375
-				$wpdb_result = (array)$wpdb_result;
1375
+				$wpdb_result = (array) $wpdb_result;
1376 1376
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1377
-				if( $this->has_primary_key_field() ){
1378
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1379
-				}else{
1377
+				if ($this->has_primary_key_field()) {
1378
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1379
+				} else {
1380 1380
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work)
1381 1381
 					$main_table_pk_value = null;
1382 1382
 				}
1383 1383
 				//if there are more than 1 tables, we'll want to verify that each table for this model has an entry in the other tables
1384 1384
 				//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1385
-				if(count($tables) > 1){
1385
+				if (count($tables) > 1) {
1386 1386
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1387 1387
 					//in that table, and so we'll want to insert one
1388
-					foreach($tables as $table_obj){
1388
+					foreach ($tables as $table_obj) {
1389 1389
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1390 1390
 						//if there is no private key for this table on the results, it means there's no entry
1391 1391
 						//in this table, right? so insert a row in the current table, using any fields available
1392
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1392
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1393 1393
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1394 1394
 							//if we died here, report the error
1395
-							if( ! $success ) {
1395
+							if ( ! $success) {
1396 1396
 								return false;
1397 1397
 							}
1398 1398
 						}
@@ -1412,44 +1412,44 @@  discard block
 block discarded – undo
1412 1412
 		//if this wasn't called from a model object (to update itself)
1413 1413
 		//then we want to make sure we keep all the existing
1414 1414
 		//model objects in sync with the db
1415
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1416
-			if( $this->has_primary_key_field() ){
1417
-				$model_objs_affected_ids = $this->get_col( $query_params );
1418
-			}else{
1415
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1416
+			if ($this->has_primary_key_field()) {
1417
+				$model_objs_affected_ids = $this->get_col($query_params);
1418
+			} else {
1419 1419
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1420
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1420
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1421 1421
 				$model_objs_affected_ids = array();
1422
-				foreach( $models_affected_key_columns as $row ){
1423
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1424
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1422
+				foreach ($models_affected_key_columns as $row) {
1423
+					$combined_index_key = $this->get_index_primary_key_string($row);
1424
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1425 1425
 				}
1426 1426
 
1427 1427
 			}
1428 1428
 
1429
-			if( ! $model_objs_affected_ids ){
1429
+			if ( ! $model_objs_affected_ids) {
1430 1430
 				//wait wait wait- if nothing was affected let's stop here
1431 1431
 				return 0;
1432 1432
 			}
1433
-			foreach( $model_objs_affected_ids as $id ){
1434
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1435
-				if( $model_obj_in_entity_map ){
1436
-					foreach( $fields_n_values as $field => $new_value ){
1437
-						$model_obj_in_entity_map->set( $field, $new_value );
1433
+			foreach ($model_objs_affected_ids as $id) {
1434
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1435
+				if ($model_obj_in_entity_map) {
1436
+					foreach ($fields_n_values as $field => $new_value) {
1437
+						$model_obj_in_entity_map->set($field, $new_value);
1438 1438
 					}
1439 1439
 				}
1440 1440
 			}
1441 1441
 			//if there is a primary key on this model, we can now do a slight optimization
1442
-			if( $this->has_primary_key_field() ){
1442
+			if ($this->has_primary_key_field()) {
1443 1443
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1444 1444
 				$query_params = array(
1445
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1446
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1445
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1446
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1447 1447
 			}
1448 1448
 		}
1449 1449
 
1450
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1451
-		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql();//note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1452
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1450
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1451
+		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql(); //note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1452
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1453 1453
 		/**
1454 1454
 		 * Action called after a model update call has been made.
1455 1455
 		 *
@@ -1458,8 +1458,8 @@  discard block
 block discarded – undo
1458 1458
 		 * @param array $query_params @see EEM_Base::get_all()
1459 1459
 		 * @param int $rows_affected
1460 1460
 		 */
1461
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1462
-		return $rows_affected;//how many supposedly got updated
1461
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1462
+		return $rows_affected; //how many supposedly got updated
1463 1463
 	}
1464 1464
 
1465 1465
 
@@ -1475,22 +1475,22 @@  discard block
 block discarded – undo
1475 1475
 	 * @return array just like $wpdb->get_col()
1476 1476
 	 * @throws \EE_Error
1477 1477
 	 */
1478
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1478
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1479 1479
 
1480
-		if( $field_to_select ){
1481
-			$field = $this->field_settings_for( $field_to_select );
1482
-		}elseif( $this->has_primary_key_field ( ) ){
1480
+		if ($field_to_select) {
1481
+			$field = $this->field_settings_for($field_to_select);
1482
+		}elseif ($this->has_primary_key_field( )) {
1483 1483
 			$field = $this->get_primary_key_field();
1484
-		}else{
1484
+		} else {
1485 1485
 			//no primary key, just grab the first column
1486
-			$field = reset( $this->field_settings());
1486
+			$field = reset($this->field_settings());
1487 1487
 		}
1488 1488
 
1489 1489
 
1490 1490
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1491 1491
 		$select_expressions = $field->get_qualified_column();
1492
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1493
-		return $this->_do_wpdb_query('get_col', array( $SQL ) );
1492
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1493
+		return $this->_do_wpdb_query('get_col', array($SQL));
1494 1494
 	}
1495 1495
 
1496 1496
 
@@ -1503,12 +1503,12 @@  discard block
 block discarded – undo
1503 1503
 	 * @return string
1504 1504
 	 * @throws \EE_Error
1505 1505
 	 */
1506
-	public function get_var( $query_params = array(), $field_to_select = NULL ) {
1507
-		$query_params[ 'limit' ] = 1;
1508
-		$col = $this->get_col( $query_params, $field_to_select );
1509
-		if( ! empty( $col ) ) {
1510
-			return reset( $col );
1511
-		}else{
1506
+	public function get_var($query_params = array(), $field_to_select = NULL) {
1507
+		$query_params['limit'] = 1;
1508
+		$col = $this->get_col($query_params, $field_to_select);
1509
+		if ( ! empty($col)) {
1510
+			return reset($col);
1511
+		} else {
1512 1512
 			return NULL;
1513 1513
 		}
1514 1514
 	}
@@ -1524,19 +1524,19 @@  discard block
 block discarded – undo
1524 1524
 	 * @return string of SQL
1525 1525
 	 * @throws \EE_Error
1526 1526
 	 */
1527
-	public function _construct_update_sql($fields_n_values){
1527
+	public function _construct_update_sql($fields_n_values) {
1528 1528
 		/** @type WPDB $wpdb */
1529 1529
 		global $wpdb;
1530 1530
 		$cols_n_values = array();
1531
-		foreach($fields_n_values as $field_name => $value){
1531
+		foreach ($fields_n_values as $field_name => $value) {
1532 1532
 			$field_obj = $this->field_settings_for($field_name);
1533 1533
 			//if the value is NULL, we want to assign the value to that.
1534 1534
 			//wpdb->prepare doesn't really handle that properly
1535
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1536
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1535
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1536
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1537 1537
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1538 1538
 		}
1539
-		return implode(",",$cols_n_values);
1539
+		return implode(",", $cols_n_values);
1540 1540
 
1541 1541
 	}
1542 1542
 
@@ -1552,10 +1552,10 @@  discard block
 block discarded – undo
1552 1552
 	 * @return boolean whether the row got deleted or not
1553 1553
 	 * @throws \EE_Error
1554 1554
 	 */
1555
-	public function delete_permanently_by_ID( $id ) {
1555
+	public function delete_permanently_by_ID($id) {
1556 1556
 		return $this->delete_permanently(
1557 1557
 			array(
1558
-				array( $this->get_primary_key_field()->get_name() => $id ),
1558
+				array($this->get_primary_key_field()->get_name() => $id),
1559 1559
 				'limit' 	=> 1
1560 1560
 			)
1561 1561
 		);
@@ -1571,10 +1571,10 @@  discard block
 block discarded – undo
1571 1571
 	 * @return boolean whether the row got deleted or not
1572 1572
 	 * @throws \EE_Error
1573 1573
 	 */
1574
-	public function delete_by_ID( $id ){
1574
+	public function delete_by_ID($id) {
1575 1575
 		return $this->delete(
1576 1576
 			array(
1577
-				array( $this->get_primary_key_field()->get_name() => $id ),
1577
+				array($this->get_primary_key_field()->get_name() => $id),
1578 1578
 				'limit' 	=> 1
1579 1579
 			)
1580 1580
 		);
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
 	 * @return int how many rows got deleted
1594 1594
 	 * @throws \EE_Error
1595 1595
 	 */
1596
-	public function delete($query_params,$allow_blocking = true){
1596
+	public function delete($query_params, $allow_blocking = true) {
1597 1597
 		return $this->delete_permanently($query_params, $allow_blocking);
1598 1598
 	}
1599 1599
 
@@ -1611,7 +1611,7 @@  discard block
 block discarded – undo
1611 1611
 	 * @return int how many rows got deleted
1612 1612
 	 * @throws \EE_Error
1613 1613
 	 */
1614
-	public function delete_permanently($query_params,$allow_blocking = true){
1614
+	public function delete_permanently($query_params, $allow_blocking = true) {
1615 1615
 		/**
1616 1616
 		 * Action called just before performing a real deletion query. You can use the
1617 1617
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1620,31 +1620,31 @@  discard block
 block discarded – undo
1620 1620
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1621 1621
 		 * to block (prevent) this deletion
1622 1622
 		 */
1623
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1623
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1624 1624
 		//some MySQL databases may be running safe mode, which may restrict
1625 1625
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1626 1626
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1627 1627
 		//to delete them
1628 1628
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1629
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1630
-		if($deletion_where){
1629
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1630
+		if ($deletion_where) {
1631 1631
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1632 1632
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1633
-			$table_aliases = array_keys( $this->_tables );
1634
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1633
+			$table_aliases = array_keys($this->_tables);
1634
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1635 1635
 
1636 1636
 			//		/echo "delete sql:$SQL";
1637
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1638
-		}else{
1637
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1638
+		} else {
1639 1639
 			$rows_deleted = 0;
1640 1640
 		}
1641 1641
 
1642 1642
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1643
-		if( $this->has_primary_key_field() ){
1644
-			foreach($items_for_deletion as $item_for_deletion_row ){
1645
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1646
-				if( isset( $this->_entity_map[ $pk_value ] ) ){
1647
-					unset( $this->_entity_map[ $pk_value ] );
1643
+		if ($this->has_primary_key_field()) {
1644
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1645
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1646
+				if (isset($this->_entity_map[$pk_value])) {
1647
+					unset($this->_entity_map[$pk_value]);
1648 1648
 				}
1649 1649
 			}
1650 1650
 		}
@@ -1656,8 +1656,8 @@  discard block
 block discarded – undo
1656 1656
 		 * @param array $query_params @see EEM_Base::get_all()
1657 1657
 		 * @param int $rows_deleted
1658 1658
 		 */
1659
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1660
-		return $rows_deleted;//how many supposedly got deleted
1659
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1660
+		return $rows_deleted; //how many supposedly got deleted
1661 1661
 	}
1662 1662
 
1663 1663
 
@@ -1675,28 +1675,28 @@  discard block
 block discarded – undo
1675 1675
 	 * @return boolean
1676 1676
 	 * @throws \EE_Error
1677 1677
 	 */
1678
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1678
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1679 1679
 		//first, if $ignore_this_model_obj was supplied, get its model
1680
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1680
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1681 1681
 			$ignored_model = $ignore_this_model_obj->get_model();
1682
-		}else{
1682
+		} else {
1683 1683
 			$ignored_model = null;
1684 1684
 		}
1685 1685
 		//now check all the relations of $this_model_obj_or_id and see if there
1686 1686
 		//are any related model objects blocking it?
1687 1687
 		$is_blocked = false;
1688
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1689
-			if( $relation_obj->block_delete_if_related_models_exist()){
1688
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1689
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1690 1690
 				//if $ignore_this_model_obj was supplied, then for the query
1691 1691
 				//on that model needs to be told to ignore $ignore_this_model_obj
1692
-				if($ignored_model && $relation_name === $ignored_model->get_this_model_name()){
1693
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1694
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1695
-				}else{
1692
+				if ($ignored_model && $relation_name === $ignored_model->get_this_model_name()) {
1693
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1694
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1695
+				} else {
1696 1696
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1697 1697
 				}
1698 1698
 
1699
-				if($related_model_objects){
1699
+				if ($related_model_objects) {
1700 1700
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1701 1701
 					$is_blocked = true;
1702 1702
 				}
@@ -1716,71 +1716,71 @@  discard block
 block discarded – undo
1716 1716
 	 * @throws EE_Error
1717 1717
 	 * @return string    everything that comes after the WHERE statement.
1718 1718
 	 */
1719
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1720
-		if($this->has_primary_key_field()){
1719
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1720
+		if ($this->has_primary_key_field()) {
1721 1721
 			$primary_table = $this->_get_main_table();
1722 1722
 			$other_tables = $this->_get_other_tables();
1723 1723
 			$deletes = $query = array();
1724
-			foreach ( $objects_for_deletion as $delete_object ) {
1724
+			foreach ($objects_for_deletion as $delete_object) {
1725 1725
 				//before we mark this object for deletion,
1726 1726
 				//make sure there's no related objects blocking its deletion (if we're checking)
1727 1727
 				if (
1728 1728
 					$allow_blocking
1729 1729
 				    && $this->delete_is_blocked_by_related_models(
1730
-						$delete_object[ $primary_table->get_fully_qualified_pk_column() ]
1730
+						$delete_object[$primary_table->get_fully_qualified_pk_column()]
1731 1731
 					)
1732 1732
 				) {
1733 1733
 					continue;
1734 1734
 				}
1735 1735
 				//primary table deletes
1736
-				if ( isset( $delete_object[ $primary_table->get_fully_qualified_pk_column() ] ) ) {
1737
-					$deletes[ $primary_table->get_fully_qualified_pk_column() ][] = $delete_object[ $primary_table->get_fully_qualified_pk_column() ];
1736
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1737
+					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1738 1738
 				}
1739 1739
 				//other tables
1740
-				if ( ! empty( $other_tables ) ) {
1741
-					foreach ( $other_tables as $ot ) {
1740
+				if ( ! empty($other_tables)) {
1741
+					foreach ($other_tables as $ot) {
1742 1742
 						//first check if we've got the foreign key column here.
1743
-						if ( isset( $delete_object[ $ot->get_fully_qualified_fk_column() ] ) ) {
1744
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_fk_column() ];
1743
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()])) {
1744
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1745 1745
 						}
1746 1746
 						// wait! it's entirely possible that we'll have a the primary key
1747 1747
 						// for this table in here, if it's a foreign key for one of the other secondary tables
1748
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_column() ] ) ) {
1749
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1748
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()])) {
1749
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1750 1750
 						}
1751 1751
 						// finally, it is possible that the fk for this table is found
1752 1752
 						// in the fully qualified pk column for the fk table, so let's see if that's there!
1753
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_on_fk_table() ] ) ) {
1754
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1753
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()])) {
1754
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1755 1755
 						}
1756 1756
 					}
1757 1757
 				}
1758 1758
 			}
1759 1759
 
1760 1760
 			//we should have deletes now, so let's just go through and setup the where statement
1761
-			foreach ( $deletes as $column => $values ) {
1761
+			foreach ($deletes as $column => $values) {
1762 1762
 				//make sure we have unique $values;
1763 1763
 				$values = array_unique($values);
1764
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1764
+				$query[] = $column.' IN('.implode(",", $values).')';
1765 1765
 			}
1766 1766
 
1767
-			return !empty($query) ? implode(' AND ', $query ) : '';
1768
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1767
+			return ! empty($query) ? implode(' AND ', $query) : '';
1768
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1769 1769
 			$ways_to_identify_a_row = array();
1770 1770
 			$fields = $this->get_combined_primary_key_fields();
1771 1771
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1772
-			foreach($objects_for_deletion as  $delete_object){
1772
+			foreach ($objects_for_deletion as  $delete_object) {
1773 1773
 				$values_for_each_cpk_for_a_row = array();
1774
-				foreach($fields as $cpk_field){
1774
+				foreach ($fields as $cpk_field) {
1775 1775
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1776 1776
 				}
1777
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1777
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1778 1778
 			}
1779
-			return implode(" OR ",$ways_to_identify_a_row);
1780
-		}else{
1779
+			return implode(" OR ", $ways_to_identify_a_row);
1780
+		} else {
1781 1781
 			//so there's no primary key and no combined key...
1782 1782
 			//sorry, can't help you
1783
-			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
1783
+			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"), get_class($this)));
1784 1784
 		}
1785 1785
 	}
1786 1786
 
@@ -1796,21 +1796,21 @@  discard block
 block discarded – undo
1796 1796
 	 * @return int
1797 1797
 	 * @throws \EE_Error
1798 1798
 	 */
1799
-	public function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1799
+	public function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1800 1800
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1801
-		if($field_to_count){
1801
+		if ($field_to_count) {
1802 1802
 			$field_obj = $this->field_settings_for($field_to_count);
1803 1803
 			$column_to_count = $field_obj->get_qualified_column();
1804
-		}elseif($this->has_primary_key_field ()){
1804
+		}elseif ($this->has_primary_key_field()) {
1805 1805
 			$pk_field_obj = $this->get_primary_key_field();
1806 1806
 			$column_to_count = $pk_field_obj->get_qualified_column();
1807
-		}else{//there's no primary key
1807
+		} else {//there's no primary key
1808 1808
 			$column_to_count = '*';
1809 1809
 		}
1810 1810
 
1811
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1812
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1813
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1811
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1812
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1813
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1814 1814
 	}
1815 1815
 
1816 1816
 
@@ -1823,24 +1823,24 @@  discard block
 block discarded – undo
1823 1823
 	 * @return float
1824 1824
 	 * @throws \EE_Error
1825 1825
 	 */
1826
-	public function sum($query_params, $field_to_sum = NULL){
1826
+	public function sum($query_params, $field_to_sum = NULL) {
1827 1827
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1828 1828
 
1829
-		if($field_to_sum){
1829
+		if ($field_to_sum) {
1830 1830
 			$field_obj = $this->field_settings_for($field_to_sum);
1831 1831
 
1832
-		}else{
1832
+		} else {
1833 1833
 			$field_obj = $this->get_primary_key_field();
1834 1834
 		}
1835 1835
 		$column_to_count = $field_obj->get_qualified_column();
1836 1836
 
1837
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1838
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1837
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1838
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1839 1839
 		$data_type = $field_obj->get_wpdb_data_type();
1840
-		if( $data_type === '%d' || $data_type === '%s' ){
1841
-			return (float)$return_value;
1842
-		}else{//must be %f
1843
-			return (float)$return_value;
1840
+		if ($data_type === '%d' || $data_type === '%s') {
1841
+			return (float) $return_value;
1842
+		} else {//must be %f
1843
+			return (float) $return_value;
1844 1844
 		}
1845 1845
 	}
1846 1846
 
@@ -1855,33 +1855,33 @@  discard block
 block discarded – undo
1855 1855
 	 * @global wpdb $wpdb
1856 1856
 	 * @return mixed
1857 1857
 	 */
1858
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1858
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1859 1859
 		//if we're in maintenance mode level 2, DON'T run any queries
1860 1860
 		//because level 2 indicates the database needs updating and
1861 1861
 		//is probably out of sync with the code
1862
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1862
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1863 1863
 			throw new EE_Error(sprintf(__("Event Espresso Level 2 Maintenance mode is active. That means EE can not run ANY database queries until the necessary migration scripts have run which will take EE out of maintenance mode level 2. Please inform support of this error.", "event_espresso")));
1864 1864
 		}
1865 1865
 		/** @type WPDB $wpdb */
1866 1866
 		global $wpdb;
1867
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1868
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1867
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1868
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1869 1869
 		}
1870
-		if( WP_DEBUG ){
1870
+		if (WP_DEBUG) {
1871 1871
 			$old_show_errors_value = $wpdb->show_errors;
1872
-			$wpdb->show_errors( FALSE );
1873
-		}
1874
-		$result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1875
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1876
-		if( WP_DEBUG ){
1877
-			$wpdb->show_errors( $old_show_errors_value );
1878
-			if( ! empty( $wpdb->last_error ) ){
1879
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1880
-			}elseif( $result === false ){
1881
-				throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) );
1872
+			$wpdb->show_errors(FALSE);
1873
+		}
1874
+		$result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1875
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1876
+		if (WP_DEBUG) {
1877
+			$wpdb->show_errors($old_show_errors_value);
1878
+			if ( ! empty($wpdb->last_error)) {
1879
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1880
+			}elseif ($result === false) {
1881
+				throw new EE_Error(sprintf(__('WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso'), $wpdb_method, var_export($arguments_to_provide, true)));
1882 1882
 			}
1883
-		}elseif( $result === false ) {
1884
-			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1883
+		}elseif ($result === false) {
1884
+			EE_Error::add_error(sprintf(__('A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__);
1885 1885
 		}
1886 1886
 		return $result;
1887 1887
 	}
@@ -1897,26 +1897,26 @@  discard block
 block discarded – undo
1897 1897
 	 * @param array $arguments_to_provide
1898 1898
 	 * @return mixed
1899 1899
 	 */
1900
-	private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) {
1900
+	private function _process_wpdb_query($wpdb_method, $arguments_to_provide) {
1901 1901
 		/** @type WPDB $wpdb */
1902 1902
 		global $wpdb;
1903 1903
 		$wpdb->last_error = null;
1904
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide );
1904
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1905 1905
 		// was there an error running the query? but we don't care on new activations
1906 1906
 		// (we're going to setup the DB anyway on new activations)
1907
-		if ( ( $result === false || ! empty( $wpdb->last_error ) )
1907
+		if (($result === false || ! empty($wpdb->last_error))
1908 1908
 			&& EE_System::instance()->detect_req_type() !== EE_System::req_type_new_activation
1909 1909
 		) {
1910
-			switch ( EEM_Base::$_db_verification_level ) {
1910
+			switch (EEM_Base::$_db_verification_level) {
1911 1911
 
1912 1912
 				case EEM_Base::db_verified_none :
1913 1913
 					// let's double-check core's DB
1914
-					$error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide );
1914
+					$error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide);
1915 1915
 					break;
1916 1916
 
1917 1917
 				case EEM_Base::db_verified_core :
1918 1918
 					// STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed
1919
-					$error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide );
1919
+					$error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide);
1920 1920
 					break;
1921 1921
 
1922 1922
 				case EEM_Base::db_verified_addons :
@@ -1924,11 +1924,11 @@  discard block
 block discarded – undo
1924 1924
 					return $result;
1925 1925
 					break;
1926 1926
 			}
1927
-			if ( ! empty( $error_message ) ) {
1928
-				EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' );
1929
-				trigger_error( $error_message );
1927
+			if ( ! empty($error_message)) {
1928
+				EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error');
1929
+				trigger_error($error_message);
1930 1930
 			}
1931
-			return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1931
+			return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1932 1932
 
1933 1933
 		}
1934 1934
 
@@ -1944,18 +1944,18 @@  discard block
 block discarded – undo
1944 1944
 	 * @param array $arguments_to_provide
1945 1945
 	 * @return string
1946 1946
 	 */
1947
-	private function _verify_core_db( $wpdb_method, $arguments_to_provide ){
1947
+	private function _verify_core_db($wpdb_method, $arguments_to_provide) {
1948 1948
 		/** @type WPDB $wpdb */
1949 1949
 		global $wpdb;
1950 1950
 		//ok remember that we've already attempted fixing the core db, in case the problem persists
1951 1951
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_core;
1952 1952
 		$error_message = sprintf(
1953
-			__( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ),
1953
+			__('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'),
1954 1954
 			$wpdb->last_error,
1955 1955
 			$wpdb_method,
1956
-			json_encode( $arguments_to_provide )
1956
+			json_encode($arguments_to_provide)
1957 1957
 		);
1958
-		EE_System::instance()->initialize_db_if_no_migrations_required( false, true );
1958
+		EE_System::instance()->initialize_db_if_no_migrations_required(false, true);
1959 1959
 		return $error_message;
1960 1960
 	}
1961 1961
 
@@ -1968,16 +1968,16 @@  discard block
 block discarded – undo
1968 1968
 	 * @param $arguments_to_provide
1969 1969
 	 * @return string
1970 1970
 	 */
1971
-	private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) {
1971
+	private function _verify_addons_db($wpdb_method, $arguments_to_provide) {
1972 1972
 		/** @type WPDB $wpdb */
1973 1973
 		global $wpdb;
1974 1974
 		//ok remember that we've already attempted fixing the addons dbs, in case the problem persists
1975 1975
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons;
1976 1976
 		$error_message = sprintf(
1977
-			__( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ),
1977
+			__('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'),
1978 1978
 			$wpdb->last_error,
1979 1979
 			$wpdb_method,
1980
-			json_encode( $arguments_to_provide )
1980
+			json_encode($arguments_to_provide)
1981 1981
 		);
1982 1982
 		EE_System::instance()->initialize_addons();
1983 1983
 		return $error_message;
@@ -1992,7 +1992,7 @@  discard block
 block discarded – undo
1992 1992
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
1993 1993
 	 * @return string
1994 1994
 	 */
1995
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
1995
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
1996 1996
 		return " FROM ".$model_query_info->get_full_join_sql().
1997 1997
 				$model_query_info->get_where_sql().
1998 1998
 				$model_query_info->get_group_by_sql().
@@ -2005,7 +2005,7 @@  discard block
 block discarded – undo
2005 2005
 	 * Set to easily debug the next X queries ran from this model.
2006 2006
 	 * @param int $count
2007 2007
 	 */
2008
-	public function show_next_x_db_queries($count = 1){
2008
+	public function show_next_x_db_queries($count = 1) {
2009 2009
 		$this->_show_next_x_db_queries = $count;
2010 2010
 	}
2011 2011
 
@@ -2014,8 +2014,8 @@  discard block
 block discarded – undo
2014 2014
 	/**
2015 2015
 	 * @param $sql_query
2016 2016
 	 */
2017
-	public function show_db_query_if_previously_requested($sql_query){
2018
-		if($this->_show_next_x_db_queries > 0){
2017
+	public function show_db_query_if_previously_requested($sql_query) {
2018
+		if ($this->_show_next_x_db_queries > 0) {
2019 2019
 			echo $sql_query;
2020 2020
 			$this->_show_next_x_db_queries--;
2021 2021
 		}
@@ -2039,9 +2039,9 @@  discard block
 block discarded – undo
2039 2039
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
2040 2040
 	 * @throws \EE_Error
2041 2041
 	 */
2042
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){
2042
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) {
2043 2043
 		$relation_obj = $this->related_settings_for($relationName);
2044
-		return $relation_obj->add_relation_to( $id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2044
+		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2045 2045
 	}
2046 2046
 
2047 2047
 
@@ -2060,9 +2060,9 @@  discard block
 block discarded – undo
2060 2060
 	 * @throws \EE_Error
2061 2061
 	 * @param array  $where_query  This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
2062 2062
 	 */
2063
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
2063
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
2064 2064
 		$relation_obj = $this->related_settings_for($relationName);
2065
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
2065
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
2066 2066
 	}
2067 2067
 
2068 2068
 
@@ -2075,9 +2075,9 @@  discard block
 block discarded – undo
2075 2075
 	 * @return \EE_Base_Class[]
2076 2076
 	 * @throws \EE_Error
2077 2077
 	 */
2078
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
2078
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
2079 2079
 		$relation_obj = $this->related_settings_for($relationName);
2080
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
2080
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
2081 2081
 	}
2082 2082
 
2083 2083
 
@@ -2093,10 +2093,10 @@  discard block
 block discarded – undo
2093 2093
 	 * @return EE_Base_Class[]
2094 2094
 	 * @throws \EE_Error
2095 2095
 	 */
2096
-	public function get_all_related($id_or_obj, $model_name, $query_params = null){
2096
+	public function get_all_related($id_or_obj, $model_name, $query_params = null) {
2097 2097
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2098 2098
 		$relation_settings = $this->related_settings_for($model_name);
2099
-		return $relation_settings->get_all_related($model_obj,$query_params);
2099
+		return $relation_settings->get_all_related($model_obj, $query_params);
2100 2100
 	}
2101 2101
 
2102 2102
 
@@ -2113,10 +2113,10 @@  discard block
 block discarded – undo
2113 2113
 	 * @return int how many deleted
2114 2114
 	 * @throws \EE_Error
2115 2115
 	 */
2116
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
2116
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
2117 2117
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2118 2118
 		$relation_settings = $this->related_settings_for($model_name);
2119
-		return $relation_settings->delete_all_related($model_obj,$query_params);
2119
+		return $relation_settings->delete_all_related($model_obj, $query_params);
2120 2120
 	}
2121 2121
 
2122 2122
 
@@ -2133,10 +2133,10 @@  discard block
 block discarded – undo
2133 2133
 	 * @return int how many deleted
2134 2134
 	 * @throws \EE_Error
2135 2135
 	 */
2136
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
2136
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
2137 2137
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2138 2138
 		$relation_settings = $this->related_settings_for($model_name);
2139
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
2139
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
2140 2140
 	}
2141 2141
 
2142 2142
 
@@ -2153,17 +2153,17 @@  discard block
 block discarded – undo
2153 2153
 	 * @return int
2154 2154
 	 * @throws \EE_Error
2155 2155
 	 */
2156
-	public function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
2156
+	public function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
2157 2157
 		$related_model = $this->get_related_model_obj($model_name);
2158 2158
 		//we're just going to use the query params on the related model's normal get_all query,
2159 2159
 		//except add a condition to say to match the current mod
2160
-		if( ! isset($query_params['default_where_conditions'])){
2161
-			$query_params['default_where_conditions']='none';
2160
+		if ( ! isset($query_params['default_where_conditions'])) {
2161
+			$query_params['default_where_conditions'] = 'none';
2162 2162
 		}
2163 2163
 		$this_model_name = $this->get_this_model_name();
2164 2164
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2165
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2166
-		return $related_model->count($query_params,$field_to_count,$distinct);
2165
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2166
+		return $related_model->count($query_params, $field_to_count, $distinct);
2167 2167
 	}
2168 2168
 
2169 2169
 
@@ -2179,21 +2179,21 @@  discard block
 block discarded – undo
2179 2179
 	 * @return float
2180 2180
 	 * @throws \EE_Error
2181 2181
 	 */
2182
-	public function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
2182
+	public function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
2183 2183
 		$related_model = $this->get_related_model_obj($model_name);
2184
-		if( ! is_array( $query_params ) ){
2185
-			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
2184
+		if ( ! is_array($query_params)) {
2185
+			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
2186 2186
 			$query_params = array();
2187 2187
 		}
2188 2188
 		//we're just going to use the query params on the related model's normal get_all query,
2189 2189
 		//except add a condition to say to match the current mod
2190
-		if( ! isset($query_params['default_where_conditions'])){
2191
-			$query_params['default_where_conditions']='none';
2190
+		if ( ! isset($query_params['default_where_conditions'])) {
2191
+			$query_params['default_where_conditions'] = 'none';
2192 2192
 		}
2193 2193
 		$this_model_name = $this->get_this_model_name();
2194 2194
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2195
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2196
-		return $related_model->sum($query_params,$field_to_sum);
2195
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2196
+		return $related_model->sum($query_params, $field_to_sum);
2197 2197
 	}
2198 2198
 
2199 2199
 
@@ -2207,12 +2207,12 @@  discard block
 block discarded – undo
2207 2207
 	 * @return EE_Base_Class
2208 2208
 	 * @throws \EE_Error
2209 2209
 	 */
2210
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
2211
-		$query_params['limit']=1;
2212
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2213
-		if( $results ){
2210
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
2211
+		$query_params['limit'] = 1;
2212
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
2213
+		if ($results) {
2214 2214
 			return array_shift($results);
2215
-		}else{
2215
+		} else {
2216 2216
 			return null;
2217 2217
 		}
2218 2218
 
@@ -2222,8 +2222,8 @@  discard block
 block discarded – undo
2222 2222
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
2223 2223
 	 * @return string
2224 2224
 	 */
2225
-	public function get_this_model_name(){
2226
-		return str_replace("EEM_","",get_class($this));
2225
+	public function get_this_model_name() {
2226
+		return str_replace("EEM_", "", get_class($this));
2227 2227
 	}
2228 2228
 
2229 2229
 	/**
@@ -2231,14 +2231,14 @@  discard block
 block discarded – undo
2231 2231
 	 * @return EE_Any_Foreign_Model_Name_Field
2232 2232
 	 * @throws EE_Error
2233 2233
 	 */
2234
-	public function get_field_containing_related_model_name(){
2235
-		foreach($this->field_settings(true) as $field){
2236
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
2234
+	public function get_field_containing_related_model_name() {
2235
+		foreach ($this->field_settings(true) as $field) {
2236
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
2237 2237
 				$field_with_model_name = $field;
2238 2238
 			}
2239 2239
 		}
2240
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
2241
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
2240
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
2241
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
2242 2242
 		}
2243 2243
 		return $field_with_model_name;
2244 2244
 	}
@@ -2259,19 +2259,19 @@  discard block
 block discarded – undo
2259 2259
 	 * @return int new primary key on main table that got inserted
2260 2260
 	 * @throws EE_Error
2261 2261
 	 */
2262
-	public function insert($field_n_values){
2262
+	public function insert($field_n_values) {
2263 2263
 		/**
2264 2264
 		 * Filters the fields and their values before inserting an item using the models
2265 2265
 		 * @param array $fields_n_values keys are the fields and values are their new values
2266 2266
 		 * @param EEM_Base $model the model used
2267 2267
 		 */
2268
-		$field_n_values = (array)apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
2269
-		if($this->_satisfies_unique_indexes($field_n_values)){
2268
+		$field_n_values = (array) apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
2269
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
2270 2270
 			$main_table = $this->_get_main_table();
2271 2271
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
2272
-			if( $new_id !== false ) {
2273
-				foreach($this->_get_other_tables() as $other_table){
2274
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
2272
+			if ($new_id !== false) {
2273
+				foreach ($this->_get_other_tables() as $other_table) {
2274
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
2275 2275
 				}
2276 2276
 			}
2277 2277
 			/**
@@ -2281,9 +2281,9 @@  discard block
 block discarded – undo
2281 2281
 			 * @param array $fields_n_values fields and their values
2282 2282
 			 * @param int|string the ID of the newly-inserted model object
2283 2283
 			 */
2284
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2284
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
2285 2285
 			return $new_id;
2286
-		}else{
2286
+		} else {
2287 2287
 			return FALSE;
2288 2288
 		}
2289 2289
 	}
@@ -2298,10 +2298,10 @@  discard block
 block discarded – undo
2298 2298
 	 * @return boolean
2299 2299
 	 * @throws \EE_Error
2300 2300
 	 */
2301
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
2302
-		foreach($this->unique_indexes() as $index_name => $index){
2301
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
2302
+		foreach ($this->unique_indexes() as $index_name => $index) {
2303 2303
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
2304
-			if($this->exists(array($uniqueness_where_params))){
2304
+			if ($this->exists(array($uniqueness_where_params))) {
2305 2305
 				EE_Error::add_error(
2306 2306
 					sprintf(
2307 2307
 						__(
@@ -2311,8 +2311,8 @@  discard block
 block discarded – undo
2311 2311
 						$action,
2312 2312
 						$this->_get_class_name(),
2313 2313
 						$index_name,
2314
-						implode( ",", $index->field_names() ),
2315
-						http_build_query( $uniqueness_where_params )
2314
+						implode(",", $index->field_names()),
2315
+						http_build_query($uniqueness_where_params)
2316 2316
 					),
2317 2317
 					__FILE__,
2318 2318
 					__FUNCTION__,
@@ -2338,37 +2338,37 @@  discard block
 block discarded – undo
2338 2338
 	 * @throws EE_Error
2339 2339
 	 * @return EE_Base_Class
2340 2340
 	 */
2341
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2342
-		if($obj_or_fields_array instanceof EE_Base_Class){
2341
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
2342
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
2343 2343
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2344
-		}elseif( is_array($obj_or_fields_array)){
2344
+		}elseif (is_array($obj_or_fields_array)) {
2345 2345
 			$fields_n_values = $obj_or_fields_array;
2346
-		}else{
2346
+		} else {
2347 2347
 			throw new EE_Error(
2348 2348
 				sprintf(
2349 2349
 					__(
2350 2350
 						"%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d",
2351 2351
 						"event_espresso"
2352 2352
 					),
2353
-					get_class( $this ),
2353
+					get_class($this),
2354 2354
 					$obj_or_fields_array
2355 2355
 				)
2356 2356
 			);
2357 2357
 		}
2358 2358
 		$query_params = array();
2359
-		if( $this->has_primary_key_field() &&
2360
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2361
-				isset($fields_n_values[$this->primary_key_name()])){
2359
+		if ($this->has_primary_key_field() &&
2360
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2361
+				isset($fields_n_values[$this->primary_key_name()])) {
2362 2362
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
2363 2363
 		}
2364
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
2364
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
2365 2365
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
2366 2366
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
2367 2367
 		}
2368 2368
 		//if there is nothing to base this search on, then we shouldn't find anything
2369
-		if( empty( $query_params ) ){
2369
+		if (empty($query_params)) {
2370 2370
 			return array();
2371
-		}else{
2371
+		} else {
2372 2372
 			return $this->get_one($query_params);
2373 2373
 		}
2374 2374
 	}
@@ -2382,7 +2382,7 @@  discard block
 block discarded – undo
2382 2382
 	 * @return boolean
2383 2383
 	 * @throws \EE_Error
2384 2384
 	 */
2385
-	public function exists($query_params){
2385
+	public function exists($query_params) {
2386 2386
 		$query_params['limit'] = 1;
2387 2387
 		return $this->count($query_params) > 0;
2388 2388
 	}
@@ -2396,7 +2396,7 @@  discard block
 block discarded – undo
2396 2396
 	 * @return boolean
2397 2397
 	 * @throws \EE_Error
2398 2398
 	 */
2399
-	public function exists_by_ID($id){
2399
+	public function exists_by_ID($id) {
2400 2400
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
2401 2401
 	}
2402 2402
 
@@ -2416,45 +2416,45 @@  discard block
 block discarded – undo
2416 2416
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
2417 2417
 	 * @return int ID of new row inserted, or FALSE on failure
2418 2418
 	 */
2419
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
2419
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
2420 2420
 		global $wpdb;
2421 2421
 		$insertion_col_n_values = array();
2422 2422
 		$format_for_insertion = array();
2423 2423
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
2424
-		foreach($fields_on_table as $field_name => $field_obj){
2424
+		foreach ($fields_on_table as $field_name => $field_obj) {
2425 2425
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
2426
-			if($field_obj->is_auto_increment()){
2426
+			if ($field_obj->is_auto_increment()) {
2427 2427
 				continue;
2428 2428
 			}
2429 2429
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
2430 2430
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
2431
-			if( $prepared_value !== NULL ){
2432
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
2431
+			if ($prepared_value !== NULL) {
2432
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
2433 2433
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
2434 2434
 			}
2435 2435
 		}
2436 2436
 
2437
-		if($table instanceof EE_Secondary_Table && $new_id){
2437
+		if ($table instanceof EE_Secondary_Table && $new_id) {
2438 2438
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
2439 2439
 			//so add the fk to the main table as a column
2440 2440
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
2441
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
2441
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
2442 2442
 		}
2443 2443
 		//insert the new entry
2444
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
2445
-		if( $result === false ) {
2444
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
2445
+		if ($result === false) {
2446 2446
 			return false;
2447 2447
 		}
2448 2448
 		//ok, now what do we return for the ID of the newly-inserted thing?
2449
-		if($this->has_primary_key_field()){
2450
-			if($this->get_primary_key_field()->is_auto_increment()){
2449
+		if ($this->has_primary_key_field()) {
2450
+			if ($this->get_primary_key_field()->is_auto_increment()) {
2451 2451
 				return $wpdb->insert_id;
2452
-			}else{
2452
+			} else {
2453 2453
 				//it's not an auto-increment primary key, so
2454 2454
 				//it must have been supplied
2455 2455
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2456 2456
 			}
2457
-		}else{
2457
+		} else {
2458 2458
 			//we can't return a  primary key because there is none. instead return
2459 2459
 			//a unique string indicating this model
2460 2460
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2473,15 +2473,15 @@  discard block
 block discarded – undo
2473 2473
 	 * @return mixed string|int|float depending on what the table column will be expecting
2474 2474
 	 * @throws \EE_Error
2475 2475
 	 */
2476
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
2476
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
2477 2477
 		//if this field doesn't allow nullable, don't allow it
2478
-		if( ! $field_obj->is_nullable() && (
2479
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
2480
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
2481
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
2478
+		if ( ! $field_obj->is_nullable() && (
2479
+				! isset($fields_n_values[$field_obj->get_name()]) ||
2480
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
2481
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
2482 2482
 		}
2483
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
2484
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
2483
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
2484
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
2485 2485
 	}
2486 2486
 
2487 2487
 
@@ -2493,9 +2493,9 @@  discard block
 block discarded – undo
2493 2493
 	 * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection
2494 2494
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
2495 2495
 	 */
2496
-	private function _prepare_value_for_use_in_db($value, $field){
2497
-		if($field && $field instanceof EE_Model_Field_Base){
2498
-			switch( $this->_values_already_prepared_by_model_object ){
2496
+	private function _prepare_value_for_use_in_db($value, $field) {
2497
+		if ($field && $field instanceof EE_Model_Field_Base) {
2498
+			switch ($this->_values_already_prepared_by_model_object) {
2499 2499
 				/** @noinspection PhpMissingBreakStatementInspection */
2500 2500
 				case self::not_prepared_by_model_object:
2501 2501
 					$value = $field->prepare_for_set($value);
@@ -2506,7 +2506,7 @@  discard block
 block discarded – undo
2506 2506
 					//leave the value alone
2507 2507
 			}
2508 2508
 			return $value;
2509
-		}else{
2509
+		} else {
2510 2510
 			return $value;
2511 2511
 		}
2512 2512
 	}
@@ -2516,13 +2516,13 @@  discard block
 block discarded – undo
2516 2516
 	 * @return EE_Primary_Table
2517 2517
 	 * @throws EE_Error
2518 2518
 	 */
2519
-	protected function _get_main_table(){
2520
-		foreach($this->_tables as $table){
2521
-			if($table instanceof EE_Primary_Table){
2519
+	protected function _get_main_table() {
2520
+		foreach ($this->_tables as $table) {
2521
+			if ($table instanceof EE_Primary_Table) {
2522 2522
 				return $table;
2523 2523
 			}
2524 2524
 		}
2525
-		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor','event_espresso'),get_class($this)));
2525
+		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor', 'event_espresso'), get_class($this)));
2526 2526
 	}
2527 2527
 
2528 2528
 
@@ -2545,7 +2545,7 @@  discard block
 block discarded – undo
2545 2545
 	 */
2546 2546
 	public function second_table() {
2547 2547
 		// grab second table from tables array
2548
-		$second_table = end( $this->_tables );
2548
+		$second_table = end($this->_tables);
2549 2549
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
2550 2550
 	}
2551 2551
 
@@ -2558,8 +2558,8 @@  discard block
 block discarded – undo
2558 2558
 	 * @param string $table_alias
2559 2559
 	 * @return EE_Primary_Table | EE_Secondary_Table
2560 2560
 	 */
2561
-	public function get_table_obj_by_alias( $table_alias = '' ) {
2562
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
2561
+	public function get_table_obj_by_alias($table_alias = '') {
2562
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
2563 2563
 	}
2564 2564
 
2565 2565
 
@@ -2568,10 +2568,10 @@  discard block
 block discarded – undo
2568 2568
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
2569 2569
 	 * @return EE_Secondary_Table[]
2570 2570
 	 */
2571
-	protected function _get_other_tables(){
2572
-		$other_tables =array();
2573
-		foreach($this->_tables as $table_alias => $table){
2574
-			if($table instanceof EE_Secondary_Table){
2571
+	protected function _get_other_tables() {
2572
+		$other_tables = array();
2573
+		foreach ($this->_tables as $table_alias => $table) {
2574
+			if ($table instanceof EE_Secondary_Table) {
2575 2575
 				$other_tables[$table_alias] = $table;
2576 2576
 			}
2577 2577
 		}
@@ -2583,7 +2583,7 @@  discard block
 block discarded – undo
2583 2583
 	 * @param string $table_alias, array key in EEM_Base::_tables
2584 2584
 	 * @return EE_Model_Field_Base[]
2585 2585
 	 */
2586
-	public function _get_fields_for_table($table_alias){
2586
+	public function _get_fields_for_table($table_alias) {
2587 2587
 		return $this->_fields[$table_alias];
2588 2588
 	}
2589 2589
 
@@ -2599,19 +2599,19 @@  discard block
 block discarded – undo
2599 2599
 	 * @return EE_Model_Query_Info_Carrier
2600 2600
 	 * @throws \EE_Error
2601 2601
 	 */
2602
-	public function _extract_related_models_from_query($query_params){
2602
+	public function _extract_related_models_from_query($query_params) {
2603 2603
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
2604
-		if ( array_key_exists( 0, $query_params ) ) {
2605
-			$this->_extract_related_models_from_sub_params_array_keys( $query_params[0], $query_info_carrier, 0 );
2604
+		if (array_key_exists(0, $query_params)) {
2605
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
2606 2606
 		}
2607
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2608
-			if ( is_array( $query_params['group_by'] ) ) {
2607
+		if (array_key_exists('group_by', $query_params)) {
2608
+			if (is_array($query_params['group_by'])) {
2609 2609
 				$this->_extract_related_models_from_sub_params_array_values(
2610 2610
 					$query_params['group_by'],
2611 2611
 					$query_info_carrier,
2612 2612
 					'group_by'
2613 2613
 				);
2614
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2614
+			} elseif ( ! empty ($query_params['group_by'])) {
2615 2615
 				$this->_extract_related_model_info_from_query_param(
2616 2616
 					$query_params['group_by'],
2617 2617
 					$query_info_carrier,
@@ -2619,21 +2619,21 @@  discard block
 block discarded – undo
2619 2619
 				);
2620 2620
 			}
2621 2621
 		}
2622
-		if ( array_key_exists( 'having', $query_params ) ) {
2622
+		if (array_key_exists('having', $query_params)) {
2623 2623
 			$this->_extract_related_models_from_sub_params_array_keys(
2624 2624
 				$query_params[0],
2625 2625
 				$query_info_carrier,
2626 2626
 				'having'
2627 2627
 			);
2628 2628
 		}
2629
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2630
-			if ( is_array( $query_params['order_by'] ) ) {
2629
+		if (array_key_exists('order_by', $query_params)) {
2630
+			if (is_array($query_params['order_by'])) {
2631 2631
 				$this->_extract_related_models_from_sub_params_array_keys(
2632 2632
 					$query_params['order_by'],
2633 2633
 					$query_info_carrier,
2634 2634
 					'order_by'
2635 2635
 				);
2636
-			} elseif ( ! empty( $query_params['order_by'] ) ) {
2636
+			} elseif ( ! empty($query_params['order_by'])) {
2637 2637
 				$this->_extract_related_model_info_from_query_param(
2638 2638
 					$query_params['order_by'],
2639 2639
 					$query_info_carrier,
@@ -2641,7 +2641,7 @@  discard block
 block discarded – undo
2641 2641
 				);
2642 2642
 			}
2643 2643
 		}
2644
-		if ( array_key_exists( 'force_join', $query_params ) ) {
2644
+		if (array_key_exists('force_join', $query_params)) {
2645 2645
 			$this->_extract_related_models_from_sub_params_array_values(
2646 2646
 				$query_params['force_join'],
2647 2647
 				$query_info_carrier,
@@ -2659,34 +2659,34 @@  discard block
 block discarded – undo
2659 2659
 	 * @throws EE_Error
2660 2660
 	 * @return \EE_Model_Query_Info_Carrier
2661 2661
 	 */
2662
-	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2663
-		if (!empty($sub_query_params)){
2662
+	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2663
+		if ( ! empty($sub_query_params)) {
2664 2664
 			$sub_query_params = (array) $sub_query_params;
2665
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2665
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2666 2666
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2667
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2667
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2668 2668
 
2669 2669
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2670 2670
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2671 2671
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2672 2672
 				//of array('Registration.TXN_ID'=>23)
2673 2673
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2674
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2675
-					if (! is_array($possibly_array_of_params)){
2674
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2675
+					if ( ! is_array($possibly_array_of_params)) {
2676 2676
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
2677
-							$param,$possibly_array_of_params));
2678
-					}else{
2679
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2677
+							$param, $possibly_array_of_params));
2678
+					} else {
2679
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2680 2680
 					}
2681
-				}elseif($query_param_type === 0 //ie WHERE
2681
+				}elseif ($query_param_type === 0 //ie WHERE
2682 2682
 						&& is_array($possibly_array_of_params)
2683 2683
 						&& isset($possibly_array_of_params[2])
2684
-						&& $possibly_array_of_params[2] == true){
2684
+						&& $possibly_array_of_params[2] == true) {
2685 2685
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2686 2686
 					//indicating that $possible_array_of_params[1] is actually a field name,
2687 2687
 					//from which we should extract query parameters!
2688
-					if( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1] ) ) {
2689
-						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"),$query_param_type,implode(",",$possibly_array_of_params)));
2688
+					if ( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1])) {
2689
+						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"), $query_param_type, implode(",", $possibly_array_of_params)));
2690 2690
 					}
2691 2691
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2692 2692
 				}
@@ -2705,14 +2705,14 @@  discard block
 block discarded – undo
2705 2705
 	 * @throws EE_Error
2706 2706
 	 * @return \EE_Model_Query_Info_Carrier
2707 2707
 	 */
2708
-	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2709
-		if (!empty($sub_query_params)){
2710
-			if(!is_array($sub_query_params)){
2711
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2708
+	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2709
+		if ( ! empty($sub_query_params)) {
2710
+			if ( ! is_array($sub_query_params)) {
2711
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2712 2712
 			}
2713
-			foreach($sub_query_params as $param){
2713
+			foreach ($sub_query_params as $param) {
2714 2714
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2715
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2715
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2716 2716
 			}
2717 2717
 		}
2718 2718
 		return $model_query_info_carrier;
@@ -2731,8 +2731,8 @@  discard block
 block discarded – undo
2731 2731
 	 * @throws EE_Error
2732 2732
 	 * @return EE_Model_Query_Info_Carrier
2733 2733
 	 */
2734
-	public function _create_model_query_info_carrier($query_params){
2735
-		if ( ! is_array( $query_params ) ) {
2734
+	public function _create_model_query_info_carrier($query_params) {
2735
+		if ( ! is_array($query_params)) {
2736 2736
 			EE_Error::doing_it_wrong(
2737 2737
 				'EEM_Base::_create_model_query_info_carrier',
2738 2738
 				sprintf(
@@ -2740,16 +2740,16 @@  discard block
 block discarded – undo
2740 2740
 						'$query_params should be an array, you passed a variable of type %s',
2741 2741
 						'event_espresso'
2742 2742
 					),
2743
-					gettype( $query_params )
2743
+					gettype($query_params)
2744 2744
 				),
2745 2745
 				'4.6.0'
2746 2746
 			);
2747 2747
 			$query_params = array();
2748 2748
 		}
2749
-		$where_query_params = isset( $query_params[0] ) ? $query_params[0] : array();
2749
+		$where_query_params = isset($query_params[0]) ? $query_params[0] : array();
2750 2750
 		//first check if we should alter the query to account for caps or not
2751 2751
 		//because the caps might require us to do extra joins
2752
-		if ( isset( $query_params['caps'] ) && $query_params['caps'] !== 'none' ) {
2752
+		if (isset($query_params['caps']) && $query_params['caps'] !== 'none') {
2753 2753
 			$query_params[0] = $where_query_params = array_replace_recursive(
2754 2754
 				$where_query_params,
2755 2755
 				$this->caps_where_conditions(
@@ -2757,10 +2757,10 @@  discard block
 block discarded – undo
2757 2757
 				)
2758 2758
 			);
2759 2759
 		}
2760
-		$query_object = $this->_extract_related_models_from_query( $query_params );
2760
+		$query_object = $this->_extract_related_models_from_query($query_params);
2761 2761
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2762
-		foreach ( $where_query_params as $key => $value ) {
2763
-			if ( is_int( $key ) ) {
2762
+		foreach ($where_query_params as $key => $value) {
2763
+			if (is_int($key)) {
2764 2764
 				throw new EE_Error(
2765 2765
 					sprintf(
2766 2766
 						__(
@@ -2768,16 +2768,16 @@  discard block
 block discarded – undo
2768 2768
 							"event_espresso"
2769 2769
 						),
2770 2770
 						$key,
2771
-						var_export( $value, true ),
2772
-						var_export( $query_params, true ),
2773
-						get_class( $this )
2771
+						var_export($value, true),
2772
+						var_export($query_params, true),
2773
+						get_class($this)
2774 2774
 					)
2775 2775
 				);
2776 2776
 			}
2777 2777
 		}
2778 2778
 		if (
2779
-			array_key_exists( 'default_where_conditions', $query_params )
2780
-			&& ! empty( $query_params['default_where_conditions'] )
2779
+			array_key_exists('default_where_conditions', $query_params)
2780
+			&& ! empty($query_params['default_where_conditions'])
2781 2781
 		) {
2782 2782
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2783 2783
 		} else {
@@ -2791,13 +2791,13 @@  discard block
 block discarded – undo
2791 2791
 			),
2792 2792
 			$where_query_params
2793 2793
 		);
2794
-		$query_object->set_where_sql( $this->_construct_where_clause( $where_query_params ) );
2794
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2795 2795
 		// if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join.
2796 2796
 		// So we need to setup a subquery and use that for the main join.
2797 2797
 		// Note for now this only works on the primary table for the model.
2798 2798
 		// So for instance, you could set the limit array like this:
2799 2799
 		// array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2800
-		if ( array_key_exists( 'on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] ) ) {
2800
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2801 2801
 			$query_object->set_main_model_join_sql(
2802 2802
 				$this->_construct_limit_join_select(
2803 2803
 					$query_params['on_join_limit'][0],
@@ -2806,40 +2806,40 @@  discard block
 block discarded – undo
2806 2806
 			);
2807 2807
 		}
2808 2808
 		//set limit
2809
-		if ( array_key_exists( 'limit', $query_params ) ) {
2810
-			if ( is_array( $query_params['limit'] ) ) {
2811
-				if ( ! isset( $query_params['limit'][0], $query_params['limit'][1] ) ) {
2809
+		if (array_key_exists('limit', $query_params)) {
2810
+			if (is_array($query_params['limit'])) {
2811
+				if ( ! isset($query_params['limit'][0], $query_params['limit'][1])) {
2812 2812
 					$e = sprintf(
2813 2813
 						__(
2814 2814
 							"Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)",
2815 2815
 							"event_espresso"
2816 2816
 						),
2817
-						http_build_query( $query_params['limit'] )
2817
+						http_build_query($query_params['limit'])
2818 2818
 					);
2819
-					throw new EE_Error( $e . "|" . $e );
2819
+					throw new EE_Error($e."|".$e);
2820 2820
 				}
2821 2821
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2822
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'][0] . "," . $query_params['limit'][1] );
2823
-			} elseif ( ! empty ( $query_params['limit'] ) ) {
2824
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'] );
2822
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2823
+			} elseif ( ! empty ($query_params['limit'])) {
2824
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit']);
2825 2825
 			}
2826 2826
 		}
2827 2827
 		//set order by
2828
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2829
-			if ( is_array( $query_params['order_by'] ) ) {
2828
+		if (array_key_exists('order_by', $query_params)) {
2829
+			if (is_array($query_params['order_by'])) {
2830 2830
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2831 2831
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2832 2832
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2833
-				if ( array_key_exists( 'order', $query_params ) ) {
2833
+				if (array_key_exists('order', $query_params)) {
2834 2834
 					throw new EE_Error(
2835 2835
 						sprintf(
2836 2836
 							__(
2837 2837
 								"In querying %s, we are using query parameter 'order_by' as an array (keys:%s,values:%s), and so we can't use query parameter 'order' (value %s). You should just use the 'order_by' parameter ",
2838 2838
 								"event_espresso"
2839 2839
 							),
2840
-							get_class( $this ),
2841
-							implode( ", ", array_keys( $query_params['order_by'] ) ),
2842
-							implode( ", ", $query_params['order_by'] ),
2840
+							get_class($this),
2841
+							implode(", ", array_keys($query_params['order_by'])),
2842
+							implode(", ", $query_params['order_by']),
2843 2843
 							$query_params['order']
2844 2844
 						)
2845 2845
 					);
@@ -2851,57 +2851,57 @@  discard block
 block discarded – undo
2851 2851
 				);
2852 2852
 				//assume it's an array of fields to order by
2853 2853
 				$order_array = array();
2854
-				foreach ( $query_params['order_by'] as $field_name_to_order_by => $order ) {
2855
-					$order = $this->_extract_order( $order );
2856
-					$order_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_order_by ) . SP . $order;
2854
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2855
+					$order = $this->_extract_order($order);
2856
+					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2857 2857
 				}
2858
-				$query_object->set_order_by_sql( " ORDER BY " . implode( ",", $order_array ) );
2859
-			} elseif ( ! empty ( $query_params['order_by'] ) ) {
2858
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2859
+			} elseif ( ! empty ($query_params['order_by'])) {
2860 2860
 				$this->_extract_related_model_info_from_query_param(
2861 2861
 					$query_params['order_by'],
2862 2862
 					$query_object,
2863 2863
 					'order',
2864 2864
 					$query_params['order_by']
2865 2865
 				);
2866
-				$order = isset( $query_params['order'] )
2867
-					? $this->_extract_order( $query_params['order'] )
2866
+				$order = isset($query_params['order'])
2867
+					? $this->_extract_order($query_params['order'])
2868 2868
 					: 'DESC';
2869 2869
 				$query_object->set_order_by_sql(
2870
-					" ORDER BY " . $this->_deduce_column_name_from_query_param( $query_params['order_by'] ) . SP . $order
2870
+					" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order
2871 2871
 				);
2872 2872
 			}
2873 2873
 		}
2874 2874
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2875
-		if ( ! array_key_exists( 'order_by', $query_params )
2876
-		     && array_key_exists( 'order', $query_params )
2877
-		     && ! empty( $query_params['order'] )
2875
+		if ( ! array_key_exists('order_by', $query_params)
2876
+		     && array_key_exists('order', $query_params)
2877
+		     && ! empty($query_params['order'])
2878 2878
 		) {
2879 2879
 			$pk_field = $this->get_primary_key_field();
2880
-			$order = $this->_extract_order( $query_params['order'] );
2881
-			$query_object->set_order_by_sql( " ORDER BY " . $pk_field->get_qualified_column() . SP . $order );
2880
+			$order = $this->_extract_order($query_params['order']);
2881
+			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2882 2882
 		}
2883 2883
 		//set group by
2884
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2885
-			if ( is_array( $query_params['group_by'] ) ) {
2884
+		if (array_key_exists('group_by', $query_params)) {
2885
+			if (is_array($query_params['group_by'])) {
2886 2886
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2887 2887
 				$group_by_array = array();
2888
-				foreach ( $query_params['group_by'] as $field_name_to_group_by ) {
2889
-					$group_by_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_group_by );
2888
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2889
+					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2890 2890
 				}
2891
-				$query_object->set_group_by_sql( " GROUP BY " . implode( ", ", $group_by_array ) );
2892
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2891
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2892
+			} elseif ( ! empty ($query_params['group_by'])) {
2893 2893
 				$query_object->set_group_by_sql(
2894
-					" GROUP BY " . $this->_deduce_column_name_from_query_param( $query_params['group_by'] )
2894
+					" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by'])
2895 2895
 				);
2896 2896
 			}
2897 2897
 		}
2898 2898
 		//set having
2899
-		if ( array_key_exists( 'having', $query_params ) && $query_params['having'] ) {
2900
-			$query_object->set_having_sql( $this->_construct_having_clause( $query_params['having'] ) );
2899
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2900
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2901 2901
 		}
2902 2902
 		//now, just verify they didn't pass anything wack
2903
-		foreach ( $query_params as $query_key => $query_value ) {
2904
-			if ( ! in_array( $query_key, $this->_allowed_query_params, true ) ) {
2903
+		foreach ($query_params as $query_key => $query_value) {
2904
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2905 2905
 				throw new EE_Error(
2906 2906
 					sprintf(
2907 2907
 						__(
@@ -2909,16 +2909,16 @@  discard block
 block discarded – undo
2909 2909
 							'event_espresso'
2910 2910
 						),
2911 2911
 						$query_key,
2912
-						get_class( $this ),
2912
+						get_class($this),
2913 2913
 //						print_r( $this->_allowed_query_params, TRUE )
2914
-						implode( ',', $this->_allowed_query_params )
2914
+						implode(',', $this->_allowed_query_params)
2915 2915
 					)
2916 2916
 				);
2917 2917
 			}
2918 2918
 		}
2919 2919
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2920
-		if ( empty( $main_model_join_sql ) ) {
2921
-			$query_object->set_main_model_join_sql( $this->_construct_internal_join() );
2920
+		if (empty($main_model_join_sql)) {
2921
+			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2922 2922
 		}
2923 2923
 		return $query_object;
2924 2924
 	}
@@ -2933,17 +2933,17 @@  discard block
 block discarded – undo
2933 2933
 	 * @return array like EEM_Base::get_all() 's $query_params[0]
2934 2934
 	 * @throws \EE_Error
2935 2935
 	 */
2936
-	public function caps_where_conditions( $context = self::caps_read ) {
2937
-		EEM_Base::verify_is_valid_cap_context( $context );
2936
+	public function caps_where_conditions($context = self::caps_read) {
2937
+		EEM_Base::verify_is_valid_cap_context($context);
2938 2938
 		$cap_where_conditions = array();
2939
-		$cap_restrictions = $this->caps_missing( $context );
2939
+		$cap_restrictions = $this->caps_missing($context);
2940 2940
 		/**
2941 2941
 		 * @var $cap_restrictions EE_Default_Where_Conditions[]
2942 2942
 		 */
2943
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
2944
-				$cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() );
2943
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
2944
+				$cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions());
2945 2945
 		}
2946
-		return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions );
2946
+		return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions);
2947 2947
 	}
2948 2948
 
2949 2949
 	/**
@@ -2953,11 +2953,11 @@  discard block
 block discarded – undo
2953 2953
 	 * @return string either ASC, asc, DESC or desc
2954 2954
 	 * @throws EE_Error
2955 2955
 	 */
2956
-	private function _extract_order($should_be_order_string){
2957
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2956
+	private function _extract_order($should_be_order_string) {
2957
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
2958 2958
 			return $should_be_order_string;
2959
-		}else{
2960
-			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
2959
+		} else {
2960
+			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"), get_class($this), $should_be_order_string));
2961 2961
 		}
2962 2962
 	}
2963 2963
 
@@ -2975,7 +2975,7 @@  discard block
 block discarded – undo
2975 2975
 	 * @throws EE_Error
2976 2976
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
2977 2977
 	 */
2978
-	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier,$use_default_where_conditions = 'all',$where_query_params = array()){
2978
+	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier, $use_default_where_conditions = 'all', $where_query_params = array()) {
2979 2979
 		$allowed_used_default_where_conditions_values = array(
2980 2980
 				'all',
2981 2981
 				'this_model_only',
@@ -2983,17 +2983,17 @@  discard block
 block discarded – undo
2983 2983
 				'minimum',
2984 2984
 				'none'
2985 2985
 			);
2986
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
2987
-			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"),$use_default_where_conditions,implode(", ",$allowed_used_default_where_conditions_values)));
2986
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
2987
+			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"), $use_default_where_conditions, implode(", ", $allowed_used_default_where_conditions_values)));
2988 2988
 		}
2989 2989
 		$universal_query_params = array();
2990
-		if( $use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only' ){
2990
+		if ($use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only') {
2991 2991
 			$universal_query_params = $this->_get_default_where_conditions();
2992
-		} else if( $use_default_where_conditions === 'minimum' ) {
2992
+		} else if ($use_default_where_conditions === 'minimum') {
2993 2993
 			$universal_query_params = $this->_get_minimum_where_conditions();
2994 2994
 		}
2995
-		if(in_array($use_default_where_conditions,array('all','other_models_only'))){
2996
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
2995
+		if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) {
2996
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
2997 2997
 				$related_model = $this->get_related_model_obj($model_name);
2998 2998
 				$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
2999 2999
 				$overrides = $this->_override_defaults_or_make_null_friendly(
@@ -3026,20 +3026,20 @@  discard block
 block discarded – undo
3026 3026
 	 * @return array like EEM_Base::get_all's $query_params[0]
3027 3027
 	 * @throws \EE_Error
3028 3028
 	 */
3029
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
3029
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
3030 3030
 		$null_friendly_where_conditions = array();
3031 3031
 		$none_overridden = true;
3032 3032
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
3033 3033
 
3034
-		foreach($default_where_conditions as $key => $val){
3035
-			if( isset($provided_where_conditions[$key])){
3034
+		foreach ($default_where_conditions as $key => $val) {
3035
+			if (isset($provided_where_conditions[$key])) {
3036 3036
 				$none_overridden = false;
3037
-			}else{
3037
+			} else {
3038 3038
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
3039 3039
 			}
3040 3040
 		}
3041
-		if( $none_overridden && $default_where_conditions){
3042
-			if($model->has_primary_key_field()){
3041
+		if ($none_overridden && $default_where_conditions) {
3042
+			if ($model->has_primary_key_field()) {
3043 3043
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
3044 3044
 			}/*else{
3045 3045
 				//@todo NO PK, use other defaults
@@ -3056,8 +3056,8 @@  discard block
 block discarded – undo
3056 3056
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3057 3057
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3058 3058
 	 */
3059
-	private function _get_default_where_conditions($model_relation_path = null){
3060
-		if ( $this->_ignore_where_strategy ){
3059
+	private function _get_default_where_conditions($model_relation_path = null) {
3060
+		if ($this->_ignore_where_strategy) {
3061 3061
 			return array();
3062 3062
 		}
3063 3063
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3071,8 +3071,8 @@  discard block
 block discarded – undo
3071 3071
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3072 3072
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3073 3073
 	 */
3074
-	protected function _get_minimum_where_conditions($model_relation_path = null){
3075
-		if ( $this->_ignore_where_strategy ){
3074
+	protected function _get_minimum_where_conditions($model_relation_path = null) {
3075
+		if ($this->_ignore_where_strategy) {
3076 3076
 			return array();
3077 3077
 		}
3078 3078
 		return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3088,16 +3088,16 @@  discard block
 block discarded – undo
3088 3088
 	 * @return string
3089 3089
 	 * @throws \EE_Error
3090 3090
 	 */
3091
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
3091
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
3092 3092
 		$selects = $this->_get_columns_to_select_for_this_model();
3093
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
3093
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
3094 3094
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
3095
-			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model( $model_relation_chain );
3096
-			foreach ( $other_model_selects as $key => $value ) {
3095
+			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain);
3096
+			foreach ($other_model_selects as $key => $value) {
3097 3097
 				$selects[] = $value;
3098 3098
 			}
3099 3099
 		}
3100
-		return implode(", ",$selects);
3100
+		return implode(", ", $selects);
3101 3101
 	}
3102 3102
 
3103 3103
 	/**
@@ -3106,19 +3106,19 @@  discard block
 block discarded – undo
3106 3106
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
3107 3107
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
3108 3108
 	 */
3109
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
3109
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
3110 3110
 		$fields = $this->field_settings();
3111 3111
 		$selects = array();
3112 3112
 		$table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model_name());
3113
-		foreach($fields as $field_obj){
3114
-			$selects[] = $table_alias_with_model_relation_chain_prefix . $field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
3113
+		foreach ($fields as $field_obj) {
3114
+			$selects[] = $table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
3115 3115
 		}
3116 3116
 		//make sure we are also getting the PKs of each table
3117 3117
 		$tables = $this->get_tables();
3118
-		if(count($tables) > 1){
3119
-			foreach($tables as $table_obj){
3120
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
3121
-				if( ! in_array($qualified_pk_column,$selects)){
3118
+		if (count($tables) > 1) {
3119
+			foreach ($tables as $table_obj) {
3120
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
3121
+				if ( ! in_array($qualified_pk_column, $selects)) {
3122 3122
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
3123 3123
 				}
3124 3124
 			}
@@ -3148,65 +3148,65 @@  discard block
 block discarded – undo
3148 3148
 		$query_param_type,
3149 3149
 		$original_query_param = null
3150 3150
 	) {
3151
-		if( $original_query_param === null ){
3151
+		if ($original_query_param === null) {
3152 3152
 			$original_query_param = $query_param;
3153 3153
 		}
3154 3154
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
3155 3155
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
3156
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
3157
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
3156
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
3157
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
3158 3158
 		//check to see if we have a field on this model
3159 3159
 		$this_model_fields = $this->field_settings(true);
3160
-		if(array_key_exists($query_param,$this_model_fields)){
3161
-			if($allow_fields){
3160
+		if (array_key_exists($query_param, $this_model_fields)) {
3161
+			if ($allow_fields) {
3162 3162
 				return;
3163
-			}else{
3163
+			} else {
3164 3164
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
3165
-						$query_param,get_class($this),$query_param_type,$original_query_param));
3165
+						$query_param, get_class($this), $query_param_type, $original_query_param));
3166 3166
 			}
3167 3167
 		}
3168 3168
 		//check if this is a special logic query param
3169
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
3170
-			if($allow_logic_query_params){
3169
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
3170
+			if ($allow_logic_query_params) {
3171 3171
 				return;
3172
-			}else{
3172
+			} else {
3173 3173
 				throw new EE_Error(
3174 3174
 					sprintf(
3175
-						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
3176
-						implode( '", "', $this->_logic_query_param_keys ),
3177
-						$query_param ,
3178
-						get_class( $this ),
3175
+						__('Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso'),
3176
+						implode('", "', $this->_logic_query_param_keys),
3177
+						$query_param,
3178
+						get_class($this),
3179 3179
 						'<br />',
3180
-						"\t" . ' $passed_in_query_info = <pre>' . print_r( $passed_in_query_info, TRUE ) . '</pre>' . "\n\t" . ' $query_param_type = ' . $query_param_type . "\n\t" . ' $original_query_param = ' . $original_query_param
3180
+						"\t".' $passed_in_query_info = <pre>'.print_r($passed_in_query_info, TRUE).'</pre>'."\n\t".' $query_param_type = '.$query_param_type."\n\t".' $original_query_param = '.$original_query_param
3181 3181
 					)
3182 3182
 				);
3183 3183
 			}
3184 3184
 		}
3185 3185
 
3186 3186
 		//check if it's a custom selection
3187
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
3187
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
3188 3188
 			return;
3189 3189
 		}
3190 3190
 
3191 3191
 		//check if has a model name at the beginning
3192 3192
 		//and
3193 3193
 		//check if it's a field on a related model
3194
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
3195
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
3196
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3194
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
3195
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
3196
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3197 3197
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
3198
-				if($query_param === ''){
3198
+				if ($query_param === '') {
3199 3199
 					//nothing left to $query_param
3200 3200
 					//we should actually end in a field name, not a model like this!
3201 3201
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
3202
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
3203
-				}else{
3202
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
3203
+				} else {
3204 3204
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
3205 3205
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
3206 3206
 					return;
3207 3207
 				}
3208
-			}elseif($query_param === $valid_related_model_name){
3209
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3208
+			}elseif ($query_param === $valid_related_model_name) {
3209
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3210 3210
 				return;
3211 3211
 			}
3212 3212
 		}
@@ -3216,7 +3216,7 @@  discard block
 block discarded – undo
3216 3216
 		//and we previously confirmed it wasn't a logic query param or field on the current model
3217 3217
 		//it's wack, that's what it is
3218 3218
 		throw new EE_Error(sprintf(__("There is no model named '%s' related to %s. Query param type is %s and original query param is %s", "event_espresso"),
3219
-				$query_param,get_class($this),$query_param_type,$original_query_param));
3219
+				$query_param, get_class($this), $query_param_type, $original_query_param));
3220 3220
 
3221 3221
 	}
3222 3222
 
@@ -3235,26 +3235,26 @@  discard block
 block discarded – undo
3235 3235
 	 * @return void
3236 3236
 	 * @throws \EE_Error
3237 3237
 	 */
3238
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
3238
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
3239 3239
 		$relation_obj = $this->related_settings_for($model_name);
3240 3240
 
3241 3241
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
3242 3242
 		//check if the relation is HABTM, because then we're essentially doing two joins
3243 3243
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
3244
-		if($relation_obj instanceof EE_HABTM_Relation){
3244
+		if ($relation_obj instanceof EE_HABTM_Relation) {
3245 3245
 			$join_model_obj = $relation_obj->get_join_model();
3246 3246
 			//replace the model specified with the join model for this relation chain, whi
3247 3247
 			$relation_chain_to_join_model = EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_obj->get_this_model_name(), $model_relation_chain);
3248 3248
 			$new_query_info = new EE_Model_Query_Info_Carrier(
3249 3249
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
3250 3250
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
3251
-			$passed_in_query_info->merge( $new_query_info  );
3251
+			$passed_in_query_info->merge($new_query_info);
3252 3252
 		}
3253 3253
 		//now just join to the other table pointed to by the relation object, and add its data types
3254 3254
 		$new_query_info = new EE_Model_Query_Info_Carrier(
3255 3255
 				array($model_relation_chain=>$model_name),
3256 3256
 				$relation_obj->get_join_statement($model_relation_chain));
3257
-		$passed_in_query_info->merge( $new_query_info  );
3257
+		$passed_in_query_info->merge($new_query_info);
3258 3258
 	}
3259 3259
 
3260 3260
 
@@ -3266,11 +3266,11 @@  discard block
 block discarded – undo
3266 3266
 	 * @return string of SQL
3267 3267
 	 * @throws \EE_Error
3268 3268
 	 */
3269
-	private function _construct_where_clause($where_params){
3269
+	private function _construct_where_clause($where_params) {
3270 3270
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3271
-		if($SQL){
3272
-			return " WHERE ". $SQL;
3273
-		}else{
3271
+		if ($SQL) {
3272
+			return " WHERE ".$SQL;
3273
+		} else {
3274 3274
 			return '';
3275 3275
 		}
3276 3276
 	}
@@ -3285,11 +3285,11 @@  discard block
 block discarded – undo
3285 3285
 	 * @return string
3286 3286
 	 * @throws \EE_Error
3287 3287
 	 */
3288
-	private function _construct_having_clause($having_params){
3288
+	private function _construct_having_clause($having_params) {
3289 3289
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3290
-		if($SQL){
3291
-			return " HAVING ". $SQL;
3292
-		}else{
3290
+		if ($SQL) {
3291
+			return " HAVING ".$SQL;
3292
+		} else {
3293 3293
 			return '';
3294 3294
 		}
3295 3295
 
@@ -3303,16 +3303,16 @@  discard block
 block discarded – undo
3303 3303
 	 * @return EE_Model_Field_Base
3304 3304
 	 * @throws EE_Error
3305 3305
 	 */
3306
-	protected function _get_field_on_model($field_name,$model_name){
3306
+	protected function _get_field_on_model($field_name, $model_name) {
3307 3307
 		$model_class = 'EEM_'.$model_name;
3308 3308
 		$model_filepath = $model_class.".model.php";
3309
-		if ( is_readable($model_filepath)){
3309
+		if (is_readable($model_filepath)) {
3310 3310
 			require_once($model_filepath);
3311
-			$model_instance=call_user_func($model_name."::instance");
3311
+			$model_instance = call_user_func($model_name."::instance");
3312 3312
 			/* @var $model_instance EEM_Base */
3313 3313
 			return $model_instance->field_settings_for($field_name);
3314
-		}else{
3315
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3314
+		} else {
3315
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
3316 3316
 		}
3317 3317
 	}
3318 3318
 
@@ -3325,41 +3325,41 @@  discard block
 block discarded – undo
3325 3325
 	 * @throws EE_Error
3326 3326
 	 * @return string of SQL
3327 3327
 	 */
3328
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
3329
-		$where_clauses=array();
3330
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
3331
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
3332
-			if(in_array($query_param,$this->_logic_query_param_keys)){
3333
-				switch($query_param){
3328
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
3329
+		$where_clauses = array();
3330
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
3331
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
3332
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
3333
+				switch ($query_param) {
3334 3334
 					case 'not':
3335 3335
 					case 'NOT':
3336
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3336
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3337 3337
 						break;
3338 3338
 					case 'and':
3339 3339
 					case 'AND':
3340
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
3340
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
3341 3341
 						break;
3342 3342
 					case 'or':
3343 3343
 					case 'OR':
3344
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3344
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
3345 3345
 						break;
3346 3346
 				}
3347
-			}else{
3347
+			} else {
3348 3348
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3349 3349
 
3350 3350
 				//if it's not a normal field, maybe it's a custom selection?
3351
-				if( ! $field_obj){
3352
-					if(isset( $this->_custom_selections[$query_param][1])){
3351
+				if ( ! $field_obj) {
3352
+					if (isset($this->_custom_selections[$query_param][1])) {
3353 3353
 						$field_obj = $this->_custom_selections[$query_param][1];
3354
-					}else{
3355
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3354
+					} else {
3355
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
3356 3356
 					}
3357 3357
 				}
3358 3358
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
3359
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3359
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3360 3360
 			}
3361 3361
 		}
3362
-		return $where_clauses ? implode( $glue, $where_clauses ) : '';
3362
+		return $where_clauses ? implode($glue, $where_clauses) : '';
3363 3363
 	}
3364 3364
 
3365 3365
 
@@ -3370,18 +3370,18 @@  discard block
 block discarded – undo
3370 3370
 	 * @throws EE_Error
3371 3371
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
3372 3372
 	 */
3373
-	private function _deduce_column_name_from_query_param($query_param){
3373
+	private function _deduce_column_name_from_query_param($query_param) {
3374 3374
 		$field = $this->_deduce_field_from_query_param($query_param);
3375 3375
 
3376
-		if( $field ){
3377
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3378
-			return $table_alias_prefix . $field->get_qualified_column();
3379
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3376
+		if ($field) {
3377
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
3378
+			return $table_alias_prefix.$field->get_qualified_column();
3379
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
3380 3380
 			//maybe it's custom selection item?
3381 3381
 			//if so, just use it as the "column name"
3382 3382
 			return $query_param;
3383
-		}else{
3384
-			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
3383
+		} else {
3384
+			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"), $query_param, implode(",", $this->_custom_selections)));
3385 3385
 		}
3386 3386
 	}
3387 3387
 
@@ -3393,11 +3393,11 @@  discard block
 block discarded – undo
3393 3393
 	 * @param string $condition_query_param_key
3394 3394
 	 * @return string
3395 3395
 	 */
3396
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
3396
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
3397 3397
 		$pos_of_star = strpos($condition_query_param_key, '*');
3398
-		if($pos_of_star === FALSE){
3398
+		if ($pos_of_star === FALSE) {
3399 3399
 			return $condition_query_param_key;
3400
-		}else{
3400
+		} else {
3401 3401
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3402 3402
 			return $condition_query_param_sans_star;
3403 3403
 		}
@@ -3412,12 +3412,12 @@  discard block
 block discarded – undo
3412 3412
 	 * @throws EE_Error
3413 3413
 	 * @return string
3414 3414
 	 */
3415
-	private function _construct_op_and_value($op_and_value, $field_obj){
3416
-		if ( is_array( $op_and_value ) ) {
3417
-			$operator = isset( $op_and_value[0] ) ? $this->_prepare_operator_for_sql( $op_and_value[0] ) : null;
3418
-			if ( ! $operator ) {
3415
+	private function _construct_op_and_value($op_and_value, $field_obj) {
3416
+		if (is_array($op_and_value)) {
3417
+			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
3418
+			if ( ! $operator) {
3419 3419
 				$php_array_like_string = array();
3420
-				foreach ( $op_and_value as $key => $value ) {
3420
+				foreach ($op_and_value as $key => $value) {
3421 3421
 					$php_array_like_string[] = "$key=>$value";
3422 3422
 				}
3423 3423
 				throw new EE_Error(
@@ -3426,27 +3426,27 @@  discard block
 block discarded – undo
3426 3426
 							"You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))",
3427 3427
 							"event_espresso"
3428 3428
 						),
3429
-						implode( ",", $php_array_like_string )
3429
+						implode(",", $php_array_like_string)
3430 3430
 					)
3431 3431
 				);
3432 3432
 			}
3433
-			$value = isset( $op_and_value[1] ) ? $op_and_value[1] : null;
3433
+			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3434 3434
 		} else {
3435 3435
 			$operator = '=';
3436 3436
 			$value = $op_and_value;
3437 3437
 		}
3438 3438
 		//check to see if the value is actually another field
3439
-		if ( is_array( $op_and_value ) && isset( $op_and_value[2] ) && $op_and_value[2] == true ) {
3440
-			return $operator . SP . $this->_deduce_column_name_from_query_param( $value );
3441
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3439
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
3440
+			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3441
+		} elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
3442 3442
 			//in this case, the value should be an array, or at least a comma-separated list
3443 3443
 			//it will need to handle a little differently
3444
-			$cleaned_value = $this->_construct_in_value( $value, $field_obj );
3444
+			$cleaned_value = $this->_construct_in_value($value, $field_obj);
3445 3445
 			//note: $cleaned_value has already been run through $wpdb->prepare()
3446
-			return $operator . SP . $cleaned_value;
3447
-		} elseif ( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3446
+			return $operator.SP.$cleaned_value;
3447
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
3448 3448
 			//the value should be an array with count of two.
3449
-			if ( count( $value ) !== 2 ) {
3449
+			if (count($value) !== 2) {
3450 3450
 				throw new EE_Error(
3451 3451
 					sprintf(
3452 3452
 						__(
@@ -3457,10 +3457,10 @@  discard block
 block discarded – undo
3457 3457
 					)
3458 3458
 				);
3459 3459
 			}
3460
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3461
-			return $operator . SP . $cleaned_value;
3462
-		} elseif ( in_array( $operator, $this->_null_style_operators ) ) {
3463
-			if ( $value !== null ) {
3460
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
3461
+			return $operator.SP.$cleaned_value;
3462
+		} elseif (in_array($operator, $this->_null_style_operators)) {
3463
+			if ($value !== null) {
3464 3464
 				throw new EE_Error(
3465 3465
 					sprintf(
3466 3466
 						__(
@@ -3473,13 +3473,13 @@  discard block
 block discarded – undo
3473 3473
 				);
3474 3474
 			}
3475 3475
 			return $operator;
3476
-		} elseif ( $operator === 'LIKE' && ! is_array( $value ) ) {
3476
+		} elseif ($operator === 'LIKE' && ! is_array($value)) {
3477 3477
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3478 3478
 			//remove other junk. So just treat it as a string.
3479
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, '%s' );
3480
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3481
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, $field_obj );
3482
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3479
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3480
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3481
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
3482
+		} elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3483 3483
 			throw new EE_Error(
3484 3484
 				sprintf(
3485 3485
 					__(
@@ -3490,7 +3490,7 @@  discard block
 block discarded – undo
3490 3490
 					$operator
3491 3491
 				)
3492 3492
 			);
3493
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3493
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
3494 3494
 			throw new EE_Error(
3495 3495
 				sprintf(
3496 3496
 					__(
@@ -3508,7 +3508,7 @@  discard block
 block discarded – undo
3508 3508
 						"It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all",
3509 3509
 						"event_espresso"
3510 3510
 					),
3511
-					http_build_query( $op_and_value )
3511
+					http_build_query($op_and_value)
3512 3512
 				)
3513 3513
 			);
3514 3514
 		}
@@ -3524,12 +3524,12 @@  discard block
 block discarded – undo
3524 3524
 	 * @return string
3525 3525
 	 * @throws \EE_Error
3526 3526
 	 */
3527
-	public function _construct_between_value( $values, $field_obj ) {
3527
+	public function _construct_between_value($values, $field_obj) {
3528 3528
 		$cleaned_values = array();
3529
-		foreach ( $values as $value ) {
3530
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3529
+		foreach ($values as $value) {
3530
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3531 3531
 		}
3532
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
3532
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
3533 3533
 	}
3534 3534
 
3535 3535
 
@@ -3546,26 +3546,26 @@  discard block
 block discarded – undo
3546 3546
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
3547 3547
 	 * @throws \EE_Error
3548 3548
 	 */
3549
-	public function _construct_in_value($values,  $field_obj){
3549
+	public function _construct_in_value($values, $field_obj) {
3550 3550
 		//check if the value is a CSV list
3551
-		if(is_string($values)){
3551
+		if (is_string($values)) {
3552 3552
 			//in which case, turn it into an array
3553
-			$values = explode(",",$values);
3553
+			$values = explode(",", $values);
3554 3554
 		}
3555 3555
 		$cleaned_values = array();
3556
-		foreach($values as $value){
3557
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3556
+		foreach ($values as $value) {
3557
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3558 3558
 		}
3559 3559
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
3560 3560
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
3561 3561
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
3562
-		if(empty($cleaned_values)){
3562
+		if (empty($cleaned_values)) {
3563 3563
 			$all_fields = $this->field_settings();
3564 3564
 			$a_field = array_shift($all_fields);
3565 3565
 			$main_table = $this->_get_main_table();
3566 3566
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
3567 3567
 		}
3568
-		return "(".implode(",",$cleaned_values).")";
3568
+		return "(".implode(",", $cleaned_values).")";
3569 3569
 	}
3570 3570
 
3571 3571
 
@@ -3577,16 +3577,16 @@  discard block
 block discarded – undo
3577 3577
 	 * @throws EE_Error
3578 3578
 	 * @return false|null|string
3579 3579
 	 */
3580
-	private function _wpdb_prepare_using_field($value,$field_obj){
3580
+	private function _wpdb_prepare_using_field($value, $field_obj) {
3581 3581
 		/** @type WPDB $wpdb */
3582 3582
 		global $wpdb;
3583
-		if($field_obj instanceof EE_Model_Field_Base){
3584
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3585
-		}else{//$field_obj should really just be a data type
3586
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3587
-				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
3583
+		if ($field_obj instanceof EE_Model_Field_Base) {
3584
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
3585
+		} else {//$field_obj should really just be a data type
3586
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
3587
+				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"), $field_obj, implode(",", $this->_valid_wpdb_data_types)));
3588 3588
 			}
3589
-			return $wpdb->prepare($field_obj,$value);
3589
+			return $wpdb->prepare($field_obj, $value);
3590 3590
 		}
3591 3591
 	}
3592 3592
 
@@ -3598,27 +3598,27 @@  discard block
 block discarded – undo
3598 3598
 	 * @throws EE_Error
3599 3599
 	 * @return EE_Model_Field_Base
3600 3600
 	 */
3601
-	protected function _deduce_field_from_query_param($query_param_name){
3601
+	protected function _deduce_field_from_query_param($query_param_name) {
3602 3602
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
3603 3603
 		//which will help us find the database table and column
3604 3604
 
3605
-		$query_param_parts = explode(".",$query_param_name);
3606
-		if(empty($query_param_parts)){
3607
-			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name));
3605
+		$query_param_parts = explode(".", $query_param_name);
3606
+		if (empty($query_param_parts)) {
3607
+			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name));
3608 3608
 		}
3609 3609
 		$number_of_parts = count($query_param_parts);
3610
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
3611
-		if($number_of_parts === 1){
3610
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
3611
+		if ($number_of_parts === 1) {
3612 3612
 			$field_name = $last_query_param_part;
3613 3613
 			$model_obj = $this;
3614
-		}else{// $number_of_parts >= 2
3614
+		} else {// $number_of_parts >= 2
3615 3615
 			//the last part is the column name, and there are only 2parts. therefore...
3616 3616
 			$field_name = $last_query_param_part;
3617
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3617
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
3618 3618
 		}
3619
-		try{
3619
+		try {
3620 3620
 			return $model_obj->field_settings_for($field_name);
3621
-		}catch(EE_Error $e){
3621
+		} catch (EE_Error $e) {
3622 3622
 			return null;
3623 3623
 		}
3624 3624
 	}
@@ -3632,13 +3632,13 @@  discard block
 block discarded – undo
3632 3632
 	 * @throws EE_Error
3633 3633
 	 * @return string
3634 3634
 	 */
3635
-	public function _get_qualified_column_for_field($field_name){
3635
+	public function _get_qualified_column_for_field($field_name) {
3636 3636
 		$all_fields = $this->field_settings();
3637 3637
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3638
-		if($field){
3638
+		if ($field) {
3639 3639
 			return $field->get_qualified_column();
3640
-		}else{
3641
-			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
3640
+		} else {
3641
+			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.", 'event_espresso'), $field_name, get_class($this)));
3642 3642
 		}
3643 3643
 	}
3644 3644
 
@@ -3652,17 +3652,17 @@  discard block
 block discarded – undo
3652 3652
 	 * @param  mixed|string $limit The limit for this select
3653 3653
 	 * @return string                The final select join element for the query.
3654 3654
 	 */
3655
-	public function _construct_limit_join_select( $table_alias, $limit ) {
3655
+	public function _construct_limit_join_select($table_alias, $limit) {
3656 3656
 		$SQL = '';
3657
-		foreach ( $this->_tables as $table_obj ) {
3658
-			if ( $table_obj instanceof EE_Primary_Table ) {
3657
+		foreach ($this->_tables as $table_obj) {
3658
+			if ($table_obj instanceof EE_Primary_Table) {
3659 3659
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3660
-					? $table_obj->get_select_join_limit( $limit )
3661
-					: SP . $table_obj->get_table_name() . " AS " . $table_obj->get_table_alias() . SP;
3662
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
3660
+					? $table_obj->get_select_join_limit($limit)
3661
+					: SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3662
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
3663 3663
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3664
-					? $table_obj->get_select_join_limit_join( $limit )
3665
-					: SP . $table_obj->get_join_sql( $table_alias ) . SP;
3664
+					? $table_obj->get_select_join_limit_join($limit)
3665
+					: SP.$table_obj->get_join_sql($table_alias).SP;
3666 3666
 			}
3667 3667
 		}
3668 3668
 		return $SQL;
@@ -3677,7 +3677,7 @@  discard block
 block discarded – undo
3677 3677
 	 * @return string SQL
3678 3678
 	 * @throws \EE_Error
3679 3679
 	 */
3680
-	public function _construct_internal_join(){
3680
+	public function _construct_internal_join() {
3681 3681
 		$SQL = $this->_get_main_table()->get_table_sql();
3682 3682
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
3683 3683
 		return $SQL;
@@ -3698,17 +3698,17 @@  discard block
 block discarded – undo
3698 3698
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
3699 3699
 	 * @return string
3700 3700
 	 */
3701
-	public function _construct_internal_join_to_table_with_alias($alias_prefixed){
3701
+	public function _construct_internal_join_to_table_with_alias($alias_prefixed) {
3702 3702
 		$SQL = '';
3703 3703
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
3704
-		foreach($this->_tables as $table_obj){
3705
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
3706
-				if($alias_sans_prefix === $table_obj->get_table_alias()){
3704
+		foreach ($this->_tables as $table_obj) {
3705
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
3706
+				if ($alias_sans_prefix === $table_obj->get_table_alias()) {
3707 3707
 					//so we're joining to this table, meaning the table is already in
3708 3708
 					//the FROM statement, BUT the primary table isn't. So we want
3709 3709
 					//to add the inverse join sql
3710 3710
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3711
-				}else{
3711
+				} else {
3712 3712
 					//just add a regular JOIN to this table from the primary table
3713 3713
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3714 3714
 				}
@@ -3722,9 +3722,9 @@  discard block
 block discarded – undo
3722 3722
 	 * This should be a growing array of keys being table-columns (eg 'EVT_ID' and 'Event.EVT_ID'), and values being their data type (eg, '%s', '%d', etc)
3723 3723
 	 * @return array
3724 3724
 	 */
3725
-	public function _get_data_types(){
3725
+	public function _get_data_types() {
3726 3726
 		$data_types = array();
3727
-		foreach( $this->field_settings() as $field_obj){
3727
+		foreach ($this->field_settings() as $field_obj) {
3728 3728
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
3729 3729
 			/** @var $field_obj EE_Model_Field_Base */
3730 3730
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -3740,10 +3740,10 @@  discard block
 block discarded – undo
3740 3740
 	 * @throws EE_Error
3741 3741
 	 * @return EEM_Base
3742 3742
 	 */
3743
-	public function get_related_model_obj($model_name){
3743
+	public function get_related_model_obj($model_name) {
3744 3744
 		$model_classname = "EEM_".$model_name;
3745
-		if(!class_exists($model_classname)){
3746
-			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s",'event_espresso'),$model_name,$model_classname));
3745
+		if ( ! class_exists($model_classname)) {
3746
+			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s", 'event_espresso'), $model_name, $model_classname));
3747 3747
 		}
3748 3748
 		return call_user_func($model_classname."::instance");
3749 3749
 	}
@@ -3753,7 +3753,7 @@  discard block
 block discarded – undo
3753 3753
 	 * Returns the array of EE_ModelRelations for this model.
3754 3754
 	 * @return EE_Model_Relation_Base[]
3755 3755
 	 */
3756
-	public function relation_settings(){
3756
+	public function relation_settings() {
3757 3757
 		return $this->_model_relations;
3758 3758
 	}
3759 3759
 
@@ -3763,10 +3763,10 @@  discard block
 block discarded – undo
3763 3763
 	 * (Eg, without an event, datetimes have little purpose.)
3764 3764
 	 * @return EE_Belongs_To_Relation[]
3765 3765
 	 */
3766
-	public function belongs_to_relations(){
3766
+	public function belongs_to_relations() {
3767 3767
 		$belongs_to_relations = array();
3768
-		foreach($this->relation_settings() as $model_name => $relation_obj){
3769
-			if($relation_obj instanceof EE_Belongs_To_Relation){
3768
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
3769
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
3770 3770
 				$belongs_to_relations[$model_name] = $relation_obj;
3771 3771
 			}
3772 3772
 		}
@@ -3781,15 +3781,15 @@  discard block
 block discarded – undo
3781 3781
 	 * @throws EE_Error
3782 3782
 	 * @return EE_Model_Relation_Base
3783 3783
 	 */
3784
-	public function related_settings_for($relation_name){
3785
-		$relatedModels=$this->relation_settings();
3786
-		if(!array_key_exists($relation_name,$relatedModels)){
3784
+	public function related_settings_for($relation_name) {
3785
+		$relatedModels = $this->relation_settings();
3786
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
3787 3787
 			throw new EE_Error(
3788 3788
 				sprintf(
3789
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
3789
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
3790 3790
 					$relation_name,
3791 3791
 					$this->_get_class_name(),
3792
-					implode( ', ', array_keys( $relatedModels ))
3792
+					implode(', ', array_keys($relatedModels))
3793 3793
 				)
3794 3794
 			);
3795 3795
 		}
@@ -3804,10 +3804,10 @@  discard block
 block discarded – undo
3804 3804
 	 * @throws EE_Error
3805 3805
 	 * @return EE_Model_Field_Base
3806 3806
 	 */
3807
-	public function field_settings_for($fieldName){
3808
-		$fieldSettings=$this->field_settings(true);
3809
-		if( ! array_key_exists($fieldName,$fieldSettings)){
3810
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
3807
+	public function field_settings_for($fieldName) {
3808
+		$fieldSettings = $this->field_settings(true);
3809
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
3810
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
3811 3811
 		}
3812 3812
 		return $fieldSettings[$fieldName];
3813 3813
 	}
@@ -3817,11 +3817,11 @@  discard block
 block discarded – undo
3817 3817
 	 * @param string $fieldName a key in the model's _field_settings array
3818 3818
 	 * @return boolean
3819 3819
 	 */
3820
-	public function has_field($fieldName){
3820
+	public function has_field($fieldName) {
3821 3821
 		$fieldSettings = $this->field_settings(true);
3822
-		if( isset($fieldSettings[$fieldName])){
3822
+		if (isset($fieldSettings[$fieldName])) {
3823 3823
 			return true;
3824
-		}else{
3824
+		} else {
3825 3825
 			return false;
3826 3826
 		}
3827 3827
 	}
@@ -3831,11 +3831,11 @@  discard block
 block discarded – undo
3831 3831
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3832 3832
 	 * @return boolean
3833 3833
 	 */
3834
-	public function has_relation($relation_name){
3834
+	public function has_relation($relation_name) {
3835 3835
 		$relations = $this->relation_settings();
3836
-		if(isset($relations[$relation_name])){
3836
+		if (isset($relations[$relation_name])) {
3837 3837
 			return true;
3838
-		}else{
3838
+		} else {
3839 3839
 			return false;
3840 3840
 		}
3841 3841
 	}
@@ -3847,7 +3847,7 @@  discard block
 block discarded – undo
3847 3847
 	 * @param $field_obj
3848 3848
 	 * @return EE_Model_Field_Base
3849 3849
 	 */
3850
-	public function is_primary_key_field( $field_obj ){
3850
+	public function is_primary_key_field($field_obj) {
3851 3851
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3852 3852
 	}
3853 3853
 
@@ -3859,16 +3859,16 @@  discard block
 block discarded – undo
3859 3859
 	 * @return EE_Model_Field_Base
3860 3860
 	 * @throws EE_Error
3861 3861
 	 */
3862
-	public function get_primary_key_field(){
3863
-		if( $this->_primary_key_field === NULL ){
3864
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3865
-				if( $this->is_primary_key_field( $field_obj )){
3862
+	public function get_primary_key_field() {
3863
+		if ($this->_primary_key_field === NULL) {
3864
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3865
+				if ($this->is_primary_key_field($field_obj)) {
3866 3866
 					$this->_primary_key_field = $field_obj;
3867 3867
 					break;
3868 3868
 				}
3869 3869
 			}
3870
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3871
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3870
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3871
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3872 3872
 			}
3873 3873
 		}
3874 3874
 		return $this->_primary_key_field;
@@ -3881,12 +3881,12 @@  discard block
 block discarded – undo
3881 3881
 	 * Internally does some caching.
3882 3882
 	 * @return boolean
3883 3883
 	 */
3884
-	public function has_primary_key_field(){
3885
-		if($this->_has_primary_key_field === null){
3886
-			try{
3884
+	public function has_primary_key_field() {
3885
+		if ($this->_has_primary_key_field === null) {
3886
+			try {
3887 3887
 				$this->get_primary_key_field();
3888 3888
 				$this->_has_primary_key_field = true;
3889
-			}catch(EE_Error $e){
3889
+			} catch (EE_Error $e) {
3890 3890
 				$this->_has_primary_key_field = false;
3891 3891
 			}
3892 3892
 		}
@@ -3900,9 +3900,9 @@  discard block
 block discarded – undo
3900 3900
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3901 3901
 	 * @return EE_Model_Field_Base or null if none is found
3902 3902
 	 */
3903
-	public function get_a_field_of_type($field_class_name){
3904
-		foreach($this->field_settings() as $field){
3905
-			if( $field instanceof $field_class_name ){
3903
+	public function get_a_field_of_type($field_class_name) {
3904
+		foreach ($this->field_settings() as $field) {
3905
+			if ($field instanceof $field_class_name) {
3906 3906
 				return $field;
3907 3907
 			}
3908 3908
 		}
@@ -3916,22 +3916,22 @@  discard block
 block discarded – undo
3916 3916
 	 * @return EE_Foreign_Key_Field_Base
3917 3917
 	 * @throws EE_Error
3918 3918
 	 */
3919
-	public function get_foreign_key_to($model_name){
3920
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3921
-			foreach($this->field_settings() as $field){
3922
-				if(
3919
+	public function get_foreign_key_to($model_name) {
3920
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3921
+			foreach ($this->field_settings() as $field) {
3922
+				if (
3923 3923
 					$field instanceof EE_Foreign_Key_Field_Base
3924
-					&& in_array($model_name,$field->get_model_names_pointed_to() )
3924
+					&& in_array($model_name, $field->get_model_names_pointed_to())
3925 3925
 				) {
3926
-					$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3926
+					$this->_cache_foreign_key_to_fields[$model_name] = $field;
3927 3927
 					break;
3928 3928
 				}
3929 3929
 			}
3930
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3931
-				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s",'event_espresso'),$model_name,get_class($this)));
3930
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3931
+				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s", 'event_espresso'), $model_name, get_class($this)));
3932 3932
 			}
3933 3933
 		}
3934
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3934
+		return $this->_cache_foreign_key_to_fields[$model_name];
3935 3935
 	}
3936 3936
 
3937 3937
 
@@ -3942,7 +3942,7 @@  discard block
 block discarded – undo
3942 3942
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3943 3943
 	 * @return EE_Table_Base
3944 3944
 	 */
3945
-	public function get_table_for_alias($table_alias){
3945
+	public function get_table_for_alias($table_alias) {
3946 3946
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
3947 3947
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
3948 3948
 	}
@@ -3955,25 +3955,25 @@  discard block
 block discarded – undo
3955 3955
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
3956 3956
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
3957 3957
 	 */
3958
-	public function field_settings($include_db_only_fields = false){
3959
-		if( $include_db_only_fields ){
3960
-			if( $this->_cached_fields === NULL ){
3958
+	public function field_settings($include_db_only_fields = false) {
3959
+		if ($include_db_only_fields) {
3960
+			if ($this->_cached_fields === NULL) {
3961 3961
 				$this->_cached_fields = array();
3962
-				foreach($this->_fields as $fields_corresponding_to_table){
3963
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3964
-						$this->_cached_fields[$field_name]=$field_obj;
3962
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3963
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3964
+						$this->_cached_fields[$field_name] = $field_obj;
3965 3965
 					}
3966 3966
 				}
3967 3967
 			}
3968 3968
 			return $this->_cached_fields;
3969
-		}else{
3970
-			if( $this->_cached_fields_non_db_only === NULL ){
3969
+		} else {
3970
+			if ($this->_cached_fields_non_db_only === NULL) {
3971 3971
 				$this->_cached_fields_non_db_only = array();
3972
-				foreach($this->_fields as $fields_corresponding_to_table){
3973
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3972
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3973
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3974 3974
 						/** @var $field_obj EE_Model_Field_Base */
3975
-						if( ! $field_obj->is_db_only_field() ){
3976
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
3975
+						if ( ! $field_obj->is_db_only_field()) {
3976
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
3977 3977
 						}
3978 3978
 					}
3979 3979
 				}
@@ -3992,60 +3992,60 @@  discard block
 block discarded – undo
3992 3992
 	 * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
3993 3993
 	 * @throws \EE_Error
3994 3994
 	 */
3995
-	protected function _create_objects( $rows = array() ) {
3996
-		$array_of_objects=array();
3997
-		if(empty($rows)){
3995
+	protected function _create_objects($rows = array()) {
3996
+		$array_of_objects = array();
3997
+		if (empty($rows)) {
3998 3998
 			return array();
3999 3999
 		}
4000 4000
 		$count_if_model_has_no_primary_key = 0;
4001 4001
 		$has_primary_key = $this->has_primary_key_field();
4002 4002
 		$primary_key_field = $has_primary_key ? $this->get_primary_key_field() : null;
4003
-		foreach ( (array)$rows as $row ) {
4004
-			if(empty($row)){
4003
+		foreach ((array) $rows as $row) {
4004
+			if (empty($row)) {
4005 4005
 				//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
4006 4006
 				return array();
4007 4007
 			}
4008 4008
 			//check if we've already set this object in the results array,
4009 4009
 			//in which case there's no need to process it further (again)
4010
-			if( $has_primary_key ) {
4010
+			if ($has_primary_key) {
4011 4011
 				$table_pk_value = $this->_get_column_value_with_table_alias_or_not(
4012 4012
 					$row,
4013 4013
 					$primary_key_field->get_qualified_column(),
4014 4014
 					$primary_key_field->get_table_column()
4015 4015
 				);
4016
-				if( $table_pk_value && isset( $array_of_objects[ $table_pk_value ] ) ) {
4016
+				if ($table_pk_value && isset($array_of_objects[$table_pk_value])) {
4017 4017
 					continue;
4018 4018
 				}
4019 4019
 			}
4020 4020
 			$classInstance = $this->instantiate_class_from_array_or_object($row);
4021
-			if( ! $classInstance ) {
4021
+			if ( ! $classInstance) {
4022 4022
 				throw new EE_Error(
4023 4023
 					sprintf(
4024
-						__( 'Could not create instance of class %s from row %s', 'event_espresso' ),
4024
+						__('Could not create instance of class %s from row %s', 'event_espresso'),
4025 4025
 						$this->get_this_model_name(),
4026
-						http_build_query( $row )
4026
+						http_build_query($row)
4027 4027
 					)
4028 4028
 				);
4029 4029
 			}
4030 4030
 			//set the timezone on the instantiated objects
4031
-			$classInstance->set_timezone( $this->_timezone );
4031
+			$classInstance->set_timezone($this->_timezone);
4032 4032
 			//make sure if there is any timezone setting present that we set the timezone for the object
4033 4033
 			$key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++;
4034
-			$array_of_objects[ $key ] = $classInstance;
4034
+			$array_of_objects[$key] = $classInstance;
4035 4035
 			//also, for all the relations of type BelongsTo, see if we can cache
4036 4036
 			//those related models
4037 4037
 			//(we could do this for other relations too, but if there are conditions
4038 4038
 			//that filtered out some fo the results, then we'd be caching an incomplete set
4039 4039
 			//so it requires a little more thought than just caching them immediately...)
4040
-			foreach($this->_model_relations as $modelName => $relation_obj){
4041
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
4040
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
4041
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
4042 4042
 					//check if this model's INFO is present. If so, cache it on the model
4043 4043
 					$other_model = $relation_obj->get_other_model();
4044 4044
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
4045 4045
 					//if we managed to make a model object from the results, cache it on the main model object
4046
-					if( $other_model_obj_maybe ){
4046
+					if ($other_model_obj_maybe) {
4047 4047
 						//set timezone on these other model objects if they are present
4048
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
4048
+						$other_model_obj_maybe->set_timezone($this->_timezone);
4049 4049
 						$classInstance->cache($modelName, $other_model_obj_maybe);
4050 4050
 					}
4051 4051
 				}
@@ -4066,12 +4066,12 @@  discard block
 block discarded – undo
4066 4066
 
4067 4067
 		$this_model_fields_and_values = array();
4068 4068
 		//setup the row using default values;
4069
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
4069
+		foreach ($this->field_settings() as $field_name => $field_obj) {
4070 4070
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
4071 4071
 		}
4072 4072
 
4073 4073
 		$className = $this->_get_class_name();
4074
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
4074
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
4075 4075
 
4076 4076
 		return $classInstance;
4077 4077
 	}
@@ -4084,45 +4084,45 @@  discard block
 block discarded – undo
4084 4084
 	 * @return EE_Base_Class
4085 4085
 	 * @throws \EE_Error
4086 4086
 	 */
4087
-	public function instantiate_class_from_array_or_object($cols_n_values){
4088
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
4089
-			$cols_n_values = get_object_vars( $cols_n_values );
4087
+	public function instantiate_class_from_array_or_object($cols_n_values) {
4088
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
4089
+			$cols_n_values = get_object_vars($cols_n_values);
4090 4090
 		}
4091 4091
 		$primary_key = NULL;
4092 4092
 		//make sure the array only has keys that are fields/columns on this model
4093
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4094
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
4095
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
4093
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4094
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
4095
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
4096 4096
 		}
4097
-		$className=$this->_get_class_name();
4097
+		$className = $this->_get_class_name();
4098 4098
 
4099 4099
 		//check we actually found results that we can use to build our model object
4100 4100
 		//if not, return null
4101
-		if( $this->has_primary_key_field()){
4102
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
4101
+		if ($this->has_primary_key_field()) {
4102
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
4103 4103
 				return NULL;
4104 4104
 			}
4105
-		}else if($this->unique_indexes()){
4105
+		} else if ($this->unique_indexes()) {
4106 4106
 			$first_column = reset($this_model_fields_n_values);
4107
-			if(empty($first_column)){
4107
+			if (empty($first_column)) {
4108 4108
 				return NULL;
4109 4109
 			}
4110 4110
 		}
4111 4111
 
4112 4112
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
4113
-		if ( $primary_key){
4114
-			$classInstance = $this->get_from_entity_map( $primary_key );
4115
-			if( ! $classInstance) {
4116
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4113
+		if ($primary_key) {
4114
+			$classInstance = $this->get_from_entity_map($primary_key);
4115
+			if ( ! $classInstance) {
4116
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4117 4117
 				// add this new object to the entity map
4118
-				$classInstance = $this->add_to_entity_map( $classInstance );
4118
+				$classInstance = $this->add_to_entity_map($classInstance);
4119 4119
 			}
4120
-		}else{
4121
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4120
+		} else {
4121
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4122 4122
 		}
4123 4123
 
4124 4124
 			//it is entirely possible that the instantiated class object has a set timezone_string db field and has set it's internal _timezone property accordingly (see new_instance_from_db in model objects particularly EE_Event for example).  In this case, we want to make sure the model object doesn't have its timezone string overwritten by any timezone property currently set here on the model so, we intentionally override the model _timezone property with the model_object timezone property.
4125
-		$this->set_timezone( $classInstance->get_timezone() );
4125
+		$this->set_timezone($classInstance->get_timezone());
4126 4126
 		return $classInstance;
4127 4127
 	}
4128 4128
 	/**
@@ -4130,8 +4130,8 @@  discard block
 block discarded – undo
4130 4130
 	 * @param int|string $id the ID of the model object
4131 4131
 	 * @return EE_Base_Class
4132 4132
 	 */
4133
-	public function get_from_entity_map( $id ){
4134
-		return isset( $this->_entity_map[ $id ] ) ? $this->_entity_map[ $id ] : NULL;
4133
+	public function get_from_entity_map($id) {
4134
+		return isset($this->_entity_map[$id]) ? $this->_entity_map[$id] : NULL;
4135 4135
 	}
4136 4136
 
4137 4137
 
@@ -4150,21 +4150,21 @@  discard block
 block discarded – undo
4150 4150
 	 * @throws EE_Error
4151 4151
 	 * @return \EE_Base_Class
4152 4152
 	 */
4153
-	public function add_to_entity_map( EE_Base_Class $object) {
4153
+	public function add_to_entity_map(EE_Base_Class $object) {
4154 4154
 		$className = $this->_get_class_name();
4155
-		if( ! $object instanceof $className ){
4156
-			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"),is_object( $object ) ? get_class( $object ) : $object, $className ) );
4155
+		if ( ! $object instanceof $className) {
4156
+			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"), is_object($object) ? get_class($object) : $object, $className));
4157 4157
 		}
4158 4158
 		/** @var $object EE_Base_Class */
4159
-		if ( ! $object->ID() ){
4160
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
4159
+		if ( ! $object->ID()) {
4160
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
4161 4161
 		}
4162 4162
 		// double check it's not already there
4163
-		$classInstance = $this->get_from_entity_map( $object->ID() );
4164
-		if ( $classInstance ) {
4163
+		$classInstance = $this->get_from_entity_map($object->ID());
4164
+		if ($classInstance) {
4165 4165
 			return $classInstance;
4166 4166
 		} else {
4167
-			$this->_entity_map[ $object->ID() ] = $object;
4167
+			$this->_entity_map[$object->ID()] = $object;
4168 4168
 			return $object;
4169 4169
 		}
4170 4170
 	}
@@ -4177,8 +4177,8 @@  discard block
 block discarded – undo
4177 4177
 	 * @param array $cols_n_values
4178 4178
 	 * @return array
4179 4179
 	 */
4180
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
4181
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4180
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4181
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4182 4182
 	}
4183 4183
 
4184 4184
 
@@ -4191,23 +4191,23 @@  discard block
 block discarded – undo
4191 4191
 	 * @param string $cols_n_values
4192 4192
 	 * @return array
4193 4193
 	 */
4194
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
4194
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4195 4195
 		$this_model_fields_n_values = array();
4196
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
4197
-			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column() );
4196
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
4197
+			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column());
4198 4198
 			//there is a primary key on this table and its not set. Use defaults for all its columns
4199
-			if( $table_pk_value === null && $table_obj->get_pk_column() ){
4200
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4201
-					if( ! $field_obj->is_db_only_field() ){
4199
+			if ($table_pk_value === null && $table_obj->get_pk_column()) {
4200
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4201
+					if ( ! $field_obj->is_db_only_field()) {
4202 4202
 						//prepare field as if its coming from db
4203
-						$prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() );
4204
-						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
4203
+						$prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value());
4204
+						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value);
4205 4205
 					}
4206 4206
 				}
4207
-			}else{
4207
+			} else {
4208 4208
 				//the table's rows existed. Use their values
4209
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4210
-					if( ! $field_obj->is_db_only_field() ){
4209
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4210
+					if ( ! $field_obj->is_db_only_field()) {
4211 4211
 						$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not(
4212 4212
 							$cols_n_values, $field_obj->get_qualified_column(),
4213 4213
 							$field_obj->get_table_column()
@@ -4227,15 +4227,15 @@  discard block
 block discarded – undo
4227 4227
 	 * @param $regular_column
4228 4228
 	 * @return null
4229 4229
 	 */
4230
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
4230
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
4231 4231
 		$value = null;
4232 4232
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
4233 4233
 		//does the field on the model relate to this column retrieved from the db?
4234 4234
 		//or is it a db-only field? (not relating to the model)
4235
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
4236
-			$value = $cols_n_values[ $qualified_column ];
4237
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
4238
-			$value = $cols_n_values[ $regular_column ];
4235
+		if (isset($cols_n_values[$qualified_column])) {
4236
+			$value = $cols_n_values[$qualified_column];
4237
+		}elseif (isset($cols_n_values[$regular_column])) {
4238
+			$value = $cols_n_values[$regular_column];
4239 4239
 		}
4240 4240
 		return $value;
4241 4241
 	}
@@ -4251,25 +4251,25 @@  discard block
 block discarded – undo
4251 4251
 	 * @return EE_Base_Class
4252 4252
 	 * @throws \EE_Error
4253 4253
 	 */
4254
-	public function refresh_entity_map_from_db( $id ){
4255
-		$obj_in_map = $this->get_from_entity_map( $id );
4256
-		if( $obj_in_map ){
4254
+	public function refresh_entity_map_from_db($id) {
4255
+		$obj_in_map = $this->get_from_entity_map($id);
4256
+		if ($obj_in_map) {
4257 4257
 			$wpdb_results = $this->_get_all_wpdb_results(
4258
-				array( array( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 )
4258
+				array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1)
4259 4259
 			);
4260
-			if( $wpdb_results && is_array( $wpdb_results ) ){
4261
-				$one_row = reset( $wpdb_results );
4262
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
4263
-					$obj_in_map->set_from_db( $field_name, $db_value );
4260
+			if ($wpdb_results && is_array($wpdb_results)) {
4261
+				$one_row = reset($wpdb_results);
4262
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
4263
+					$obj_in_map->set_from_db($field_name, $db_value);
4264 4264
 				}
4265 4265
 				//clear the cache of related model objects
4266
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4267
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4266
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4267
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4268 4268
 				}
4269 4269
 			}
4270 4270
 			return $obj_in_map;
4271
-		}else{
4272
-			return $this->get_one_by_ID( $id );
4271
+		} else {
4272
+			return $this->get_one_by_ID($id);
4273 4273
 		}
4274 4274
 	}
4275 4275
 
@@ -4287,24 +4287,24 @@  discard block
 block discarded – undo
4287 4287
 	 * @return \EE_Base_Class
4288 4288
 	 * @throws \EE_Error
4289 4289
 	 */
4290
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
4291
-		$obj_in_map = $this->get_from_entity_map( $id );
4292
-		if( $obj_in_map ){
4293
-			if( $replacing_model_obj instanceof EE_Base_Class ){
4294
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
4295
-					$obj_in_map->set( $field_name, $value );
4290
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
4291
+		$obj_in_map = $this->get_from_entity_map($id);
4292
+		if ($obj_in_map) {
4293
+			if ($replacing_model_obj instanceof EE_Base_Class) {
4294
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
4295
+					$obj_in_map->set($field_name, $value);
4296 4296
 				}
4297 4297
 				//make the model object in the entity map's cache match the $replacing_model_obj
4298
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4299
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4300
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
4301
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
4298
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4299
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4300
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
4301
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
4302 4302
 					}
4303 4303
 				}
4304 4304
 			}
4305 4305
 			return $obj_in_map;
4306
-		}else{
4307
-			$this->add_to_entity_map( $replacing_model_obj );
4306
+		} else {
4307
+			$this->add_to_entity_map($replacing_model_obj);
4308 4308
 			return $replacing_model_obj;
4309 4309
 		}
4310 4310
 	}
@@ -4317,7 +4317,7 @@  discard block
 block discarded – undo
4317 4317
 	 * require_once($this->_getClassName().".class.php");
4318 4318
 	 * @return string
4319 4319
 	 */
4320
-	private function _get_class_name(){
4320
+	private function _get_class_name() {
4321 4321
 		return "EE_".$this->get_this_model_name();
4322 4322
 	}
4323 4323
 
@@ -4330,8 +4330,8 @@  discard block
 block discarded – undo
4330 4330
 	 * @param int $quantity
4331 4331
 	 * @return string
4332 4332
 	 */
4333
-	public function item_name($quantity = 1){
4334
-		return (int)$quantity === 1 ? $this->singular_item : $this->plural_item;
4333
+	public function item_name($quantity = 1) {
4334
+		return (int) $quantity === 1 ? $this->singular_item : $this->plural_item;
4335 4335
 	}
4336 4336
 
4337 4337
 
@@ -4358,13 +4358,13 @@  discard block
 block discarded – undo
4358 4358
 	 * @throws EE_Error
4359 4359
 	 * @return mixed whatever the plugin which calls add_filter decides
4360 4360
 	 */
4361
-	public function __call($methodName,$args){
4362
-		$className=get_class($this);
4363
-		$tagName="FHEE__{$className}__{$methodName}";
4364
-		if(!has_filter($tagName)){
4361
+	public function __call($methodName, $args) {
4362
+		$className = get_class($this);
4363
+		$tagName = "FHEE__{$className}__{$methodName}";
4364
+		if ( ! has_filter($tagName)) {
4365 4365
 			throw new EE_Error(
4366 4366
 				sprintf(
4367
-					__( 'Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso' ),
4367
+					__('Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso'),
4368 4368
 					$methodName,
4369 4369
 					$className,
4370 4370
 					$tagName,
@@ -4373,7 +4373,7 @@  discard block
 block discarded – undo
4373 4373
 			);
4374 4374
 		}
4375 4375
 
4376
-		return apply_filters($tagName,null,$this,$args);
4376
+		return apply_filters($tagName, null, $this, $args);
4377 4377
 	}
4378 4378
 
4379 4379
 
@@ -4391,28 +4391,28 @@  discard block
 block discarded – undo
4391 4391
 	 * @throws EE_Error
4392 4392
 	 * @return EE_Base_Class
4393 4393
 	 */
4394
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
4394
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
4395 4395
 		$className = $this->_get_class_name();
4396
-		if ( $base_class_obj_or_id instanceof $className ) {
4396
+		if ($base_class_obj_or_id instanceof $className) {
4397 4397
 			$model_object = $base_class_obj_or_id;
4398 4398
 		} else {
4399 4399
 			$primary_key_field = $this->get_primary_key_field();
4400 4400
 			if (
4401 4401
 				$primary_key_field instanceof EE_Primary_Key_Int_Field
4402 4402
 				&& (
4403
-					is_int( $base_class_obj_or_id )
4404
-					|| is_string( $base_class_obj_or_id )
4403
+					is_int($base_class_obj_or_id)
4404
+					|| is_string($base_class_obj_or_id)
4405 4405
 				)
4406 4406
 			) {
4407 4407
 				// assume it's an ID.
4408 4408
 				// either a proper integer or a string representing an integer (eg "101" instead of 101)
4409
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4409
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4410 4410
 			} else if (
4411 4411
 				$primary_key_field instanceof EE_Primary_Key_String_Field
4412
-			    && is_string( $base_class_obj_or_id )
4412
+			    && is_string($base_class_obj_or_id)
4413 4413
 			) {
4414 4414
 				// assume its a string representation of the object
4415
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4415
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4416 4416
 			} else {
4417 4417
 				throw new EE_Error(
4418 4418
 					sprintf(
@@ -4422,12 +4422,12 @@  discard block
 block discarded – undo
4422 4422
 						),
4423 4423
 						$base_class_obj_or_id,
4424 4424
 						$this->_get_class_name(),
4425
-						print_r( $base_class_obj_or_id, true )
4425
+						print_r($base_class_obj_or_id, true)
4426 4426
 					)
4427 4427
 				);
4428 4428
 			}
4429 4429
 		}
4430
-		if ( $ensure_is_in_db && $model_object->ID() !== null ) {
4430
+		if ($ensure_is_in_db && $model_object->ID() !== null) {
4431 4431
 			$model_object->save();
4432 4432
 		}
4433 4433
 		return $model_object;
@@ -4443,19 +4443,19 @@  discard block
 block discarded – undo
4443 4443
 	 * @return int|string depending on the type of this model object's ID
4444 4444
 	 * @throws EE_Error
4445 4445
 	 */
4446
-	public function ensure_is_ID($base_class_obj_or_id){
4446
+	public function ensure_is_ID($base_class_obj_or_id) {
4447 4447
 		$className = $this->_get_class_name();
4448
-		if( $base_class_obj_or_id instanceof $className ){
4448
+		if ($base_class_obj_or_id instanceof $className) {
4449 4449
 			/** @var $base_class_obj_or_id EE_Base_Class */
4450 4450
 			$id = $base_class_obj_or_id->ID();
4451
-		}elseif(is_int($base_class_obj_or_id)){
4451
+		}elseif (is_int($base_class_obj_or_id)) {
4452 4452
 			//assume it's an ID
4453 4453
 			$id = $base_class_obj_or_id;
4454
-		}elseif(is_string($base_class_obj_or_id)){
4454
+		}elseif (is_string($base_class_obj_or_id)) {
4455 4455
 			//assume its a string representation of the object
4456 4456
 			$id = $base_class_obj_or_id;
4457
-		}else{
4458
-			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4457
+		} else {
4458
+			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true)));
4459 4459
 		}
4460 4460
 		return $id;
4461 4461
 	}
@@ -4478,14 +4478,14 @@  discard block
 block discarded – undo
4478 4478
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
4479 4479
 	 * @return void
4480 4480
 	 */
4481
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
4481
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
4482 4482
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
4483 4483
 	}
4484 4484
 	/**
4485 4485
 	 * Read comments for assume_values_already_prepared_by_model_object()
4486 4486
 	 * @return int
4487 4487
 	 */
4488
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4488
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
4489 4489
 		return $this->_values_already_prepared_by_model_object;
4490 4490
 	}
4491 4491
 
@@ -4493,17 +4493,17 @@  discard block
 block discarded – undo
4493 4493
 	 * Gets all the indexes on this model
4494 4494
 	 * @return EE_Index[]
4495 4495
 	 */
4496
-	public function indexes(){
4496
+	public function indexes() {
4497 4497
 		return $this->_indexes;
4498 4498
 	}
4499 4499
 	/**
4500 4500
 	 * Gets all the Unique Indexes on this model
4501 4501
 	 * @return EE_Unique_Index[]
4502 4502
 	 */
4503
-	public function unique_indexes(){
4503
+	public function unique_indexes() {
4504 4504
 		$unique_indexes = array();
4505
-		foreach($this->_indexes as $name => $index){
4506
-			if($index instanceof EE_Unique_Index){
4505
+		foreach ($this->_indexes as $name => $index) {
4506
+			if ($index instanceof EE_Unique_Index) {
4507 4507
 				$unique_indexes [$name] = $index;
4508 4508
 			}
4509 4509
 		}
@@ -4521,13 +4521,13 @@  discard block
 block discarded – undo
4521 4521
 	 * @return EE_Model_Field_Base[] indexed by the field's name
4522 4522
 	 * @throws \EE_Error
4523 4523
 	 */
4524
-	public function get_combined_primary_key_fields(){
4525
-		foreach($this->indexes() as $index){
4526
-			if($index instanceof EE_Primary_Key_Index){
4524
+	public function get_combined_primary_key_fields() {
4525
+		foreach ($this->indexes() as $index) {
4526
+			if ($index instanceof EE_Primary_Key_Index) {
4527 4527
 				return $index->fields();
4528 4528
 			}
4529 4529
 		}
4530
-		return array( $this->primary_key_name() => $this->get_primary_key_field());
4530
+		return array($this->primary_key_name() => $this->get_primary_key_field());
4531 4531
 	}
4532 4532
 	
4533 4533
 
@@ -4541,7 +4541,7 @@  discard block
 block discarded – undo
4541 4541
 	 * @return string
4542 4542
 	 * @throws \EE_Error
4543 4543
 	 */
4544
-	public function get_index_primary_key_string($cols_n_values){
4544
+	public function get_index_primary_key_string($cols_n_values) {
4545 4545
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
4546 4546
 		return http_build_query($cols_n_values_for_primary_key_index);
4547 4547
 	}
@@ -4556,13 +4556,13 @@  discard block
 block discarded – undo
4556 4556
 	 * @return null|array
4557 4557
 	 * @throws \EE_Error
4558 4558
 	 */
4559
-	public function parse_index_primary_key_string( $index_primary_key_string) {
4559
+	public function parse_index_primary_key_string($index_primary_key_string) {
4560 4560
 		$key_fields = $this->get_combined_primary_key_fields();
4561 4561
 		//check all of them are in the $id
4562 4562
 		$key_vals_in_combined_pk = array();
4563
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
4564
-		foreach( $key_fields as $key_field_name => $field_obj ) {
4565
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
4563
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
4564
+		foreach ($key_fields as $key_field_name => $field_obj) {
4565
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
4566 4566
 				return NULL;
4567 4567
 			}
4568 4568
 		}
@@ -4579,10 +4579,10 @@  discard block
 block discarded – undo
4579 4579
 	 * @return boolean
4580 4580
 	 * @throws \EE_Error
4581 4581
 	 */
4582
-	public function has_all_combined_primary_key_fields( $key_vals ) {
4583
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
4584
-		foreach( $keys_it_should_have as $key ){
4585
-			if( ! isset( $key_vals[ $key ] ) ){
4582
+	public function has_all_combined_primary_key_fields($key_vals) {
4583
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
4584
+		foreach ($keys_it_should_have as $key) {
4585
+			if ( ! isset($key_vals[$key])) {
4586 4586
 				return false;
4587 4587
 			}
4588 4588
 		}
@@ -4598,23 +4598,23 @@  discard block
 block discarded – undo
4598 4598
 	 * @throws EE_Error
4599 4599
 	 * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed)
4600 4600
 	 */
4601
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
4601
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
4602 4602
 
4603
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
4603
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
4604 4604
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4605
-		}elseif(is_array($model_object_or_attributes_array)){
4605
+		}elseif (is_array($model_object_or_attributes_array)) {
4606 4606
 			$attributes_array = $model_object_or_attributes_array;
4607
-		}else{
4608
-			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
4607
+		} else {
4608
+			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"), $model_object_or_attributes_array));
4609 4609
 		}
4610 4610
 		//even copies obviously won't have the same ID, so remove the primary key
4611 4611
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
4612
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
4612
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
4613 4613
 			unset($attributes_array[$this->primary_key_name()]);
4614 4614
 		}
4615
-		if(isset($query_params[0])){
4616
-			$query_params[0] = array_merge($attributes_array,$query_params);
4617
-		}else{
4615
+		if (isset($query_params[0])) {
4616
+			$query_params[0] = array_merge($attributes_array, $query_params);
4617
+		} else {
4618 4618
 			$query_params[0] = $attributes_array;
4619 4619
 		}
4620 4620
 		return $this->get_all($query_params);
@@ -4630,16 +4630,16 @@  discard block
 block discarded – undo
4630 4630
 	 * @return EE_Base_Class
4631 4631
 	 * @throws \EE_Error
4632 4632
 	 */
4633
-	public function get_one_copy($model_object_or_attributes_array,$query_params = array()){
4634
-		if( ! is_array( $query_params ) ){
4635
-			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
4633
+	public function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
4634
+		if ( ! is_array($query_params)) {
4635
+			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
4636 4636
 			$query_params = array();
4637 4637
 		}
4638 4638
 		$query_params['limit'] = 1;
4639
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4640
-		if(is_array($copies)){
4639
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
4640
+		if (is_array($copies)) {
4641 4641
 			return array_shift($copies);
4642
-		}else{
4642
+		} else {
4643 4643
 			return null;
4644 4644
 		}
4645 4645
 	}
@@ -4655,10 +4655,10 @@  discard block
 block discarded – undo
4655 4655
 	 * @return int number of rows updated
4656 4656
 	 * @throws \EE_Error
4657 4657
 	 */
4658
-	public function update_by_ID($fields_n_values,$id){
4658
+	public function update_by_ID($fields_n_values, $id) {
4659 4659
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
4660 4660
 			'default_where_conditions'=>'other_models_only',);
4661
-		return $this->update($fields_n_values,$query_params);
4661
+		return $this->update($fields_n_values, $query_params);
4662 4662
 	}
4663 4663
 
4664 4664
 
@@ -4669,12 +4669,12 @@  discard block
 block discarded – undo
4669 4669
 	 * @return string an operator which can be used in SQL
4670 4670
 	 * @throws EE_Error
4671 4671
 	 */
4672
-	private function _prepare_operator_for_sql($operator_supplied){
4672
+	private function _prepare_operator_for_sql($operator_supplied) {
4673 4673
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4674
-		if($sql_operator){
4674
+		if ($sql_operator) {
4675 4675
 			return $sql_operator;
4676
-		}else{
4677
-			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
4676
+		} else {
4677
+			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"), $operator_supplied, implode(",", array_keys($this->_valid_operators))));
4678 4678
 		}
4679 4679
 	}
4680 4680
 
@@ -4688,10 +4688,10 @@  discard block
 block discarded – undo
4688 4688
 	 * @return string[]
4689 4689
 	 * @throws \EE_Error
4690 4690
 	 */
4691
-	public function get_all_names($query_params = array()){
4691
+	public function get_all_names($query_params = array()) {
4692 4692
 		$objs = $this->get_all($query_params);
4693 4693
 		$names = array();
4694
-		foreach($objs as $obj){
4694
+		foreach ($objs as $obj) {
4695 4695
 			$names[$obj->ID()] = $obj->name();
4696 4696
 		}
4697 4697
 		return $names;
@@ -4710,11 +4710,11 @@  discard block
 block discarded – undo
4710 4710
 	 * @return array
4711 4711
 	 * @throws \EE_Error
4712 4712
 	 */
4713
-	public function get_IDs( $model_objects, $filter_out_empty_ids = false) {
4714
-		if( ! $this->has_primary_key_field() ) {
4715
-			if( WP_DEBUG ) {
4713
+	public function get_IDs($model_objects, $filter_out_empty_ids = false) {
4714
+		if ( ! $this->has_primary_key_field()) {
4715
+			if (WP_DEBUG) {
4716 4716
 				EE_Error::add_error(
4717
-					__( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ),
4717
+					__('Trying to get IDs from a model than has no primary key', 'event_espresso'),
4718 4718
 					__FILE__,
4719 4719
 					__FUNCTION__,
4720 4720
 					__LINE__
@@ -4722,13 +4722,13 @@  discard block
 block discarded – undo
4722 4722
 			}
4723 4723
 		}
4724 4724
 		$IDs = array();
4725
-		foreach( $model_objects as $model_object ) {
4725
+		foreach ($model_objects as $model_object) {
4726 4726
 			$id = $model_object->ID();
4727
-			if( ! $id ) {
4728
-				if( $filter_out_empty_ids ) {
4727
+			if ( ! $id) {
4728
+				if ($filter_out_empty_ids) {
4729 4729
 					continue;
4730 4730
 				}
4731
-				if ( WP_DEBUG ) {
4731
+				if (WP_DEBUG) {
4732 4732
 					EE_Error::add_error(
4733 4733
 						__(
4734 4734
 							'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database',
@@ -4750,8 +4750,8 @@  discard block
 block discarded – undo
4750 4750
 	 * are no capabilities that relate to this model returns false
4751 4751
 	 * @return string|false
4752 4752
 	 */
4753
-	public function cap_slug(){
4754
-		return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4753
+	public function cap_slug() {
4754
+		return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4755 4755
 	}
4756 4756
 
4757 4757
 
@@ -4766,34 +4766,34 @@  discard block
 block discarded – undo
4766 4766
 	 * @return EE_Default_Where_Conditions[] indexed by associated capability
4767 4767
 	 * @throws \EE_Error
4768 4768
 	 */
4769
-	public function cap_restrictions( $context = EEM_Base::caps_read ) {
4770
-		EEM_Base::verify_is_valid_cap_context( $context );
4769
+	public function cap_restrictions($context = EEM_Base::caps_read) {
4770
+		EEM_Base::verify_is_valid_cap_context($context);
4771 4771
 		//check if we ought to run the restriction generator first
4772
-		if(
4773
-			isset( $this->_cap_restriction_generators[ $context ] )
4774
-			&& $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base
4775
-			&& ! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions()
4772
+		if (
4773
+			isset($this->_cap_restriction_generators[$context])
4774
+			&& $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base
4775
+			&& ! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()
4776 4776
 		) {
4777
-			$this->_cap_restrictions[ $context ] = array_merge(
4778
-				$this->_cap_restrictions[ $context ],
4779
-				$this->_cap_restriction_generators[ $context ]->generate_restrictions()
4777
+			$this->_cap_restrictions[$context] = array_merge(
4778
+				$this->_cap_restrictions[$context],
4779
+				$this->_cap_restriction_generators[$context]->generate_restrictions()
4780 4780
 			);
4781 4781
 		}
4782 4782
 		//and make sure we've finalized the construction of each restriction
4783
-		foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) {
4784
-			if ( $where_conditions_obj instanceof EE_Default_Where_Conditions ) {
4785
-				$where_conditions_obj->_finalize_construct( $this );
4783
+		foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) {
4784
+			if ($where_conditions_obj instanceof EE_Default_Where_Conditions) {
4785
+				$where_conditions_obj->_finalize_construct($this);
4786 4786
 			}
4787 4787
 		}
4788 4788
 
4789
-		return $this->_cap_restrictions[ $context ];
4789
+		return $this->_cap_restrictions[$context];
4790 4790
 	}
4791 4791
 
4792 4792
 	/**
4793 4793
 	 * Indicating whether or not this model thinks its a wp core model
4794 4794
 	 * @return boolean
4795 4795
 	 */
4796
-	public function is_wp_core_model(){
4796
+	public function is_wp_core_model() {
4797 4797
 		return $this->_wp_core_model;
4798 4798
 	}
4799 4799
 
@@ -4807,12 +4807,12 @@  discard block
 block discarded – undo
4807 4807
 	 * @return EE_Default_Where_Conditions[] indexed by capability name
4808 4808
 	 * @throws \EE_Error
4809 4809
 	 */
4810
-	public function caps_missing( $context = EEM_Base::caps_read ) {
4810
+	public function caps_missing($context = EEM_Base::caps_read) {
4811 4811
 		$missing_caps = array();
4812
-		$cap_restrictions = $this->cap_restrictions( $context );
4813
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
4814
-			if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) {
4815
-				$missing_caps[ $cap ] = $restriction_if_no_cap;
4812
+		$cap_restrictions = $this->cap_restrictions($context);
4813
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
4814
+			if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) {
4815
+				$missing_caps[$cap] = $restriction_if_no_cap;
4816 4816
 			}
4817 4817
 		}
4818 4818
 		return $missing_caps;
@@ -4824,7 +4824,7 @@  discard block
 block discarded – undo
4824 4824
 	 * one of 'read', 'edit', or 'delete'
4825 4825
 	 */
4826 4826
 	public function cap_contexts_to_cap_action_map() {
4827
-		return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this );
4827
+		return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this);
4828 4828
 	}
4829 4829
 
4830 4830
 
@@ -4835,19 +4835,19 @@  discard block
 block discarded – undo
4835 4835
 	 * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values
4836 4836
 	 * @throws \EE_Error
4837 4837
 	 */
4838
-	public function cap_action_for_context( $context ) {
4838
+	public function cap_action_for_context($context) {
4839 4839
 		$mapping = $this->cap_contexts_to_cap_action_map();
4840
-		if( isset( $mapping[ $context ] ) ) {
4841
-			return $mapping[ $context ];
4840
+		if (isset($mapping[$context])) {
4841
+			return $mapping[$context];
4842 4842
 		}
4843
-		if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) {
4843
+		if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) {
4844 4844
 			return $action;
4845 4845
 		}
4846 4846
 		throw new EE_Error(
4847 4847
 			sprintf(
4848
-				__( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ),
4848
+				__('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'),
4849 4849
 				$context,
4850
-				implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) )
4850
+				implode(',', array_keys($this->cap_contexts_to_cap_action_map()))
4851 4851
 			)
4852 4852
 		);
4853 4853
 
@@ -4858,7 +4858,7 @@  discard block
 block discarded – undo
4858 4858
 	 * @return array
4859 4859
 	 */
4860 4860
 	static public function valid_cap_contexts() {
4861
-		return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array(
4861
+		return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array(
4862 4862
 			self::caps_read,
4863 4863
 			self::caps_read_admin,
4864 4864
 			self::caps_edit,
@@ -4874,17 +4874,17 @@  discard block
 block discarded – undo
4874 4874
 	 * @return bool
4875 4875
 	 * @throws \EE_Error
4876 4876
 	 */
4877
-	static public function verify_is_valid_cap_context( $context ) {
4877
+	static public function verify_is_valid_cap_context($context) {
4878 4878
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4879
-		if( in_array( $context, $valid_cap_contexts ) ) {
4879
+		if (in_array($context, $valid_cap_contexts)) {
4880 4880
 			return true;
4881
-		}else{
4881
+		} else {
4882 4882
 			throw new EE_Error(
4883 4883
 				sprintf(
4884
-					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
4884
+					__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'),
4885 4885
 					$context,
4886
-					'EEM_Base' ,
4887
-					implode(',', $valid_cap_contexts )
4886
+					'EEM_Base',
4887
+					implode(',', $valid_cap_contexts)
4888 4888
 				)
4889 4889
 			);
4890 4890
 		}
Please login to merge, or discard this patch.