Completed
Push — master ( 5b2818...3f335f )
by J.D.
03:35
created
src/includes/classes/hierarchy.php 2 patches
Doc Comments   +44 added lines patch added patch discarded remove patch
@@ -9,17 +9,49 @@  discard block
 block discarded – undo
9 9
 
10 10
 interface WordPoints_HierarchyI {
11 11
 	public function get();
12
+
13
+	/**
14
+	 * @return void
15
+	 */
12 16
 	public function push( $field, $data );
17
+
18
+	/**
19
+	 * @return void
20
+	 */
13 21
 	public function pop();
14 22
 	public function set_field( $field, $value );
23
+
24
+	/**
25
+	 * @param string $field
26
+	 * @param string $sub
27
+	 * @param string $sub_2
28
+	 */
15 29
 	public function get_field( $field, $sub = null, $sub_2 = null );
16 30
 	public function get_id();
17 31
 	public function go_to( $id );
32
+
33
+	/**
34
+	 * @param string $field
35
+	 *
36
+	 * @return void
37
+	 */
18 38
 	public function push_to( $field, $value );
39
+
40
+	/**
41
+	 * @return boolean
42
+	 */
19 43
 	public function ascend();
44
+
45
+	/**
46
+	 * @return boolean
47
+	 */
20 48
 	public function descend( $to = null );
21 49
 	public function is_main();
22 50
 	public function next();
51
+
52
+	/**
53
+	 * @return void
54
+	 */
23 55
 	public function reset();
24 56
 }
25 57
 
@@ -134,6 +166,9 @@  discard block
 block discarded – undo
134 166
 	protected $current = 0;
135 167
 	protected $i = 0;
136 168
 
169
+	/**
170
+	 * @param string $descendant_index
171
+	 */
137 172
 	public function __construct( $descendant_index ) {
138 173
 		$this->descendant_index = $descendant_index;
139 174
 	}
@@ -196,10 +231,16 @@  discard block
 block discarded – undo
196 231
 		$this->current = 0;
197 232
 	}
198 233
 
234
+	/**
235
+	 * @param string $field
236
+	 */
199 237
 	public function set_field( $field, $value ) {
200 238
 		$this->hierarchy[ $this->current ][ $field ] = $value;
201 239
 	}
202 240
 
241
+	/**
242
+	 * @param string $field
243
+	 */
203 244
 	public function get_field( $field, $sub = null, $sub_2 = null ) {
204 245
 
205 246
 		if ( ! isset( $this->hierarchy[ $this->current ][ $field ] ) ) {
@@ -225,6 +266,9 @@  discard block
 block discarded – undo
225 266
 		return $this->hierarchy[ $this->current ][ $field ];
226 267
 	}
227 268
 
269
+	/**
270
+	 * @param string $field
271
+	 */
228 272
 	public function push_to( $field, $value ) {
229 273
 
230 274
 		if ( ! isset( $this->hierarchy[ $this->current ][ $field ] ) ) {
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@  discard block
 block discarded – undo
9 9
 
10 10
 interface WordPoints_HierarchyI {
11 11
 	public function get();
12
-	public function push( $field, $data );
12
+	public function push($field, $data);
13 13
 	public function pop();
14
-	public function set_field( $field, $value );
15
-	public function get_field( $field, $sub = null, $sub_2 = null );
14
+	public function set_field($field, $value);
15
+	public function get_field($field, $sub = null, $sub_2 = null);
16 16
 	public function get_id();
17
-	public function go_to( $id );
18
-	public function push_to( $field, $value );
17
+	public function go_to($id);
18
+	public function push_to($field, $value);
19 19
 	public function ascend();
20
-	public function descend( $to = null );
20
+	public function descend($to = null);
21 21
 	public function is_main();
22 22
 	public function next();
23 23
 	public function reset();
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
 	protected $descendant_index;
32 32
 
33 33
 	public function __construct() {
34
-		$this->current =& $this->hierarchy;
34
+		$this->current = & $this->hierarchy;
35 35
 	}
36 36
 
37 37
 	public function get() {
38 38
 		return $this->hierarchy;
39 39
 	}
40 40
 
41
-	public function push( $field, $data ) {
41
+	public function push($field, $data) {
42 42
 
43
-		if ( ! isset( $this->current['slug'] ) || $this->current['slug'] !== $field ) {
43
+		if ( ! isset($this->current['slug']) || $this->current['slug'] !== $field) {
44 44
 
45
-			if ( ! empty( $this->hierarchy ) ) {
46
-				$this->current[ $this->descendant_index ][ $field ] = $data;
47
-				$this->current =& $this->current[ $this->descendant_index ][ $field ];
45
+			if ( ! empty($this->hierarchy)) {
46
+				$this->current[$this->descendant_index][$field] = $data;
47
+				$this->current = & $this->current[$this->descendant_index][$field];
48 48
 			} else {
49 49
 				$this->current = $this->stack[0] = $data;
50 50
 			}
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
 
58 58
 	public function pop() {
59 59
 
60
-		unset( $this->current );
60
+		unset($this->current);
61 61
 
62
-		$this->current = array_pop( $this->stack );
62
+		$this->current = array_pop($this->stack);
63 63
 	}
64 64
 
65 65
 	public function reset() {
66 66
 		//	unset( $this->current_arg );
67
-		$this->current =& $this->hierarchy;
67
+		$this->current = & $this->hierarchy;
68 68
 		$this->stack = array();
69 69
 	}
70 70
 
@@ -80,30 +80,30 @@  discard block
 block discarded – undo
80 80
 //		return $this->current[ $field ];
81 81
 //	}
82 82
 
83
-	public function push_to( $field, $value ) {
83
+	public function push_to($field, $value) {
84 84
 
85
-		if ( ! isset( $this->current[ $field ] ) ) {
85
+		if ( ! isset($this->current[$field])) {
86 86
 
87 87
 		}
88 88
 		//var_dump( $field, $value,$this->current[ $field ] );
89
-		$this->current[ $field ][] = $value;
89
+		$this->current[$field][] = $value;
90 90
 	}
91 91
 
92
-	public function set_sub_field( $slug, $field, $value ) {
93
-		$this->current[ $this->descendant_index ][ $slug ][ $field ] = $value;
92
+	public function set_sub_field($slug, $field, $value) {
93
+		$this->current[$this->descendant_index][$slug][$field] = $value;
94 94
 	}
95 95
 
96
-	public function get_sub_field( $slug, $field ) {
97
-		return $this->current[ $this->descendant_index ][ $slug ][ $field ];
96
+	public function get_sub_field($slug, $field) {
97
+		return $this->current[$this->descendant_index][$slug][$field];
98 98
 	}
99 99
 
100
-	public function get_sub_data( $slug ) {
101
-		return $this->current[ $this->descendant_index ][ $slug ];
100
+	public function get_sub_data($slug) {
101
+		return $this->current[$this->descendant_index][$slug];
102 102
 	}
103 103
 
104 104
 	public function ascend() {
105 105
 
106
-		if ( ! $this->stack ) {
106
+		if ( ! $this->stack) {
107 107
 			return false;
108 108
 		}
109 109
 
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
 		return true;
113 113
 	}
114 114
 
115
-	public function descend( $to = null ) {
115
+	public function descend($to = null) {
116 116
 
117
-		if ( ! isset( $this->hierarchy[ $this->descendant_index ] ) ) {
117
+		if ( ! isset($this->hierarchy[$this->descendant_index])) {
118 118
 			return false;
119 119
 		}
120 120
 
121
-		reset( $this->current[ $this->descendant_index ] );
122
-		$field = key( $this->current[ $this->descendant_index ] );
123
-		$this->current =& $this->current[ $this->descendant_index ][ $field ];
121
+		reset($this->current[$this->descendant_index]);
122
+		$field = key($this->current[$this->descendant_index]);
123
+		$this->current = & $this->current[$this->descendant_index][$field];
124 124
 
125 125
 		$this->stack[] = $this->current;
126 126
 
@@ -134,52 +134,52 @@  discard block
 block discarded – undo
134 134
 	protected $current = 0;
135 135
 	protected $i = 0;
136 136
 
137
-	public function __construct( $descendant_index ) {
137
+	public function __construct($descendant_index) {
138 138
 		$this->descendant_index = $descendant_index;
139 139
 	}
140 140
 
141 141
 	public function get() {
142 142
 	//	var_dump( $this->hierarchy );
143 143
 
144
-		if ( empty( $this->hierarchy ) ) {
144
+		if (empty($this->hierarchy)) {
145 145
 			return array();
146 146
 		}
147 147
 
148
-		return $this->build_hierarchy( $this->hierarchy[0] );
148
+		return $this->build_hierarchy($this->hierarchy[0]);
149 149
 	}
150 150
 
151
-	protected function build_hierarchy( $arg ) {
151
+	protected function build_hierarchy($arg) {
152 152
 
153
-		if ( isset( $arg[ $this->descendant_index ] ) ) {
153
+		if (isset($arg[$this->descendant_index])) {
154 154
 
155
-			foreach ( $arg[ $this->descendant_index ] as $sub_arg => $i ) {
156
-				$arg[ $this->descendant_index ][ $sub_arg ] = $this->build_hierarchy( $this->hierarchy[ $i ] );
155
+			foreach ($arg[$this->descendant_index] as $sub_arg => $i) {
156
+				$arg[$this->descendant_index][$sub_arg] = $this->build_hierarchy($this->hierarchy[$i]);
157 157
 			}
158 158
 		}
159 159
 
160
-		if ( isset( $arg['_parent'] ) ) {
161
-			unset( $arg['_parent'] );
160
+		if (isset($arg['_parent'])) {
161
+			unset($arg['_parent']);
162 162
 		}
163 163
 
164
-		unset( $arg['_i'] );
164
+		unset($arg['_i']);
165 165
 
166 166
 		return $arg;
167 167
 	}
168 168
 
169
-	public function push( $field, $data ) {
169
+	public function push($field, $data) {
170 170
 
171
-		if ( ! isset( $this->hierarchy[ $this->current ]['slug'] ) || $this->hierarchy[ $this->current ]['slug'] !== $field ) {
171
+		if ( ! isset($this->hierarchy[$this->current]['slug']) || $this->hierarchy[$this->current]['slug'] !== $field) {
172 172
 
173 173
 			$i = $this->i++;
174 174
 
175
-			if ( ! empty( $this->hierarchy ) ) {
176
-				$this->hierarchy[ $this->current ][ $this->descendant_index ][ $field ] = $i;
175
+			if ( ! empty($this->hierarchy)) {
176
+				$this->hierarchy[$this->current][$this->descendant_index][$field] = $i;
177 177
 				$data['_parent'] = $this->current;
178 178
 			}
179 179
 
180
-			$this->hierarchy[ $i ] = $data;
181
-			$this->hierarchy[ $i ]['slug'] = $field;
182
-			$this->hierarchy[ $i ]['_i'] = $i;
180
+			$this->hierarchy[$i] = $data;
181
+			$this->hierarchy[$i]['slug'] = $field;
182
+			$this->hierarchy[$i]['_i'] = $i;
183 183
 
184 184
 			$this->current = $i;
185 185
 		}
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 
188 188
 	public function pop() {
189 189
 
190
-		$this->current = isset( $this->hierarchy[ $this->current ]['_parent'] )
191
-			?  $this->hierarchy[ $this->current ]['_parent']
190
+		$this->current = isset($this->hierarchy[$this->current]['_parent'])
191
+			? $this->hierarchy[$this->current]['_parent']
192 192
 			: 0;
193 193
 	}
194 194
 
@@ -196,95 +196,95 @@  discard block
 block discarded – undo
196 196
 		$this->current = 0;
197 197
 	}
198 198
 
199
-	public function set_field( $field, $value ) {
200
-		$this->hierarchy[ $this->current ][ $field ] = $value;
199
+	public function set_field($field, $value) {
200
+		$this->hierarchy[$this->current][$field] = $value;
201 201
 	}
202 202
 
203
-	public function get_field( $field, $sub = null, $sub_2 = null ) {
203
+	public function get_field($field, $sub = null, $sub_2 = null) {
204 204
 
205
-		if ( ! isset( $this->hierarchy[ $this->current ][ $field ] ) ) {
205
+		if ( ! isset($this->hierarchy[$this->current][$field])) {
206 206
 			return null;
207 207
 		}
208 208
 
209
-		if ( isset( $sub ) ) {
210
-			if ( ! isset( $this->hierarchy[ $this->current ][ $field ][ $sub ] ) ) {
209
+		if (isset($sub)) {
210
+			if ( ! isset($this->hierarchy[$this->current][$field][$sub])) {
211 211
 				return null;
212 212
 			}
213 213
 
214
-			if ( isset( $sub_2 ) ) {
215
-				if ( ! isset( $this->hierarchy[ $this->current ][ $field ][ $sub ][ $sub_2 ] ) ) {
214
+			if (isset($sub_2)) {
215
+				if ( ! isset($this->hierarchy[$this->current][$field][$sub][$sub_2])) {
216 216
 					return null;
217 217
 				} else {
218
-					return $this->hierarchy[ $this->current ][ $field ][ $sub ][ $sub_2 ];
218
+					return $this->hierarchy[$this->current][$field][$sub][$sub_2];
219 219
 				}
220 220
 			}
221 221
 
222
-			return $this->hierarchy[ $this->current ][ $field ][ $sub ];
222
+			return $this->hierarchy[$this->current][$field][$sub];
223 223
 		}
224 224
 
225
-		return $this->hierarchy[ $this->current ][ $field ];
225
+		return $this->hierarchy[$this->current][$field];
226 226
 	}
227 227
 
228
-	public function push_to( $field, $value ) {
228
+	public function push_to($field, $value) {
229 229
 
230
-		if ( ! isset( $this->hierarchy[ $this->current ][ $field ] ) ) {
230
+		if ( ! isset($this->hierarchy[$this->current][$field])) {
231 231
 
232 232
 		}
233 233
 		//var_dump( $field, $value,$this->current[ $field ] );
234
-		$this->hierarchy[ $this->current ][ $field ][] = $value;
234
+		$this->hierarchy[$this->current][$field][] = $value;
235 235
 	}
236 236
 
237
-	public function set_sub_field( $slug, $field, $value ) {
238
-		$this->hierarchy[ $this->current ][ $this->descendant_index ][ $slug ][ $field ] = $value;
237
+	public function set_sub_field($slug, $field, $value) {
238
+		$this->hierarchy[$this->current][$this->descendant_index][$slug][$field] = $value;
239 239
 	}
240 240
 
241
-	public function get_sub_field( $slug, $field ) {
241
+	public function get_sub_field($slug, $field) {
242 242
 
243
-		return $this->hierarchy[ $this->current ][ $this->descendant_index ][ $slug ][ $field ];
243
+		return $this->hierarchy[$this->current][$this->descendant_index][$slug][$field];
244 244
 	}
245 245
 
246
-	public function get_sub_data( $slug ) {
247
-		return $this->hierarchy[ $this->current ][ $this->descendant_index ][ $slug ];
246
+	public function get_sub_data($slug) {
247
+		return $this->hierarchy[$this->current][$this->descendant_index][$slug];
248 248
 	}
249 249
 
250
-	public function has_child( $slug ) {
251
-		return isset( $this->hierarchy[ $this->current ][ $this->descendant_index ][ $slug ] );
250
+	public function has_child($slug) {
251
+		return isset($this->hierarchy[$this->current][$this->descendant_index][$slug]);
252 252
 	}
253 253
 
254 254
 	public function get_children() {
255
-		return isset( $this->hierarchy[ $this->current ][ $this->descendant_index ][ $slug ] );
255
+		return isset($this->hierarchy[$this->current][$this->descendant_index][$slug]);
256 256
 
257 257
 	}
258 258
 
259 259
 	public function ascend() {
260 260
 
261
-		if ( ! isset( $this->hierarchy[ $this->current ]['_parent'] ) ) {
261
+		if ( ! isset($this->hierarchy[$this->current]['_parent'])) {
262 262
 			return false;
263 263
 		}
264 264
 
265
-		$this->current = $this->hierarchy[ $this->current ]['_parent'];
265
+		$this->current = $this->hierarchy[$this->current]['_parent'];
266 266
 
267 267
 		return true;
268 268
 	}
269 269
 
270
-	public function descend( $to = null ) {
270
+	public function descend($to = null) {
271 271
 
272
-		if ( ! isset( $this->hierarchy[ $this->current ][ $this->descendant_index ] ) ) {
272
+		if ( ! isset($this->hierarchy[$this->current][$this->descendant_index])) {
273 273
 			return false;
274 274
 		}
275 275
 
276
-		if ( isset( $to ) ) {
276
+		if (isset($to)) {
277 277
 
278
-			if ( ! isset( $this->hierarchy[ $this->current ][ $this->descendant_index ][ $to ] ) ) {
278
+			if ( ! isset($this->hierarchy[$this->current][$this->descendant_index][$to])) {
279 279
 				return false;
280 280
 			}
281 281
 
282
-			$this->current = $this->hierarchy[ $this->current ][ $this->descendant_index ][ $to ];
282
+			$this->current = $this->hierarchy[$this->current][$this->descendant_index][$to];
283 283
 
284 284
 		} else {
285 285
 
286 286
 			$this->current = reset(
287
-				$this->hierarchy[ $this->current ][ $this->descendant_index ]
287
+				$this->hierarchy[$this->current][$this->descendant_index]
288 288
 			);
289 289
 		}
290 290
 
@@ -293,29 +293,29 @@  discard block
 block discarded – undo
293 293
 
294 294
 	public function next() {
295 295
 
296
-		if ( ! isset( $this->hierarchy[ $this->current ]['_parent'] ) ) {
296
+		if ( ! isset($this->hierarchy[$this->current]['_parent'])) {
297 297
 			return false;
298 298
 		}
299 299
 
300
-		$parent = $this->hierarchy[ $this->current ]['_parent'];
300
+		$parent = $this->hierarchy[$this->current]['_parent'];
301 301
 
302
-		if ( ! isset( $this->hierarchy[ $parent ][ $this->descendant_index ] ) ) {
302
+		if ( ! isset($this->hierarchy[$parent][$this->descendant_index])) {
303 303
 			return false;
304 304
 		}
305 305
 
306
-		$sub_args = $this->hierarchy[ $parent ][ $this->descendant_index ];
306
+		$sub_args = $this->hierarchy[$parent][$this->descendant_index];
307 307
 
308
-		reset( $sub_args );
308
+		reset($sub_args);
309 309
 
310
-		while ( current( $sub_args ) !== $this->current ) {
311
-			next( $sub_args );
310
+		while (current($sub_args) !== $this->current) {
311
+			next($sub_args);
312 312
 		}
313 313
 
314
-		if ( ! next( $sub_args ) ) {
314
+		if ( ! next($sub_args)) {
315 315
 			return false;
316 316
 		}
317 317
 
318
-		$this->current = current( $sub_args );
318
+		$this->current = current($sub_args);
319 319
 
320 320
 		return true;
321 321
 	}
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
 		return $this->current;
325 325
 	}
326 326
 
327
-	public function go_to( $id ) {
327
+	public function go_to($id) {
328 328
 
329
-		if ( false === wordpoints_posint( $id ) || $id < 0 ) {
329
+		if (false === wordpoints_posint($id) || $id < 0) {
330 330
 			return;
331 331
 		}
332 332
 
Please login to merge, or discard this patch.
src/includes/classes/hook/retroactive/query.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -73,6 +73,10 @@
 block discarded – undo
73 73
 
74 74
 
75 75
 interface WordPoints_Hook_Reactor_RetroactiveI extends WordPoints_Hook_Retroactive_Query_ModifierI {
76
+
77
+	/**
78
+	 * @return void
79
+	 */
76 80
 	public function retroactive_hit( $target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction );
77 81
 }
78 82
 
Please login to merge, or discard this patch.
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
 
74 74
 
75 75
 interface WordPoints_Hook_Reactor_RetroactiveI extends WordPoints_Hook_Retroactive_Query_ModifierI {
76
-	public function retroactive_hit( $target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction );
76
+	public function retroactive_hit($target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction);
77 77
 }
78 78
 
79 79
 abstract class WordPoints_Hook_Reactor_Retroactive implements WordPoints_Hook_Reactor_RetroactiveI {
80 80
 
81
-	public function modify_retroactive_query( WordPoints_Hook_Retroactive_QueryI $query ) {
81
+	public function modify_retroactive_query(WordPoints_Hook_Retroactive_QueryI $query) {
82 82
 
83
-		$query->set_target( $query->get_reaction()->get_meta( 'target' ) );
83
+		$query->set_target($query->get_reaction()->get_meta('target'));
84 84
 	}
85 85
 
86 86
 	public function reverse_hits() {
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 	/**
98 98
 	 * @since 1.0.0
99 99
 	 */
100
-	public function retroactive_hit( $target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction ) {
100
+	public function retroactive_hit($target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction) {
101 101
 
102
-		$count = count( $records );
102
+		$count = count($records);
103 103
 
104 104
 		wordpoints_alter_points(
105 105
 			$target
106
-			, $reaction->get_meta( 'points' ) * $count
107
-			, $reaction->get_meta( 'points_type' )
108
-			, 'retroactive_' . $reaction->get_event_slug()
109
-			, array( 'count' => $count )
110
-			, $event->get_retroactive_description( $reaction )
106
+			, $reaction->get_meta('points') * $count
107
+			, $reaction->get_meta('points_type')
108
+			, 'retroactive_'.$reaction->get_event_slug()
109
+			, array('count' => $count)
110
+			, $event->get_retroactive_description($reaction)
111 111
 		);
112 112
 	}
113 113
 
@@ -139,22 +139,22 @@  discard block
 block discarded – undo
139 139
 
140 140
 		$logs = $query->get();
141 141
 
142
-		if ( ! $logs ) {
142
+		if ( ! $logs) {
143 143
 			return;
144 144
 		}
145 145
 
146
-		foreach ( $logs as $log ) {
146
+		foreach ($logs as $log) {
147 147
 
148 148
 			wordpoints_alter_points(
149 149
 				$log->user_id
150
-				, - ( $log->points / wordpoints_get_points_log_meta( $log->id, 'count', true ) )
150
+				, -($log->points / wordpoints_get_points_log_meta($log->id, 'count', true))
151 151
 				, $log->points_type
152 152
 				, "reverse_{$event}"
153
-				, array( 'original_log_id' => $log->id )
153
+				, array('original_log_id' => $log->id)
154 154
 				, $args->get_description()
155 155
 			);
156 156
 
157
-			wordpoints_add_points_log_meta( $log->id, 'auto_reversed', $args->get_entity_id() );
157
+			wordpoints_add_points_log_meta($log->id, 'auto_reversed', $args->get_entity_id());
158 158
 		}
159 159
 	}
160 160
 }
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
 
197 197
 	protected $results;
198 198
 
199
-	public function __construct( WordPoints_Hook_ReactionI $reaction ) {
199
+	public function __construct(WordPoints_Hook_ReactionI $reaction) {
200 200
 
201 201
 		$this->reaction = $reaction;
202
-		$this->arg_hierarchy = new WordPoints_Hierarchy( 'sub_args' );
202
+		$this->arg_hierarchy = new WordPoints_Hierarchy('sub_args');
203 203
 		$this->hooks = wordpoints_hooks();
204 204
 		$this->entities = wordpoints_entities();
205
-		$this->validator = new WordPoints_Hook_Reaction_Validator( $reaction, true );
205
+		$this->validator = new WordPoints_Hook_Reaction_Validator($reaction, true);
206 206
 	}
207 207
 
208 208
 	public function get_reaction() {
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
 
216 216
 	public function get_results() {
217 217
 
218
-		if ( ! isset( $this->results ) ) {
218
+		if ( ! isset($this->results)) {
219 219
 
220 220
 			$this->execute();
221 221
 
222
-			if ( $this->validator->had_errors() ) {
222
+			if ($this->validator->had_errors()) {
223 223
 				$this->results = $this->validator;
224 224
 			}
225 225
 		}
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 			$this->filter_results();
237 237
 			$this->group_results();
238 238
 
239
-		} catch ( WordPoints_Hook_Validator_Exception $e ) {
240
-			unset( $e );
239
+		} catch (WordPoints_Hook_Validator_Exception $e) {
240
+			unset($e);
241 241
 		}
242 242
 	}
243 243
 
@@ -245,33 +245,33 @@  discard block
 block discarded – undo
245 245
 
246 246
 		$event_slug = $this->reaction->get_event_slug();
247 247
 
248
-		$events = $this->hooks->get_sub_app( 'events' );
249
-		$event  = $events->get( $event_slug );
248
+		$events = $this->hooks->get_sub_app('events');
249
+		$event  = $events->get($event_slug);
250 250
 
251
-		if ( ! ( $event instanceof WordPoints_Hook_Event_RetroactiveI ) ) {
252
-			$this->validator->add_error( 'invalid hook' );
251
+		if ( ! ($event instanceof WordPoints_Hook_Event_RetroactiveI)) {
252
+			$this->validator->add_error('invalid hook');
253 253
 		}
254 254
 
255
-		foreach ( $events->get_sub_app( 'args' )->get_children( $event_slug ) as $arg ) {
255
+		foreach ($events->get_sub_app('args')->get_children($event_slug) as $arg) {
256 256
 			$this->arg_hierarchy_push( // TODO
257 257
 				$arg
258 258
 			);
259 259
 		}
260 260
 
261
-		if ( $event instanceof WordPoints_Hook_Retroactive_Query_ModifierI ) {
262
-			$event->modify_retroactive_query( $this );
261
+		if ($event instanceof WordPoints_Hook_Retroactive_Query_ModifierI) {
262
+			$event->modify_retroactive_query($this);
263 263
 			$this->reset();
264 264
 		}
265 265
 
266
-		$reactor = $this->hooks->get_sub_app( 'reactors' )->get( $this->reaction->get_reactor_slug() );
266
+		$reactor = $this->hooks->get_sub_app('reactors')->get($this->reaction->get_reactor_slug());
267 267
 
268
-		$reactor->modify_retroactive_query( $this );
268
+		$reactor->modify_retroactive_query($this);
269 269
 		$this->reset();
270 270
 
271
-		foreach ( $this->hooks->get_sub_app( 'extensions' )->get_all() as $extension ) {
271
+		foreach ($this->hooks->get_sub_app('extensions')->get_all() as $extension) {
272 272
 
273
-			if ( $extension instanceof WordPoints_Hook_Retroactive_Query_ModifierI ) {
274
-				$extension->modify_retroactive_query( $this );
273
+			if ($extension instanceof WordPoints_Hook_Retroactive_Query_ModifierI) {
274
+				$extension->modify_retroactive_query($this);
275 275
 				$this->reset();
276 276
 			}
277 277
 		}
@@ -279,126 +279,126 @@  discard block
 block discarded – undo
279 279
 
280 280
 	protected function perform_query() {
281 281
 
282
-		$this->queries = new WordPoints_Hierarchy( 'sub_queries' );
283
-		$this->consolidate_queries( array( $this->arg_hierarchy->get() ) );
284
-		unset( $this->query );
282
+		$this->queries = new WordPoints_Hierarchy('sub_queries');
283
+		$this->consolidate_queries(array($this->arg_hierarchy->get()));
284
+		unset($this->query);
285 285
 
286 286
 		$this->queries->reset();
287 287
 
288 288
 		// Find the tip of a query.
289
-		$this->results = $this->execute_queries( $this->queries->get() );
289
+		$this->results = $this->execute_queries($this->queries->get());
290 290
 
291
-		if ( is_wp_error( $this->results ) ) {
292
-			$this->validator->add_error( $this->results );
291
+		if (is_wp_error($this->results)) {
292
+			$this->validator->add_error($this->results);
293 293
 		}
294 294
 	}
295 295
 
296
-	protected function consolidate_queries( $arg_hierarchy, $storage_type = null ) {
296
+	protected function consolidate_queries($arg_hierarchy, $storage_type = null) {
297 297
 
298
-		foreach ( $arg_hierarchy as $data ) {
299
-			$this->consolidate_query( $data );
298
+		foreach ($arg_hierarchy as $data) {
299
+			$this->consolidate_query($data);
300 300
 		}
301 301
 	}
302 302
 
303
-	protected function consolidate_query( $data ) {
303
+	protected function consolidate_query($data) {
304 304
 
305
-		if ( $data['storage_info']['type'] !== $this->queries->get_field( 'slug' ) ) {
305
+		if ($data['storage_info']['type'] !== $this->queries->get_field('slug')) {
306 306
 
307 307
 			$parent_id = null;
308
-			if ( isset( $this->query ) ) {
308
+			if (isset($this->query)) {
309 309
 				$parent_id = $this->query->get_id();
310 310
 			}
311 311
 
312
-			$this->query = new WordPoints_Hierarchy( 'sub_args' );
312
+			$this->query = new WordPoints_Hierarchy('sub_args');
313 313
 
314 314
 			$this->queries->push(
315 315
 				$data['storage_info']['type']
316
-				, array( 'query' => $this->query, 'parent_id' => $parent_id )
316
+				, array('query' => $this->query, 'parent_id' => $parent_id)
317 317
 			);
318 318
 
319 319
 			$pushed_query = true;
320 320
 		}
321 321
 
322
-		if ( isset( $data['sub_args'] ) ) {
322
+		if (isset($data['sub_args'])) {
323 323
 			$sub_args = $data['sub_args'];
324
-			unset( $data['sub_args'] );
324
+			unset($data['sub_args']);
325 325
 		}
326 326
 
327
-		$this->query->push( $data['slug'], $data );
327
+		$this->query->push($data['slug'], $data);
328 328
 
329
-		if ( isset( $sub_args ) ) {
330
-			$this->consolidate_queries( $sub_args, $data['storage_info']['type'] );
329
+		if (isset($sub_args)) {
330
+			$this->consolidate_queries($sub_args, $data['storage_info']['type']);
331 331
 		}
332 332
 
333 333
 		$this->query->pop();
334 334
 
335
-		if ( ! empty( $pushed_query ) ) {
335
+		if ( ! empty($pushed_query)) {
336 336
 			$this->queries->pop();
337
-			$this->query = $this->queries->get_field( 'query' );
337
+			$this->query = $this->queries->get_field('query');
338 338
 		}
339 339
 	}
340 340
 
341
-	protected function execute_queries( $queries ) {
341
+	protected function execute_queries($queries) {
342 342
 
343 343
 		/** @var WordPoints_HierarchyI $query */
344 344
 		$query = $queries['query'];
345 345
 
346
-		if ( isset( $queries['sub_queries'] ) ) {
347
-			foreach ( $queries['sub_queries'] as $query_data ) {
346
+		if (isset($queries['sub_queries'])) {
347
+			foreach ($queries['sub_queries'] as $query_data) {
348 348
 
349
-				$results = $this->execute_queries( $query_data );
349
+				$results = $this->execute_queries($query_data);
350 350
 
351
-				if ( is_wp_error( $results ) ) {
351
+				if (is_wp_error($results)) {
352 352
 					return $results;
353 353
 				}
354 354
 
355
-				if ( empty( $results ) ) {
355
+				if (empty($results)) {
356 356
 					return array();
357 357
 				}
358 358
 
359 359
 				/** @var WordPoints_HierarchyI $child_query */
360 360
 				$child_query = $query_data['query'];
361
-				$query->go_to( $query_data['parent_id'] );
361
+				$query->go_to($query_data['parent_id']);
362 362
 
363 363
 				$condition = array(
364 364
 //					'field' => $child_query->get_field( 'slug' ),
365 365
 					'compare' => 'in',
366 366
 					'value' => wp_list_pluck(
367 367
 						$results
368
-						, $child_query->get_field( 'storage_info', 'meta', 'id_field' )
368
+						, $child_query->get_field('storage_info', 'meta', 'id_field')
369 369
 					),
370 370
 				);
371 371
 
372
-				$query->push_to( 'conditions', $condition );
372
+				$query->push_to('conditions', $condition);
373 373
 			}
374 374
 		}
375 375
 
376 376
 		$query->reset();
377
-		$storage_type = $query->get_field( 'storage_info', 'type' );
377
+		$storage_type = $query->get_field('storage_info', 'type');
378 378
 
379 379
 		// it is pretty stupid to wait until now to figure this out.
380
-		$executor = $this->hooks->get_sub_app( 'retroactive_query_executors' )->get( $storage_type );
380
+		$executor = $this->hooks->get_sub_app('retroactive_query_executors')->get($storage_type);
381 381
 
382
-		if ( ! $executor ) {
382
+		if ( ! $executor) {
383 383
 			$this->validator->add_error(
384
-				sprintf( 'unknown storage type "%s".', $storage_type )
384
+				sprintf('unknown storage type "%s".', $storage_type)
385 385
 			);
386 386
 		}
387 387
 
388
-		return $executor->execute( array( $query->get() ) );
388
+		return $executor->execute(array($query->get()));
389 389
 	}
390 390
 
391 391
 	protected function filter_results() {
392 392
 
393
-		$reactor = $this->hooks->get_sub_app( 'reactors' )->get( $this->reaction->get_reactor_slug() );
393
+		$reactor = $this->hooks->get_sub_app('reactors')->get($this->reaction->get_reactor_slug());
394 394
 
395
-		if ( $reactor instanceof WordPoints_Hook_Retroactive_Query_FilterI ) {
396
-			$reactor->filter_retroactive_query( $this );
395
+		if ($reactor instanceof WordPoints_Hook_Retroactive_Query_FilterI) {
396
+			$reactor->filter_retroactive_query($this);
397 397
 		}
398 398
 
399
-		foreach ( $this->hooks->get_sub_app( 'extensions' )->get_all() as $extension ) {
400
-			if ( $extension instanceof WordPoints_Hook_Retroactive_Query_FilterI ) {
401
-				$extension->filter_retroactive_query( $this );
399
+		foreach ($this->hooks->get_sub_app('extensions')->get_all() as $extension) {
400
+			if ($extension instanceof WordPoints_Hook_Retroactive_Query_FilterI) {
401
+				$extension->filter_retroactive_query($this);
402 402
 			}
403 403
 		}
404 404
 	}
@@ -407,27 +407,27 @@  discard block
 block discarded – undo
407 407
 
408 408
 		$grouped_results = array();
409 409
 
410
-		foreach ( $this->results as $result ) {
411
-			$grouped_results[ $result->target ][] = $result;
410
+		foreach ($this->results as $result) {
411
+			$grouped_results[$result->target][] = $result;
412 412
 		}
413 413
 
414 414
 		$this->results = $grouped_results;
415 415
 	}
416 416
 
417
-	public function add_condition( array $condition ) {
417
+	public function add_condition(array $condition) {
418 418
 
419
-		$this->arg_hierarchy->push_to( 'conditions', $condition );
419
+		$this->arg_hierarchy->push_to('conditions', $condition);
420 420
 	}
421 421
 
422
-	public function select_value( $data = array() ) {
422
+	public function select_value($data = array()) {
423 423
 
424
-		$this->arg_hierarchy->set_field( 'select', $data );
424
+		$this->arg_hierarchy->set_field('select', $data);
425 425
 	}
426 426
 
427
-	public function set_target( $target_arg ) {
427
+	public function set_target($target_arg) {
428 428
 
429
-		foreach ( $target_arg as $arg_slug ) {
430
-			$this->arg_hierarchy_push( $arg_slug );
429
+		foreach ($target_arg as $arg_slug) {
430
+			$this->arg_hierarchy_push($arg_slug);
431 431
 		}
432 432
 
433 433
 //		$id = $this->arg_hierarchy->get_id();
@@ -437,10 +437,10 @@  discard block
 block discarded – undo
437 437
 //			$field = $this->arg_hierarchy->get_field( 'storage_info', 'meta', 'field' );
438 438
 //			$this->arg_hierarchy->ascend();
439 439
 //		} else {
440
-			$field = $this->arg_hierarchy->get_field( 'storage_info', 'meta', 'id_field' );
440
+			$field = $this->arg_hierarchy->get_field('storage_info', 'meta', 'id_field');
441 441
 //		}
442 442
 
443
-		$this->select_value( array( 'field' => $field, 'as' => 'target' ) );
443
+		$this->select_value(array('field' => $field, 'as' => 'target'));
444 444
 
445 445
 //		$this->arg_hierarchy->go_to( $id );
446 446
 	}
@@ -452,40 +452,40 @@  discard block
 block discarded – undo
452 452
 	 * @return WordPoints_EntityishI
453 453
 	 */
454 454
 	public function get_arg() {
455
-		return $this->arg_hierarchy->get_field( 'arg' );
455
+		return $this->arg_hierarchy->get_field('arg');
456 456
 	}
457 457
 
458
-	public function arg_hierarchy_push( $slug ) {
458
+	public function arg_hierarchy_push($slug) {
459 459
 
460
-		$current_slug = $this->arg_hierarchy->get_field( 'slug' );
460
+		$current_slug = $this->arg_hierarchy->get_field('slug');
461 461
 
462
-		if ( $current_slug === $slug && $this->arg_hierarchy->is_main() ) {
462
+		if ($current_slug === $slug && $this->arg_hierarchy->is_main()) {
463 463
 			return;
464 464
 		}
465 465
 
466 466
 //		if ( $current_slug !== $slug ) {
467 467
 
468
-			if ( empty( $current_slug ) ) {
469
-				$arg = $this->entities->get( $slug );
468
+			if (empty($current_slug)) {
469
+				$arg = $this->entities->get($slug);
470 470
 			} else {
471 471
 
472 472
 				// If this child exists, don't overwrite it, just descend into it.
473
-				if ( $this->arg_hierarchy->has_child( $slug ) ) {
474
-					$this->arg_hierarchy->descend( $slug );
473
+				if ($this->arg_hierarchy->has_child($slug)) {
474
+					$this->arg_hierarchy->descend($slug);
475 475
 					return;
476 476
 				}
477 477
 
478
-				$parent_arg = $this->arg_hierarchy->get_field( 'arg' );
478
+				$parent_arg = $this->arg_hierarchy->get_field('arg');
479 479
 
480
-				if ( $parent_arg instanceof WordPoints_Entity_ParentI ) {
481
-					$arg = $parent_arg->get_child( $slug );
480
+				if ($parent_arg instanceof WordPoints_Entity_ParentI) {
481
+					$arg = $parent_arg->get_child($slug);
482 482
 				} else {
483 483
 					return; // TODO
484 484
 				}
485 485
 			}
486 486
 
487
-			if ( $arg instanceof WordPoints_Entity_Array ) {
488
-				$arg = $this->entities->get( $arg->get_entity_slug() );
487
+			if ($arg instanceof WordPoints_Entity_Array) {
488
+				$arg = $this->entities->get($arg->get_entity_slug());
489 489
 			}
490 490
 
491 491
 			$data['arg'] = $arg;
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 			// TODO check if storage type is recognized?
494 494
 			$data['storage_info'] = $arg->get_storage_info();
495 495
 
496
-			$this->arg_hierarchy->push( $slug, $data );
496
+			$this->arg_hierarchy->push($slug, $data);
497 497
 
498 498
 //		} else {
499 499
 //			$data = array();
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
 }
511 511
 
512 512
 interface WordPoints_Hook_Retroactive_Query_FilterI {
513
-	public function filter_retroactive_query( WordPoints_Hook_Retroactive_QueryI $query );
513
+	public function filter_retroactive_query(WordPoints_Hook_Retroactive_QueryI $query);
514 514
 }
515 515
 
516 516
 interface WordPoints_Hook_Retroactive_Query_ExecutorI {
517
-	public function execute( $query );
517
+	public function execute($query);
518 518
 }
519 519
 
520 520
 /*
@@ -543,48 +543,48 @@  discard block
 block discarded – undo
543 543
 	protected $array;
544 544
 	protected $results;
545 545
 
546
-	public function execute( $query ) {
546
+	public function execute($query) {
547 547
 
548
-		foreach ( $query as $arg_data ) {
548
+		foreach ($query as $arg_data) {
549 549
 
550 550
 			$meta = $arg_data['storage_info']['meta'];
551 551
 
552
-			if ( isset( $meta['getter'] ) ) {
552
+			if (isset($meta['getter'])) {
553 553
 				$this->array = $meta['getter']();
554 554
 			}
555 555
 
556
-			if ( isset( $arg_data['conditions'] ) ) {
556
+			if (isset($arg_data['conditions'])) {
557 557
 
558
-				foreach ( $arg_data['conditions'] as $condition ) {
558
+				foreach ($arg_data['conditions'] as $condition) {
559 559
 
560
-					if ( ! isset( $condition['field'] ) ) {
561
-						if ( $arg_data['arg'] instanceof WordPoints_Entity_Attr ) {
560
+					if ( ! isset($condition['field'])) {
561
+						if ($arg_data['arg'] instanceof WordPoints_Entity_Attr) {
562 562
 							$condition['field'] = $meta['field'];
563 563
 						} else {
564 564
 							$condition['field'] = $meta['id_field'];
565 565
 						}
566 566
 					}
567 567
 
568
-					if ( ! isset( $condition['condition'] ) ) {
568
+					if ( ! isset($condition['condition'])) {
569 569
 						$condition['condition'] = '=';
570 570
 					}
571 571
 
572 572
 					$filter_args = array();
573 573
 
574
-					switch ( $condition['condition'] ) {
574
+					switch ($condition['condition']) {
575 575
 
576 576
 						case '=':
577
-							$filter_args[ $condition['field'] ] = $condition['value'];
577
+							$filter_args[$condition['field']] = $condition['value'];
578 578
 							break;
579 579
 
580 580
 						case 'in':
581 581
 							// TODO
582 582
 
583 583
 						default:
584
-							return new WP_Error( 'invalid condition type' );
584
+							return new WP_Error('invalid condition type');
585 585
 					}
586 586
 
587
-					$this->array = wp_list_filter( $this->array, $filter_args );
587
+					$this->array = wp_list_filter($this->array, $filter_args);
588 588
 				}
589 589
 			}
590 590
 
@@ -592,9 +592,9 @@  discard block
 block discarded – undo
592 592
 //				$builder->add_field( $arg_data['select'] );
593 593
 //			}
594 594
 
595
-			if ( isset( $arg_data['sub_args'] ) ) {
595
+			if (isset($arg_data['sub_args'])) {
596 596
 				$this->parent_data = $arg_data;
597
-				$this->array = $this->execute( $arg_data['sub_args'] );
597
+				$this->array = $this->execute($arg_data['sub_args']);
598 598
 			}
599 599
 
600 600
 			$this->results = $this->array;
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 
624 624
 	protected $entered_join;
625 625
 
626
-	public function execute( $query ) {
626
+	public function execute($query) {
627 627
 		// WE should be getting a hierarchy object here.
628 628
 		// This will let us loop over things easier.
629 629
 		// We'll also need to be marking the non-usable parts of the query.
@@ -633,69 +633,69 @@  discard block
 block discarded – undo
633 633
 
634 634
 		$this->builder = new WordPoints_Query_Builder_DB_MySQL();
635 635
 
636
-		$this->build_query( $query );
636
+		$this->build_query($query);
637 637
 
638 638
 		$sql = $this->builder->get_query();
639 639
 
640
-		if ( is_wp_error( $sql ) ) {
640
+		if (is_wp_error($sql)) {
641 641
 			return $sql;
642 642
 		}
643 643
 
644
-		return $wpdb->get_results( $sql );
644
+		return $wpdb->get_results($sql);
645 645
 	}
646 646
 
647
-	protected function build_query( $args ) {
647
+	protected function build_query($args) {
648 648
 
649
-		foreach ( $args as $arg_data ) {
649
+		foreach ($args as $arg_data) {
650 650
 
651 651
 			$this->arg_data = $arg_data;
652 652
 
653
-			if ( isset( $arg_data['storage_info']['meta']['table_name'] ) ) {
654
-				$this->build_table_schema( $arg_data['storage_info']['meta'] );
653
+			if (isset($arg_data['storage_info']['meta']['table_name'])) {
654
+				$this->build_table_schema($arg_data['storage_info']['meta']);
655 655
 			}
656 656
 
657
-			if ( isset( $arg_data['conditions'] ) ) {
658
-				$this->build_conditions( $arg_data['conditions'] );
657
+			if (isset($arg_data['conditions'])) {
658
+				$this->build_conditions($arg_data['conditions']);
659 659
 			}
660 660
 
661
-			if ( isset( $arg_data['select'] ) ) {
662
-				$this->builder->add_field( $arg_data['select'] );
661
+			if (isset($arg_data['select'])) {
662
+				$this->builder->add_field($arg_data['select']);
663 663
 			}
664 664
 
665
-			if ( isset( $arg_data['sub_args'] ) ) {
665
+			if (isset($arg_data['sub_args'])) {
666 666
 
667 667
 				$this->grandparent_data = $this->parent_data;
668 668
 				$this->parent_data = $arg_data;
669 669
 
670
-				$this->build_query( $arg_data['sub_args'] );
670
+				$this->build_query($arg_data['sub_args']);
671 671
 
672 672
 				$this->parent_data = $this->grandparent_data;
673 673
 			}
674 674
 
675
-			if ( isset( $this->entered_join ) ) {
675
+			if (isset($this->entered_join)) {
676 676
 				$this->builder->exit_join();
677 677
 				$this->entered_join = null;
678 678
 			}
679 679
 		}
680 680
 	}
681 681
 
682
-	protected function build_table_schema( $db ) {
682
+	protected function build_table_schema($db) {
683 683
 
684
-		if ( $this->builder->get_table() ) {
684
+		if ($this->builder->get_table()) {
685 685
 
686
-			if ( $this->parent_data['arg'] instanceof WordPoints_Entity_Relationship ) {
686
+			if ($this->parent_data['arg'] instanceof WordPoints_Entity_Relationship) {
687 687
 				$primary_field = $this->parent_data['storage_info']['meta']['field'];
688 688
 				$join_field = $db['id_field'];
689 689
 				//$primary_field = $this->arg_data['arg']->get_secondary_field();
690
-			} elseif ( $this->arg_data['arg'] instanceof WordPoints_Entity_Relationship ) {
690
+			} elseif ($this->arg_data['arg'] instanceof WordPoints_Entity_Relationship) {
691 691
 				$join_field = $db['join_field'];
692 692
 				$primary_field = $this->parent_data['storage_info']['meta']['id_field'];
693 693
 			} else {
694
-				throw new WordPoints_Query_Builder_Exception( 'Houston, we have a problem.' );
694
+				throw new WordPoints_Query_Builder_Exception('Houston, we have a problem.');
695 695
 			}
696 696
 
697
-			if ( is_array( $primary_field ) && isset( $primary_field['table_name'] ) ) {
698
-				$this->builder->enter_join( $primary_field );
697
+			if (is_array($primary_field) && isset($primary_field['table_name'])) {
698
+				$this->builder->enter_join($primary_field);
699 699
 				$primary_field = $primary_field['on']['join_field'];
700 700
 			}
701 701
 
@@ -707,26 +707,26 @@  discard block
 block discarded – undo
707 707
 				),
708 708
 			);
709 709
 
710
-			if ( isset( $db['join_where'] ) ) {
710
+			if (isset($db['join_where'])) {
711 711
 				$join['where'] = $db['join_where'];
712 712
 			}
713 713
 
714
-			$this->builder->enter_join( $join );
714
+			$this->builder->enter_join($join);
715 715
 
716 716
 			$this->entered_join = true;
717 717
 
718 718
 		} else {
719
-			$this->builder->set_table( $db['table_name'] );
720
-			$this->builder->add_field( $db['id_field'] );
719
+			$this->builder->set_table($db['table_name']);
720
+			$this->builder->add_field($db['id_field']);
721 721
 		}
722 722
 	}
723 723
 
724
-	protected function build_conditions( $conditions ) {
724
+	protected function build_conditions($conditions) {
725 725
 
726 726
 		// Join conditions should be pushed to the end.
727 727
 		$join_conditions = array();
728 728
 
729
-		foreach ( $conditions as $condition ) {
729
+		foreach ($conditions as $condition) {
730 730
 
731 731
 			// THis needs to be the identifier field for the type of arg that this
732 732
 			// field represents.
@@ -734,43 +734,43 @@  discard block
 block discarded – undo
734 734
 			// However, for a relationship it could be something else.
735 735
 			// Ultimately, this will have to be left up to the arg object to
736 736
 			// decide.
737
-			if ( ! isset( $condition['field'] ) ) {
738
-				if ( $this->arg_data['arg'] instanceof WordPoints_Entity_Relationship ) {
737
+			if ( ! isset($condition['field'])) {
738
+				if ($this->arg_data['arg'] instanceof WordPoints_Entity_Relationship) {
739 739
 //					$condition['field'] = $this->arg_data['arg']->get_secondary_field();
740 740
 					$condition['field'] = $this->arg_data['storage_info']['meta']['field'];
741 741
 
742
-					if ( is_array( $condition['field'] && isset( $condition['field']['table_name'] ) ) ) {
742
+					if (is_array($condition['field'] && isset($condition['field']['table_name']))) {
743 743
 						$join_conditions[] = $condition;
744 744
 						continue;
745 745
 					}
746
-				} elseif ( $this->arg_data['arg'] instanceof WordPoints_Entity_Attr ) {
746
+				} elseif ($this->arg_data['arg'] instanceof WordPoints_Entity_Attr) {
747 747
 					$condition['field'] = $this->arg_data['arg']->get_field();
748 748
 				} else {
749
-					var_dump($this->arg_data['arg']);exit;
749
+					var_dump($this->arg_data['arg']); exit;
750 750
 				}
751 751
 			}
752 752
 
753
-			$this->builder->where( $condition );
753
+			$this->builder->where($condition);
754 754
 		}
755 755
 
756
-		$join_count = count( $join_conditions );
756
+		$join_count = count($join_conditions);
757 757
 		$i = 0;
758 758
 
759
-		foreach ( $join_conditions as $condition ) {
759
+		foreach ($join_conditions as $condition) {
760 760
 
761 761
 			$i++;
762 762
 
763
-			$this->builder->enter_join( $condition['field'] );
763
+			$this->builder->enter_join($condition['field']);
764 764
 
765 765
 			$condition['field'] = $condition['field']['on']['primary_field'];
766 766
 
767
-			$this->builder->where( $condition );
767
+			$this->builder->where($condition);
768 768
 
769 769
 			$this->builder->exit_join();
770 770
 
771 771
 			// If there are more join conditions, we need to leave a fresh, trailing
772 772
 			// join for the next one to join to.
773
-			if ( $i < $join_count ) {
773
+			if ($i < $join_count) {
774 774
 
775 775
 				// There is a current join, but it is already being used, so we
776 776
 				// need to exit it.
Please login to merge, or discard this patch.
src/includes/classes/query/builder/db/mysql.php 2 patches
Doc Comments   +24 added lines patch added patch discarded remove patch
@@ -9,12 +9,36 @@
 block discarded – undo
9 9
 
10 10
 
11 11
 interface WordPoints_Query_BuilderI {
12
+
13
+	/**
14
+	 * @return void
15
+	 */
12 16
 	public function set_fields( $fields );
17
+
18
+	/**
19
+	 * @return void
20
+	 */
13 21
 	public function add_field( $field );
22
+
23
+	/**
24
+	 * @return void
25
+	 */
14 26
 	public function set_table( $table_name );
15 27
 	public function get_table();
28
+
29
+	/**
30
+	 * @return void
31
+	 */
16 32
 	public function enter_join( $join );
33
+
34
+	/**
35
+	 * @return void
36
+	 */
17 37
 	public function exit_join();
38
+
39
+	/**
40
+	 * @return void
41
+	 */
18 42
 	public function where( $condition );
19 43
 	public function get_query();
20 44
 }
Please login to merge, or discard this patch.
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
 
10 10
 
11 11
 interface WordPoints_Query_BuilderI {
12
-	public function set_fields( $fields );
13
-	public function add_field( $field );
14
-	public function set_table( $table_name );
12
+	public function set_fields($fields);
13
+	public function add_field($field);
14
+	public function set_table($table_name);
15 15
 	public function get_table();
16
-	public function enter_join( $join );
16
+	public function enter_join($join);
17 17
 	public function exit_join();
18
-	public function where( $condition );
18
+	public function where($condition);
19 19
 	public function get_query();
20 20
 }
21 21
 
@@ -33,55 +33,55 @@  discard block
 block discarded – undo
33 33
 	protected $aliases = array();
34 34
 
35 35
 	public function __construct() {
36
-		$this->query = new WordPoints_Hierarchy( 'joins' );
37
-		$this->query->push( '', array() );
36
+		$this->query = new WordPoints_Hierarchy('joins');
37
+		$this->query->push('', array());
38 38
 	}
39 39
 
40
-	public function set_fields( $fields ) {
41
-		$this->query->set_field( 'fields', $fields );
40
+	public function set_fields($fields) {
41
+		$this->query->set_field('fields', $fields);
42 42
 	}
43 43
 
44
-	public function add_field( $field ) {
45
-		$this->query->push_to( 'fields', $field );
44
+	public function add_field($field) {
45
+		$this->query->push_to('fields', $field);
46 46
 	}
47 47
 
48
-	public function set_table( $table_name ) {
49
-		$this->query->set_field( 'table_name',  $table_name );
48
+	public function set_table($table_name) {
49
+		$this->query->set_field('table_name', $table_name);
50 50
 	}
51 51
 
52 52
 	public function get_table() {
53
-		return $this->query->get_field( 'table_name' );
53
+		return $this->query->get_field('table_name');
54 54
 	}
55 55
 
56
-	protected function get_alias( $data ) {
56
+	protected function get_alias($data) {
57 57
 
58
-		if ( ! isset( $this->aliases[ $data['table_name'] ] ) ) {
59
-			$this->aliases[ $data['table_name'] ] = 0;
58
+		if ( ! isset($this->aliases[$data['table_name']])) {
59
+			$this->aliases[$data['table_name']] = 0;
60 60
 		}
61 61
 
62
-		return $data['table_name'] . '_' . ++$this->aliases[ $data['table_name'] ];
62
+		return $data['table_name'].'_'.++$this->aliases[$data['table_name']];
63 63
 	}
64 64
 
65
-	public function enter_join( $join ) {
66
-		$alias = $this->get_alias( $join );
67
-		$this->query->push( $alias, $join );
65
+	public function enter_join($join) {
66
+		$alias = $this->get_alias($join);
67
+		$this->query->push($alias, $join);
68 68
 	}
69 69
 
70 70
 	public function exit_join() {
71 71
 		$this->query->pop();
72 72
 	}
73 73
 
74
-	public function where( $condition ) {
74
+	public function where($condition) {
75 75
 
76
-		$where = $this->query->get_field( 'where' );
76
+		$where = $this->query->get_field('where');
77 77
 
78
-		if ( ! is_array( $where ) ) {
78
+		if ( ! is_array($where)) {
79 79
 			$where = array();
80 80
 		}
81 81
 
82 82
 		$where[] = $condition;
83 83
 
84
-		$this->query->set_field( 'where', $where );
84
+		$this->query->set_field('where', $where);
85 85
 	}
86 86
 }
87 87
 
@@ -101,64 +101,64 @@  discard block
 block discarded – undo
101 101
 
102 102
 		var_dump($this->query);
103 103
 		try {
104
-			$this->build_query( $this->query->get() );
105
-		} catch ( WordPoints_Query_Builder_Exception $e ) {
106
-			return new WP_Error( $e->getMessage(), $e->getTraceAsString() );
104
+			$this->build_query($this->query->get());
105
+		} catch (WordPoints_Query_Builder_Exception $e) {
106
+			return new WP_Error($e->getMessage(), $e->getTraceAsString());
107 107
 		}
108 108
 
109 109
 		return $this->sql;
110 110
 	}
111 111
 
112
-	protected function build_query( $query ) {
112
+	protected function build_query($query) {
113 113
 
114
-		var_dump( __METHOD__, $query );
114
+		var_dump(__METHOD__, $query);
115 115
 
116
-		$this->alias = $this->get_alias( $query );
116
+		$this->alias = $this->get_alias($query);
117 117
 
118
-		$this->build_fields( $query );
119
-		$this->build_from( $query );
120
-		$this->build_joins( $query );
121
-		$this->build_where( $query );
118
+		$this->build_fields($query);
119
+		$this->build_from($query);
120
+		$this->build_joins($query);
121
+		$this->build_where($query);
122 122
 		$this->build_select();
123 123
 	}
124 124
 
125 125
 	protected function build_select() {
126 126
 
127
-		if ( empty( $this->fields ) ) {
128
-			throw new WordPoints_Query_Builder_Exception( 'no fields' );
127
+		if (empty($this->fields)) {
128
+			throw new WordPoints_Query_Builder_Exception('no fields');
129 129
 		}
130 130
 
131
-		$this->sql = 'SELECT' . $this->fields . $this->sql;
131
+		$this->sql = 'SELECT'.$this->fields.$this->sql;
132 132
 	}
133 133
 
134
-	protected function build_fields( $query ) {
134
+	protected function build_fields($query) {
135 135
 
136
-		if ( empty( $query['fields'] ) ) {
136
+		if (empty($query['fields'])) {
137 137
 			return;
138 138
 		}
139 139
 
140
-		foreach ( $query['fields'] as $field ) {
140
+		foreach ($query['fields'] as $field) {
141 141
 
142
-			if ( ! is_array( $field ) ) {
143
-				$field = array( 'field' => $field );
142
+			if ( ! is_array($field)) {
143
+				$field = array('field' => $field);
144 144
 			}
145 145
 
146
-			if ( ! isset( $field['field'] ) ) {
147
-				throw new WordPoints_Query_Builder_Exception( 'invalid field' );
146
+			if ( ! isset($field['field'])) {
147
+				throw new WordPoints_Query_Builder_Exception('invalid field');
148 148
 			}
149 149
 
150
-			if ( ! empty( $this->fields ) ) {
150
+			if ( ! empty($this->fields)) {
151 151
 				$this->fields .= ',';
152 152
 			}
153 153
 
154
-			$this->fields .= ' ' . $this->build_field( $field['field'] );
154
+			$this->fields .= ' '.$this->build_field($field['field']);
155 155
 
156 156
 			$as = $field['field'];
157
-			if ( isset( $field['as'] ) ) {
157
+			if (isset($field['as'])) {
158 158
 				$as = $field['as'];
159 159
 			}
160 160
 
161
-			$this->fields .= ' AS `' . $this->escape_identifier( $as ) . '`';
161
+			$this->fields .= ' AS `'.$this->escape_identifier($as).'`';
162 162
 		}
163 163
 	}
164 164
 
@@ -171,118 +171,118 @@  discard block
 block discarded – undo
171 171
 	 *
172 172
 	 * @throws WordPoints_Query_Builder_Exception
173 173
 	 */
174
-	protected function build_field( $field ) {
174
+	protected function build_field($field) {
175 175
 
176
-		$field_name = $this->get_field_name( $field );
176
+		$field_name = $this->get_field_name($field);
177 177
 
178
-		$sql = '`' . $this->escape_identifier( $this->alias ) . '`';
179
-		$sql .= '.`' . $this->escape_identifier( $field_name ) . '`';
178
+		$sql = '`'.$this->escape_identifier($this->alias).'`';
179
+		$sql .= '.`'.$this->escape_identifier($field_name).'`';
180 180
 
181 181
 		return $sql;
182 182
 	}
183 183
 
184
-	protected function build_from( $query ) {
184
+	protected function build_from($query) {
185 185
 
186
-		if ( ! isset( $query['table_name'] ) ) {
187
-			throw new WordPoints_Query_Builder_Exception( 'table_name' );
186
+		if ( ! isset($query['table_name'])) {
187
+			throw new WordPoints_Query_Builder_Exception('table_name');
188 188
 		}
189 189
 
190 190
 		$this->sql .= "\n";
191
-		$this->sql .= 'FROM `' . $this->escape_identifier( $query['table_name'] ) . '`';
192
-		$this->sql .= ' AS `' . $this->escape_identifier( $this->alias ) . '`';
191
+		$this->sql .= 'FROM `'.$this->escape_identifier($query['table_name']).'`';
192
+		$this->sql .= ' AS `'.$this->escape_identifier($this->alias).'`';
193 193
 	}
194 194
 
195
-	protected function build_joins( $query ) {
195
+	protected function build_joins($query) {
196 196
 
197
-		if ( ! isset( $query['joins'] ) ) {
197
+		if ( ! isset($query['joins'])) {
198 198
 			return;
199 199
 		}
200 200
 
201
-		foreach ( $query['joins'] as $join ) {
202
-			$this->build_join( $join );
201
+		foreach ($query['joins'] as $join) {
202
+			$this->build_join($join);
203 203
 		}
204 204
 	}
205 205
 
206
-	protected function build_join( $join ) {
206
+	protected function build_join($join) {
207 207
 
208
-		if ( ! isset( $join['table_name'] ) ) {
209
-			throw new WordPoints_Query_Builder_Exception( 'join table_name' );
208
+		if ( ! isset($join['table_name'])) {
209
+			throw new WordPoints_Query_Builder_Exception('join table_name');
210 210
 		}
211 211
 
212
-		if ( ! isset( $join['on'] ) ) {
213
-			throw new WordPoints_Query_Builder_Exception( 'join on' );
212
+		if ( ! isset($join['on'])) {
213
+			throw new WordPoints_Query_Builder_Exception('join on');
214 214
 		}
215 215
 
216
-		if ( ! isset( $join['on']['join_field'] ) ) {
217
-			throw new WordPoints_Query_Builder_Exception( 'join on join_field' );
216
+		if ( ! isset($join['on']['join_field'])) {
217
+			throw new WordPoints_Query_Builder_Exception('join on join_field');
218 218
 		}
219 219
 
220
-		if ( ! isset( $join['on']['primary_field'] ) ) {
221
-			throw new WordPoints_Query_Builder_Exception( 'join on primary_field' );
220
+		if ( ! isset($join['on']['primary_field'])) {
221
+			throw new WordPoints_Query_Builder_Exception('join on primary_field');
222 222
 		}
223 223
 
224
-		$alias = $this->get_alias( $join );
224
+		$alias = $this->get_alias($join);
225 225
 
226 226
 		$this->sql .= "\n";
227
-		$this->sql .= 'INNER JOIN `' . $this->escape_identifier( $join['table_name'] ) . '`';
228
-		$this->sql .= ' AS `' . $this->escape_identifier( $alias ) . '`';
229
-		$this->sql .= "\n\t" . 'ON ' . $this->build_field( $join['on']['primary_field'] );
227
+		$this->sql .= 'INNER JOIN `'.$this->escape_identifier($join['table_name']).'`';
228
+		$this->sql .= ' AS `'.$this->escape_identifier($alias).'`';
229
+		$this->sql .= "\n\t".'ON '.$this->build_field($join['on']['primary_field']);
230 230
 
231 231
 		$old_alias = $this->alias;
232 232
 		$this->alias = $alias;
233 233
 
234
-		$this->sql .= ' = ' . $this->build_field( $join['on']['join_field'] );
234
+		$this->sql .= ' = '.$this->build_field($join['on']['join_field']);
235 235
 
236
-		$this->build_fields( $join );
236
+		$this->build_fields($join);
237 237
 
238
-		if ( isset( $join['where'] ) ) {
239
-			foreach ( $join['where'] as $condition ) {
240
-				$this->build_condition( $condition );
238
+		if (isset($join['where'])) {
239
+			foreach ($join['where'] as $condition) {
240
+				$this->build_condition($condition);
241 241
 			}
242 242
 		}
243 243
 
244
-		$this->build_joins( $join );
244
+		$this->build_joins($join);
245 245
 
246 246
 		$this->alias = $old_alias;
247 247
 	}
248 248
 
249
-	protected function build_where( $query ) {
249
+	protected function build_where($query) {
250 250
 
251
-		if ( empty( $query['where'] ) ) {
251
+		if (empty($query['where'])) {
252 252
 			return;
253 253
 		}
254 254
 
255 255
 		$this->sql .= "\n";
256 256
 		$this->sql .= 'WHERE 1=1';
257 257
 
258
-		foreach ( $query['where'] as $condition ) {
259
-			$this->build_condition( $condition );
258
+		foreach ($query['where'] as $condition) {
259
+			$this->build_condition($condition);
260 260
 		}
261 261
 	}
262 262
 
263
-	protected function build_condition( $condition ) {
263
+	protected function build_condition($condition) {
264 264
 
265 265
 		global $wpdb;
266 266
 
267
-		if ( ! isset( $condition['field'], $condition['value'] ) ) {
267
+		if ( ! isset($condition['field'], $condition['value'])) {
268 268
 			var_dump($condition);
269
-			throw new WordPoints_Query_Builder_Exception( 'bad condition' );
269
+			throw new WordPoints_Query_Builder_Exception('bad condition');
270 270
 		}
271 271
 
272
-		if ( ! isset( $condition['compare'] ) ) {
272
+		if ( ! isset($condition['compare'])) {
273 273
 			$condition['compare'] = '=';
274 274
 		}
275 275
 
276 276
 		$this->sql .= "\n\t";
277 277
 
278
-		$this->build_condition_type( $condition );
278
+		$this->build_condition_type($condition);
279 279
 
280
-		$field_type = $this->get_field_type( $condition['field'] );
281
-		if ( 'serialized_array' === $field_type ) {
282
-			if ( is_array( $condition['value'] ) ) {
283
-				if ( isset( $condition['compare'] ) && 'in' === $condition['compare'] ) {
280
+		$field_type = $this->get_field_type($condition['field']);
281
+		if ('serialized_array' === $field_type) {
282
+			if (is_array($condition['value'])) {
283
+				if (isset($condition['compare']) && 'in' === $condition['compare']) {
284 284
 					$this->sql .= '( 1=0 ';
285
-					foreach ( $condition['value'] as $index => $value ) {
285
+					foreach ($condition['value'] as $index => $value) {
286 286
 						$this->build_condition(
287 287
 							array(
288 288
 								'type' => 'or',
@@ -296,13 +296,13 @@  discard block
 block discarded – undo
296 296
 					return;
297 297
 				}
298 298
 			} else {
299
-				$condition['value'] = $this->serialize_value( $condition['value'] );
299
+				$condition['value'] = $this->serialize_value($condition['value']);
300 300
 			}
301 301
 		}
302 302
 
303
-		$this->sql .= $this->build_field( $condition['field'] );
303
+		$this->sql .= $this->build_field($condition['field']);
304 304
 
305
-		switch ( $condition['compare'] ) {
305
+		switch ($condition['compare']) {
306 306
 
307 307
 			case '=':
308 308
 				$this->sql .= ' = ';
@@ -313,18 +313,18 @@  discard block
 block discarded – undo
313 313
 				break;
314 314
 
315 315
 			case 'in':
316
-				$this->sql .= ' IN (' . wordpoints_prepare__in( $condition['value'] ) . ')';
316
+				$this->sql .= ' IN ('.wordpoints_prepare__in($condition['value']).')';
317 317
 				return;
318 318
 
319 319
 			default:
320
-				throw new WordPoints_Query_Builder_Exception( 'bad condition comparison' );
320
+				throw new WordPoints_Query_Builder_Exception('bad condition comparison');
321 321
 		}
322 322
 
323
-		if ( ! is_scalar( $condition['value'] ) ) {
324
-			throw new WordPoints_Query_Builder_Exception( 'bad condition value' );
323
+		if ( ! is_scalar($condition['value'])) {
324
+			throw new WordPoints_Query_Builder_Exception('bad condition value');
325 325
 		}
326 326
 
327
-		$this->sql .= $wpdb->prepare( '%s', $condition['value'] );
327
+		$this->sql .= $wpdb->prepare('%s', $condition['value']);
328 328
 	}
329 329
 
330 330
 	/**
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @throws WordPoints_Query_Builder_Exception
338 338
 	 */
339
-	protected function build_condition_type( $condition ) {
339
+	protected function build_condition_type($condition) {
340 340
 
341
-		if ( ! isset( $condition['type'] ) ) {
341
+		if ( ! isset($condition['type'])) {
342 342
 			$condition['type'] = 'and';
343 343
 		}
344 344
 
345
-		switch ( $condition['type'] ) {
345
+		switch ($condition['type']) {
346 346
 
347 347
 			case 'and':
348 348
 				$this->sql .= 'AND ';
@@ -353,21 +353,21 @@  discard block
 block discarded – undo
353 353
 				break;
354 354
 
355 355
 			default:
356
-				throw new WordPoints_Query_Builder_Exception( 'bad condition type' );
356
+				throw new WordPoints_Query_Builder_Exception('bad condition type');
357 357
 		}
358 358
 	}
359 359
 
360
-	protected function escape_identifier( $identifier ) {
360
+	protected function escape_identifier($identifier) {
361 361
 
362
-		return str_replace( '`', '``', $identifier );
362
+		return str_replace('`', '``', $identifier);
363 363
 	}
364 364
 
365
-	protected function get_field_name( $field ) {
365
+	protected function get_field_name($field) {
366 366
 
367
-		if ( is_array( $field ) ) {
367
+		if (is_array($field)) {
368 368
 
369
-			if ( ! isset( $field['name'] ) ) {
370
-				throw new WordPoints_Query_Builder_Exception( 'field name' );
369
+			if ( ! isset($field['name'])) {
370
+				throw new WordPoints_Query_Builder_Exception('field name');
371 371
 			}
372 372
 
373 373
 			$field = $field['name'];
@@ -376,22 +376,22 @@  discard block
 block discarded – undo
376 376
 		return $field;
377 377
 	}
378 378
 
379
-	protected function get_field_type( $field ) {
379
+	protected function get_field_type($field) {
380 380
 
381
-		if ( is_array( $field ) && isset( $field['type'] ) ) {
381
+		if (is_array($field) && isset($field['type'])) {
382 382
 			return $field['type'];
383 383
 		}
384 384
 
385 385
 		return 'string';
386 386
 	}
387 387
 
388
-	protected function serialize_value( $value ) {
388
+	protected function serialize_value($value) {
389 389
 
390
-		if ( is_string( $value ) ) {
391
-			$value = '"' . $value . '"';
390
+		if (is_string($value)) {
391
+			$value = '"'.$value.'"';
392 392
 		}
393 393
 
394
-		return '%:' . $value . ';%';
394
+		return '%:'.$value.';%';
395 395
 	}
396 396
 }
397 397
 
Please login to merge, or discard this patch.
src/includes/classes/spec.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -284,6 +284,9 @@
 block discarded – undo
284 284
 		return $entities;
285 285
 	}
286 286
 
287
+	/**
288
+	 * @param integer $count
289
+	 */
287 290
 	protected function check_count( $count ) {
288 291
 
289 292
 		if ( isset( $this->settings['max'] ) && $count > $this->settings['max'] ) {
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 interface WordPoints_SpecI {
12 12
 	public function get_title();
13 13
 	public function get_settings_fields();
14
-	public function validate_settings( $settings );
14
+	public function validate_settings($settings);
15 15
 	public function is_met();
16
-	public function get_error( $name );
16
+	public function get_error($name);
17 17
 }
18 18
 
19 19
 abstract class WordPoints_Spec implements  WordPoints_SpecI {
@@ -25,38 +25,38 @@  discard block
 block discarded – undo
25 25
 	 * @param $value
26 26
 	 * @param $expected
27 27
 	 */
28
-	public function __construct( $value, $expected ) {
28
+	public function __construct($value, $expected) {
29 29
 		$this->value = $value;
30 30
 		$this->expected = $expected;
31 31
 	}
32 32
 
33
-	public function validate_settings( $settings ) {
33
+	public function validate_settings($settings) {
34 34
 
35
-		$data_types = wordpoints_apps()->get_sub_app( 'data_types' );
35
+		$data_types = wordpoints_apps()->get_sub_app('data_types');
36 36
 
37
-		foreach ( $this->get_settings_fields() as $setting => $data ) {
37
+		foreach ($this->get_settings_fields() as $setting => $data) {
38 38
 
39
-			if ( ! isset( $settings[ $setting ] ) ) {
39
+			if ( ! isset($settings[$setting])) {
40 40
 
41
-				if ( ! empty( $data['required'] ) ) {
41
+				if ( ! empty($data['required'])) {
42 42
 					return 'error'; // TODO
43 43
 				}
44 44
 
45 45
 			} else {
46 46
 
47
-				$data_type = $data_types->get( $data['type'] );
47
+				$data_type = $data_types->get($data['type']);
48 48
 
49
-				if ( ! $data_type instanceof WordPoints_Data_TypeI ) {
49
+				if ( ! $data_type instanceof WordPoints_Data_TypeI) {
50 50
 					continue;
51 51
 				}
52 52
 
53
-				$value = $data_type->validate_value( $settings[ $setting ] );
53
+				$value = $data_type->validate_value($settings[$setting]);
54 54
 
55
-				if ( is_wp_error( $value ) ) {
55
+				if (is_wp_error($value)) {
56 56
 					return $value;
57 57
 				}
58 58
 
59
-				$settings[ $setting ] = $value;
59
+				$settings[$setting] = $value;
60 60
 			}
61 61
 		}
62 62
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 class WordPoints_Spec_Number_Max extends WordPoints_Spec {
68 68
 
69 69
 	public function get_title() {
70
-		return __( 'Maximum', 'wordpoints' );
70
+		return __('Maximum', 'wordpoints');
71 71
 	}
72 72
 
73 73
 	public function get_settings_fields() {
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
 		return $this->value <= $this->expected;
86 86
 	}
87 87
 
88
-	public function get_error( $name ) {
88
+	public function get_error($name) {
89 89
 
90 90
 		return sprintf(
91
-			__( '%1$s must not be more than %2$s.', 'wordpoints' )
91
+			__('%1$s must not be more than %2$s.', 'wordpoints')
92 92
 			, $name
93 93
 			, $this->expected
94 94
 		);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 class WordPoints_Spec_String_Length_Max extends WordPoints_Spec {
99 99
 
100 100
 	public function get_title() {
101
-		return __( 'Maximum Length', 'wordpoints' );
101
+		return __('Maximum Length', 'wordpoints');
102 102
 	}
103 103
 
104 104
 	public function get_settings_fields() {
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
 	}
113 113
 
114 114
 	public function is_met() {
115
-		return strlen( $this->value ) <= $this->expected;
115
+		return strlen($this->value) <= $this->expected;
116 116
 	}
117 117
 
118
-	public function get_error( $name ) {
118
+	public function get_error($name) {
119 119
 
120 120
 		return sprintf(
121
-			__( '%1$s must not be longer than %2$s characters.', 'wordpoints' )
121
+			__('%1$s must not be longer than %2$s characters.', 'wordpoints')
122 122
 			, $name
123 123
 			, $this->expected
124 124
 		);
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 class WordPoints_Spec_String_Contains extends WordPoints_Spec {
130 130
 
131 131
 	public function get_title() {
132
-		return __( 'Contains', 'wordpoints' );
132
+		return __('Contains', 'wordpoints');
133 133
 	}
134 134
 
135 135
 	public function get_settings_fields() {
136 136
 	}
137 137
 
138 138
 	public function is_met() {
139
-		return false !== strpos( $this->value, $this->expected );
139
+		return false !== strpos($this->value, $this->expected);
140 140
 	}
141 141
 
142
-	public function get_error( $name ) {
142
+	public function get_error($name) {
143 143
 
144 144
 		return sprintf(
145
-			__( '%1$s must contain "%2$s".', 'wordpoints' ) // TODO quotes
145
+			__('%1$s must contain "%2$s".', 'wordpoints') // TODO quotes
146 146
 			, $name
147 147
 			, $this->expected
148 148
 		);
@@ -165,19 +165,19 @@  discard block
 block discarded – undo
165 165
 	protected $validator;
166 166
 
167 167
 	public function get_title() {
168
-		return __( 'Contains', 'wordpoints' );
168
+		return __('Contains', 'wordpoints');
169 169
 	}
170 170
 
171 171
 	public function get_settings_fields() {
172 172
 		return array(
173 173
 			'min' => array(
174 174
 				'slug'  => 'min',
175
-				'label' => __( 'Minimum number of items', 'wordpoints' ),
175
+				'label' => __('Minimum number of items', 'wordpoints'),
176 176
 				'type'  => 'number',
177 177
 			),
178 178
 			'max' => array(
179 179
 				'slug'  => 'max',
180
-				'label' => __( 'Maximum number of items', 'wordpoints' ),
180
+				'label' => __('Maximum number of items', 'wordpoints'),
181 181
 				'type'  => 'number',
182 182
 			),
183 183
 		);
@@ -192,18 +192,18 @@  discard block
 block discarded – undo
192 192
 //		WordPoints_Hook_Reaction_Validator $validator
193 193
 	) {
194 194
 
195
-		if ( ! $this->arg_type_supported( $arg, $validator ) ) {
195
+		if ( ! $this->arg_type_supported($arg, $validator)) {
196 196
 			return false;
197 197
 		}
198 198
 
199 199
 		$this->settings = $settings;
200 200
 		$this->validator = $validator;
201 201
 
202
-		if ( ! $this->validate_count() ) {
202
+		if ( ! $this->validate_count()) {
203 203
 			return false;
204 204
 		}
205 205
 
206
-		if ( isset( $settings['conditions'] ) ) {
206
+		if (isset($settings['conditions'])) {
207 207
 			$this->validate_conditions();
208 208
 		}
209 209
 
@@ -213,21 +213,21 @@  discard block
 block discarded – undo
213 213
 	protected function validate_count() {
214 214
 
215 215
 		if (
216
-			! empty( $this->settings['max'] )
217
-			&& ! wordpoints_posint( $this->settings['max'] )
216
+			! empty($this->settings['max'])
217
+			&& ! wordpoints_posint($this->settings['max'])
218 218
 		) {
219 219
 			$this->validator->add_error(
220
-				__( 'The maximum must be a positive integer.', 'wordpoints' )
220
+				__('The maximum must be a positive integer.', 'wordpoints')
221 221
 				, 'max'
222 222
 			);
223 223
 		}
224 224
 
225 225
 		if (
226
-			! empty( $this->settings['min'] )
227
-			&& ! wordpoints_posint( $this->settings['min'] )
226
+			! empty($this->settings['min'])
227
+			&& ! wordpoints_posint($this->settings['min'])
228 228
 		) {
229 229
 			$this->validator->add_error(
230
-				__( 'The minimum must be a positive integer.', 'wordpoints' )
230
+				__('The minimum must be a positive integer.', 'wordpoints')
231 231
 				, 'min'
232 232
 			);
233 233
 		}
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 
238 238
 	protected function validate_conditions() {
239 239
 
240
-		$conditions_extension = wordpoints_hooks()->get_sub_app( 'extensions' )->get(
240
+		$conditions_extension = wordpoints_hooks()->get_sub_app('extensions')->get(
241 241
 			'conditions'
242 242
 		);
243 243
 
244 244
 		$conditions = $conditions_extension->validate_settings(
245
-			array( 'conditions' => $this->settings['conditions'] )
245
+			array('conditions' => $this->settings['conditions'])
246 246
 			, $this->validator
247 247
 			, $this->validator->get_event_args()
248 248
 		);
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
 
253 253
 	public function is_met() {
254 254
 
255
-		$entities = $this->filter_entities( $this->value );
255
+		$entities = $this->filter_entities($this->value);
256 256
 
257
-		return $this->check_count( count( $entities ) );
257
+		return $this->check_count(count($entities));
258 258
 	}
259 259
 
260 260
 	/**
@@ -266,41 +266,41 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return WordPoints_Entity[]
268 268
 	 */
269
-	protected function filter_entities( $entities ) {
269
+	protected function filter_entities($entities) {
270 270
 
271
-		$conditions_extension = wordpoints_hooks()->get_sub_app( 'extensions' )->get(
271
+		$conditions_extension = wordpoints_hooks()->get_sub_app('extensions')->get(
272 272
 			'conditions'
273 273
 		);
274 274
 
275
-		foreach ( $entities as $index => $entity ) {
275
+		foreach ($entities as $index => $entity) {
276 276
 
277 277
 			$matches = $conditions_extension->conditions_are_met(
278 278
 				$this->expected['conditions']
279
-				, new WordPoints_Hook_Event_Args( array( $entity ) )
279
+				, new WordPoints_Hook_Event_Args(array($entity))
280 280
 			);
281 281
 
282
-			if ( ! $matches ) {
283
-				unset( $entities[ $index ] );
282
+			if ( ! $matches) {
283
+				unset($entities[$index]);
284 284
 			}
285 285
 		}
286 286
 
287 287
 		return $entities;
288 288
 	}
289 289
 
290
-	protected function check_count( $count ) {
290
+	protected function check_count($count) {
291 291
 
292
-		if ( isset( $this->settings['max'] ) && $count > $this->settings['max'] ) {
292
+		if (isset($this->settings['max']) && $count > $this->settings['max']) {
293 293
 			return false;
294 294
 		}
295 295
 
296
-		if ( isset( $this->settings['min'] ) && $count < $this->settings['min'] ) {
296
+		if (isset($this->settings['min']) && $count < $this->settings['min']) {
297 297
 			return false;
298 298
 		}
299 299
 
300 300
 		return true;
301 301
 	}
302 302
 
303
-	public function get_error( $name ) {
303
+	public function get_error($name) {
304 304
 		// TODO: Implement get_error() method.
305 305
 	}
306 306
 }
Please login to merge, or discard this patch.
src/hooks-api.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -44,21 +44,21 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @since 1.0.0
46 46
  */
47
-require_once( dirname( __FILE__ ) . '/includes/constants.php' );
47
+require_once(dirname(__FILE__).'/includes/constants.php');
48 48
 
49 49
 /**
50 50
  * The module's functions.
51 51
  *
52 52
  * @since 1.0.0
53 53
  */
54
-require_once( dirname( __FILE__ ) . '/includes/functions.php' );
54
+require_once(dirname(__FILE__).'/includes/functions.php');
55 55
 
56 56
 /**
57 57
  * The module's actions and filters.
58 58
  *
59 59
  * @since 1.0.0
60 60
  */
61
-require_once( dirname( __FILE__ ) . '/includes/actions.php' );
61
+require_once(dirname(__FILE__).'/includes/actions.php');
62 62
 
63 63
 /**
64 64
  * Class autoloader.
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @since 1.0.0
69 69
  */
70
-require_once( dirname( __FILE__ ) . '/includes/classes/class/autoloader.php' );
70
+require_once(dirname(__FILE__).'/includes/classes/class/autoloader.php');
71 71
 
72 72
 // Register the classes to autoload.
73 73
 WordPoints_Class_Autoloader::register_dir(
74
-	dirname( __FILE__ ) . '/includes/classes'
74
+	dirname(__FILE__).'/includes/classes'
75 75
 	, 'WordPoints_'
76 76
 );
77 77
 
78
-if ( is_admin() ) {
78
+if (is_admin()) {
79 79
 
80 80
 	/**
81 81
 	 * Administration-side code.
82 82
 	 *
83 83
 	 * @since 1.0.0
84 84
 	 */
85
-	require_once( dirname( __FILE__ ) . '/admin/admin.php' );
85
+	require_once(dirname(__FILE__).'/admin/admin.php');
86 86
 }
87 87
 
88 88
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/app/registry.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -28,46 +28,46 @@
 block discarded – undo
28 28
 	/**
29 29
 	 * @since 1.0.0
30 30
 	 */
31
-	public function __construct( $slug ) {
31
+	public function __construct($slug) {
32 32
 
33 33
 		$this->registry = new WordPoints_Class_Registry();
34 34
 
35
-		parent::__construct( $slug );
35
+		parent::__construct($slug);
36 36
 	}
37 37
 
38 38
 	/**
39 39
 	 * @since 1.0.0
40 40
 	 */
41
-	public function get_all( array $args = array() ) {
42
-		return $this->registry->get_all( $args );
41
+	public function get_all(array $args = array()) {
42
+		return $this->registry->get_all($args);
43 43
 	}
44 44
 
45 45
 	/**
46 46
 	 * @since 1.0.0
47 47
 	 */
48
-	public function get( $slug, array $args = array() ) {
49
-		return $this->registry->get( $slug, $args );
48
+	public function get($slug, array $args = array()) {
49
+		return $this->registry->get($slug, $args);
50 50
 	}
51 51
 
52 52
 	/**
53 53
 	 * @since 1.0.0
54 54
 	 */
55
-	public function register( $slug, $class, array $args = array() ) {
56
-		return $this->registry->register( $slug, $class, $args );
55
+	public function register($slug, $class, array $args = array()) {
56
+		return $this->registry->register($slug, $class, $args);
57 57
 	}
58 58
 
59 59
 	/**
60 60
 	 * @since 1.0.0
61 61
 	 */
62
-	public function deregister( $slug ) {
63
-		$this->registry->deregister( $slug );
62
+	public function deregister($slug) {
63
+		$this->registry->deregister($slug);
64 64
 	}
65 65
 
66 66
 	/**
67 67
 	 * @since 1.0.0
68 68
 	 */
69
-	public function is_registered( $slug ) {
70
-		return $this->registry->is_registered( $slug );
69
+	public function is_registered($slug) {
70
+		return $this->registry->is_registered($slug);
71 71
 	}
72 72
 }
73 73
 
Please login to merge, or discard this patch.
src/includes/classes/class/autoloader.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -62,15 +62,15 @@  discard block
 block discarded – undo
62 62
 	 * @param string $dir    The full path of the directory.
63 63
 	 * @param string $prefix The prefix used for class names in this directory.
64 64
 	 */
65
-	public static function register_dir( $dir, $prefix ) {
65
+	public static function register_dir($dir, $prefix) {
66 66
 
67
-		if ( ! self::$added_action ) {
68
-			add_action( 'wordpoints_modules_loaded', __CLASS__ . '::init', 0 );
67
+		if ( ! self::$added_action) {
68
+			add_action('wordpoints_modules_loaded', __CLASS__.'::init', 0);
69 69
 			self::$added_action = true;
70 70
 		}
71 71
 
72
-		self::$prefixes[ $prefix ]['length'] = strlen( $prefix );
73
-		self::$prefixes[ $prefix ]['dirs'][] = trailingslashit( $dir );
72
+		self::$prefixes[$prefix]['length'] = strlen($prefix);
73
+		self::$prefixes[$prefix]['dirs'][] = trailingslashit($dir);
74 74
 
75 75
 		self::$sorted = false;
76 76
 	}
@@ -86,31 +86,31 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @param string $class_name The name fo the class to load.
88 88
 	 */
89
-	public static function load_class( $class_name ) {
89
+	public static function load_class($class_name) {
90 90
 
91
-		if ( ! self::$sorted ) {
92
-			arsort( self::$prefixes );
91
+		if ( ! self::$sorted) {
92
+			arsort(self::$prefixes);
93 93
 			self::$sorted = true;
94 94
 		}
95 95
 
96
-		foreach ( self::$prefixes as $prefix => $data ) {
96
+		foreach (self::$prefixes as $prefix => $data) {
97 97
 
98
-			if ( substr( $class_name, 0, $data['length'] ) !== $prefix ) {
98
+			if (substr($class_name, 0, $data['length']) !== $prefix) {
99 99
 				continue;
100 100
 			}
101 101
 
102
-			$trimmed_class_name = substr( $class_name, $data['length'] );
102
+			$trimmed_class_name = substr($class_name, $data['length']);
103 103
 
104
-			$file_name = str_replace( '_', '/', strtolower( $trimmed_class_name ) );
105
-			$file_name = $file_name . '.php';
104
+			$file_name = str_replace('_', '/', strtolower($trimmed_class_name));
105
+			$file_name = $file_name.'.php';
106 106
 
107
-			foreach ( $data['dirs'] as $dir ) {
107
+			foreach ($data['dirs'] as $dir) {
108 108
 
109
-				if ( ! file_exists( $dir . $file_name ) ) {
109
+				if ( ! file_exists($dir.$file_name)) {
110 110
 					continue;
111 111
 				}
112 112
 
113
-				require_once( $dir . $file_name );
113
+				require_once($dir.$file_name);
114 114
 
115 115
 				return;
116 116
 			}
@@ -135,16 +135,16 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	public static function init() {
137 137
 
138
-		if ( function_exists( 'spl_autoload_register' ) ) {
138
+		if (function_exists('spl_autoload_register')) {
139 139
 
140
-			spl_autoload_register( __CLASS__ . '::load_class' );
140
+			spl_autoload_register(__CLASS__.'::load_class');
141 141
 
142 142
 		} else {
143 143
 
144
-			foreach ( self::$prefixes as $prefix => $data ) {
145
-				foreach ( $data['dirs'] as $dir ) {
146
-					if ( file_exists( $dir . '/index.php' ) ) {
147
-						require( $dir . '/index.php' );
144
+			foreach (self::$prefixes as $prefix => $data) {
145
+				foreach ($data['dirs'] as $dir) {
146
+					if (file_exists($dir.'/index.php')) {
147
+						require($dir.'/index.php');
148 148
 					}
149 149
 				}
150 150
 			}
Please login to merge, or discard this patch.
src/includes/classes/class/registry/persistent.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
 	/**
30 30
 	 * @since 1.0.0
31 31
 	 */
32
-	public function get_all( array $args = array() ) {
32
+	public function get_all(array $args = array()) {
33 33
 
34
-		$classes = array_diff_key( $this->classes, $this->objects );
34
+		$classes = array_diff_key($this->classes, $this->objects);
35 35
 
36
-		if ( ! empty( $classes ) ) {
36
+		if ( ! empty($classes)) {
37 37
 
38 38
 			$objects = WordPoints_Class_Registry::construct_with_args(
39 39
 				$classes
@@ -49,40 +49,40 @@  discard block
 block discarded – undo
49 49
 	/**
50 50
 	 * @since 1.0.0
51 51
 	 */
52
-	public function get( $slug, array $args = array() ) {
52
+	public function get($slug, array $args = array()) {
53 53
 
54
-		if ( ! isset( $this->objects[ $slug ] ) ) {
54
+		if ( ! isset($this->objects[$slug])) {
55 55
 
56
-			$object = parent::get( $slug, $args );
56
+			$object = parent::get($slug, $args);
57 57
 
58
-			if ( ! $object ) {
58
+			if ( ! $object) {
59 59
 				return false;
60 60
 			}
61 61
 
62
-			$this->objects[ $slug ] = $object;
62
+			$this->objects[$slug] = $object;
63 63
 		}
64 64
 
65
-		return $this->objects[ $slug ];
65
+		return $this->objects[$slug];
66 66
 	}
67 67
 
68 68
 	/**
69 69
 	 * @since 1.0.0
70 70
 	 */
71
-	public function register( $slug, $class, array $args = array() ) {
71
+	public function register($slug, $class, array $args = array()) {
72 72
 
73
-		unset( $this->objects[ $slug ] );
73
+		unset($this->objects[$slug]);
74 74
 
75
-		return parent::register( $slug, $class, $args );
75
+		return parent::register($slug, $class, $args);
76 76
 	}
77 77
 
78 78
 	/**
79 79
 	 * @since 1.0.0
80 80
 	 */
81
-	public function deregister( $slug ) {
81
+	public function deregister($slug) {
82 82
 
83
-		parent::deregister( $slug );
83
+		parent::deregister($slug);
84 84
 
85
-		unset( $this->objects[ $slug ] );
85
+		unset($this->objects[$slug]);
86 86
 	}
87 87
 }
88 88
 
Please login to merge, or discard this patch.
src/includes/classes/class/registryi.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @return object|false The object or false if it is not registered.
43 43
 	 */
44
-	public function get( $slug );
44
+	public function get($slug);
45 45
 
46 46
 	/**
47 47
 	 * Register a type of object.
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return bool Whether the class was registered successfully.
56 56
 	 */
57
-	public function register( $slug, $class, array $args = array() );
57
+	public function register($slug, $class, array $args = array());
58 58
 
59 59
 	/**
60 60
 	 * Deregister a type of object
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @param string $slug The slug of the class to deregister.
65 65
 	 */
66
-	public function deregister( $slug );
66
+	public function deregister($slug);
67 67
 
68 68
 	/**
69 69
 	 * Check if a type of object is registered by its slug.
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return bool Whether the class is registered.
76 76
 	 */
77
-	public function is_registered( $slug );
77
+	public function is_registered($slug);
78 78
 }
79 79
 
80 80
 // EOF
Please login to merge, or discard this patch.