Completed
Push — master ( dce43d...f66823 )
by J.D.
04:19
created
src/classes/hook/reaction/validator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 
120 120
 			$this->settings = $settings;
121 121
 
122
-			if ( isset( $this->settings['event'] ) ) {
123
-				$this->event_slug = $this->settings['event'];
122
+			if ( isset( $this->settings[ 'event' ] ) ) {
123
+				$this->event_slug = $this->settings[ 'event' ];
124 124
 			}
125 125
 
126
-			if ( isset( $this->settings['reactor'] ) ) {
127
-				$this->reactor_slug = $this->settings['reactor'];
126
+			if ( isset( $this->settings[ 'reactor' ] ) ) {
127
+				$this->reactor_slug = $this->settings[ 'reactor' ];
128 128
 			}
129 129
 		}
130 130
 	}
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
 		$field_stack = $this->field_stack;
230 230
 
231 231
 		if ( null !== $field ) {
232
-			$field_stack[] = $field;
232
+			$field_stack[ ] = $field;
233 233
 		}
234 234
 
235
-		$this->errors[] = array( 'message' => $message, 'field' => $field_stack );
235
+		$this->errors[ ] = array( 'message' => $message, 'field' => $field_stack );
236 236
 
237 237
 		if ( $this->fail_fast ) {
238 238
 			throw new WordPoints_Hook_Validator_Exception;
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 * @param string $field The field.
270 270
 	 */
271 271
 	public function push_field( $field ) {
272
-		$this->field_stack[] = $field;
272
+		$this->field_stack[ ] = $field;
273 273
 	}
274 274
 
275 275
 	/**
Please login to merge, or discard this patch.
src/classes/hook/action.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 		$this->slug = $slug;
89 89
 		$this->args = $action_args;
90 90
 
91
-		if ( isset( $args['requirements'] ) ) {
92
-			$this->requirements = $args['requirements'];
91
+		if ( isset( $args[ 'requirements' ] ) ) {
92
+			$this->requirements = $args[ 'requirements' ];
93 93
 		}
94 94
 
95
-		if ( isset( $args['arg_index'] ) ) {
96
-			$this->arg_index = $args['arg_index'];
95
+		if ( isset( $args[ 'arg_index' ] ) ) {
96
+			$this->arg_index = $args[ 'arg_index' ];
97 97
 		}
98 98
 	}
99 99
 
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 
114 114
 			$comparator = '=';
115 115
 
116
-			if ( is_array( $value ) && isset( $value['comparator'], $value['value'] ) ) {
117
-				$comparator = $value['comparator'];
118
-				$value = $value['value'];
116
+			if ( is_array( $value ) && isset( $value[ 'comparator' ], $value[ 'value' ] ) ) {
117
+				$comparator = $value[ 'comparator' ];
118
+				$value = $value[ 'value' ];
119 119
 			}
120 120
 
121 121
 			switch ( $comparator ) {
Please login to merge, or discard this patch.
src/classes/hook/router.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 
96 96
 		// Return the first value, in case it is hooked to a filter.
97 97
 		$return = null;
98
-		if ( isset( $args[0] ) ) {
99
-			$return = $args[0];
98
+		if ( isset( $args[ 0 ] ) ) {
99
+			$return = $args[ 0 ];
100 100
 		}
101 101
 
102 102
 		return $return;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 			$this->event_args = $this->events->get_sub_app( 'args' );
133 133
 		}
134 134
 
135
-		foreach ( $this->action_index[ $name ]['actions'] as $slug => $data ) {
135
+		foreach ( $this->action_index[ $name ][ 'actions' ] as $slug => $data ) {
136 136
 
137 137
 			if ( ! isset( $this->event_index[ $slug ] ) ) {
138 138
 				continue;
@@ -195,53 +195,53 @@  discard block
 block discarded – undo
195 195
 	public function add_action( $slug, array $args ) {
196 196
 
197 197
 		$priority = 10;
198
-		if ( isset( $args['priority'] ) ) {
199
-			$priority = $args['priority'];
198
+		if ( isset( $args[ 'priority' ] ) ) {
199
+			$priority = $args[ 'priority' ];
200 200
 		}
201 201
 
202
-		if ( ! isset( $args['action'] ) ) {
202
+		if ( ! isset( $args[ 'action' ] ) ) {
203 203
 			return;
204 204
 		}
205 205
 
206
-		$method = "{$args['action']},{$priority}";
206
+		$method = "{$args[ 'action' ]},{$priority}";
207 207
 
208
-		$this->action_index[ $method ]['actions'][ $slug ] = array();
208
+		$this->action_index[ $method ][ 'actions' ][ $slug ] = array();
209 209
 
210 210
 		$arg_number = 1;
211 211
 
212
-		if ( isset( $args['data'] ) ) {
212
+		if ( isset( $args[ 'data' ] ) ) {
213 213
 
214
-			if ( isset( $args['data']['arg_index'] ) ) {
215
-				$arg_number = 1 + max( $args['data']['arg_index'] );
214
+			if ( isset( $args[ 'data' ][ 'arg_index' ] ) ) {
215
+				$arg_number = 1 + max( $args[ 'data' ][ 'arg_index' ] );
216 216
 			}
217 217
 
218
-			if ( isset( $args['data']['requirements'] ) ) {
219
-				$requirements = 1 + max( array_keys( $args['data']['requirements'] ) );
218
+			if ( isset( $args[ 'data' ][ 'requirements' ] ) ) {
219
+				$requirements = 1 + max( array_keys( $args[ 'data' ][ 'requirements' ] ) );
220 220
 
221 221
 				if ( $requirements > $arg_number ) {
222 222
 					$arg_number = $requirements;
223 223
 				}
224 224
 			}
225 225
 
226
-			$this->action_index[ $method ]['actions'][ $slug ] = $args['data'];
226
+			$this->action_index[ $method ][ 'actions' ][ $slug ] = $args[ 'data' ];
227 227
 		}
228 228
 
229
-		if ( isset( $args['arg_number'] ) ) {
230
-			$arg_number = $args['arg_number'];
229
+		if ( isset( $args[ 'arg_number' ] ) ) {
230
+			$arg_number = $args[ 'arg_number' ];
231 231
 		}
232 232
 
233 233
 		// If this action is already being routed, and will have enough args, we
234 234
 		// don't need to hook to it again.
235 235
 		if (
236
-			isset( $this->action_index[ $method ]['arg_number'] )
237
-			&& $this->action_index[ $method ]['arg_number'] >= $arg_number
236
+			isset( $this->action_index[ $method ][ 'arg_number' ] )
237
+			&& $this->action_index[ $method ][ 'arg_number' ] >= $arg_number
238 238
 		) {
239 239
 			return;
240 240
 		}
241 241
 
242
-		$this->action_index[ $method ]['arg_number'] = $arg_number;
242
+		$this->action_index[ $method ][ 'arg_number' ] = $arg_number;
243 243
 
244
-		add_action( $args['action'], array( $this, $method ), $priority, $arg_number );
244
+		add_action( $args[ 'action' ], array( $this, $method ), $priority, $arg_number );
245 245
 	}
246 246
 
247 247
 	/**
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
 	public function remove_action( $slug ) {
255 255
 
256 256
 		foreach ( $this->action_index as $method => $data ) {
257
-			if ( isset( $data['actions'][ $slug ] ) ) {
257
+			if ( isset( $data[ 'actions' ][ $slug ] ) ) {
258 258
 
259
-				unset( $this->action_index[ $method ]['actions'][ $slug ] );
259
+				unset( $this->action_index[ $method ][ 'actions' ][ $slug ] );
260 260
 
261
-				if ( empty( $this->action_index[ $method ]['actions'] ) ) {
261
+				if ( empty( $this->action_index[ $method ][ 'actions' ] ) ) {
262 262
 
263 263
 					unset( $this->action_index[ $method ] );
264 264
 
Please login to merge, or discard this patch.
src/classes/hook/action/post/type.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,23 +50,23 @@  discard block
 block discarded – undo
50 50
 
51 51
 		$parts = wordpoints_parse_dynamic_slug( $this->slug );
52 52
 
53
-		if ( ! $parts['dynamic'] ) {
53
+		if ( ! $parts[ 'dynamic' ] ) {
54 54
 			return false;
55 55
 		}
56 56
 
57 57
 		$this->post_hierarchy = str_replace(
58 58
 			'\\post'
59
-			, '\\' . $parts['dynamic']
59
+			, '\\' . $parts[ 'dynamic' ]
60 60
 			, $this->post_hierarchy
61 61
 		);
62 62
 
63
-		$entity = wordpoints_entities()->get( $this->post_hierarchy[0] );
63
+		$entity = wordpoints_entities()->get( $this->post_hierarchy[ 0 ] );
64 64
 
65 65
 		if ( ! $entity instanceof WordPoints_Entity ) {
66 66
 			return false;
67 67
 		}
68 68
 
69
-		$entity->set_the_value( $this->get_arg_value( $this->post_hierarchy[0] ) );
69
+		$entity->set_the_value( $this->get_arg_value( $this->post_hierarchy[ 0 ] ) );
70 70
 
71 71
 		if ( 1 === count( $this->post_hierarchy ) ) {
72 72
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 			}
84 84
 		}
85 85
 
86
-		if ( $parts['dynamic'] !== $post_entity->get_the_attr_value( 'post_type' ) ) {
86
+		if ( $parts[ 'dynamic' ] !== $post_entity->get_the_attr_value( 'post_type' ) ) {
87 87
 			return false;
88 88
 		}
89 89
 
Please login to merge, or discard this patch.
src/classes/hook/action/comment/new.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@
 block discarded – undo
25 25
 	 */
26 26
 	public function should_fire() {
27 27
 
28
-		if ( ! isset( $this->args[1]->comment_approved ) ) {
28
+		if ( ! isset( $this->args[ 1 ]->comment_approved ) ) {
29 29
 			return false;
30 30
 		}
31 31
 
32
-		if ( 1 !== (int) $this->args[1]->comment_approved ) {
32
+		if ( 1 !== (int) $this->args[ 1 ]->comment_approved ) {
33 33
 			return false;
34 34
 		}
35 35
 
Please login to merge, or discard this patch.
src/classes/hook/arg.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,8 +77,8 @@
 block discarded – undo
77 77
 
78 78
 		$parts = explode( ':', $slug, 2 );
79 79
 
80
-		if ( isset( $parts[1] ) ) {
81
-			$this->entity_slug = $parts[1];
80
+		if ( isset( $parts[ 1 ] ) ) {
81
+			$this->entity_slug = $parts[ 1 ];
82 82
 		} else {
83 83
 			$this->entity_slug = $slug;
84 84
 		}
Please login to merge, or discard this patch.
src/classes/hook/extension/periods.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
 		$period_units = array(
42 42
 			1                   => __( 'Seconds', 'wordpoints' ),
43 43
 			MINUTE_IN_SECONDS   => __( 'Minutes', 'wordpoints' ),
44
-			HOUR_IN_SECONDS     => __( 'Hours',   'wordpoints' ),
45
-			DAY_IN_SECONDS      => __( 'Days',    'wordpoints' ),
46
-			WEEK_IN_SECONDS     => __( 'Weeks',   'wordpoints' ),
47
-			30 * DAY_IN_SECONDS => __( 'Months',  'wordpoints' ),
44
+			HOUR_IN_SECONDS     => __( 'Hours', 'wordpoints' ),
45
+			DAY_IN_SECONDS      => __( 'Days', 'wordpoints' ),
46
+			WEEK_IN_SECONDS     => __( 'Weeks', 'wordpoints' ),
47
+			30 * DAY_IN_SECONDS => __( 'Months', 'wordpoints' ),
48 48
 		);
49 49
 
50 50
 		/**
@@ -122,17 +122,17 @@  discard block
 block discarded – undo
122 122
 			return false;
123 123
 		}
124 124
 
125
-		if ( isset( $period['args'] ) ) {
126
-			$this->validate_period_args( $period['args'] );
125
+		if ( isset( $period[ 'args' ] ) ) {
126
+			$this->validate_period_args( $period[ 'args' ] );
127 127
 		}
128 128
 
129
-		if ( ! isset( $period['length'] ) ) {
129
+		if ( ! isset( $period[ 'length' ] ) ) {
130 130
 
131 131
 			$this->validator->add_error(
132 132
 				__( 'Period length setting is missing.', 'wordpoints' )
133 133
 			);
134 134
 
135
-		} elseif ( false === wordpoints_posint( $period['length'] ) ) {
135
+		} elseif ( false === wordpoints_posint( $period[ 'length' ] ) ) {
136 136
 
137 137
 			$this->validator->add_error(
138 138
 				__( 'Period length must be a positive integer.', 'wordpoints' )
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
 		$now = current_time( 'timestamp', true );
238 238
 		$hit_time = strtotime( $period->date, $now );
239 239
 
240
-		if ( ! empty( $settings['relative'] ) ) {
240
+		if ( ! empty( $settings[ 'relative' ] ) ) {
241 241
 
242
-			return ( $now > $hit_time + $settings['length'] );
242
+			return ( $now > $hit_time + $settings[ 'length' ] );
243 243
 
244 244
 		} else {
245 245
 
246 246
 			$offset = get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
247 247
 
248 248
 			return (
249
-				(int) ( ( $hit_time + $offset ) / $settings['length'] )
250
-				< (int) ( ( $now + $offset ) / $settings['length'] )
249
+				(int) ( ( $hit_time + $offset ) / $settings[ 'length' ] )
250
+				< (int) ( ( $now + $offset ) / $settings[ 'length' ] )
251 251
 			);
252 252
 		}
253 253
 	}
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
 					LIMIT 1
372 372
 				"
373 373
 				, $signature
374
-				, $reaction_guid['mode']
375
-				, $reaction_guid['store']
376
-				, wp_json_encode( $reaction_guid['context_id'] )
377
-				, $reaction_guid['id']
374
+				, $reaction_guid[ 'mode' ]
375
+				, $reaction_guid[ 'store' ]
376
+				, wp_json_encode( $reaction_guid[ 'context_id' ] )
377
+				, $reaction_guid[ 'id' ]
378 378
 				, $this->action_type
379 379
 			)
380 380
 		);
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 		WordPoints_Hook_ReactionI $reaction
432 432
 	) {
433 433
 
434
-		if ( isset( $settings['args'] ) ) {
435
-			$period_args = $settings['args'];
434
+		if ( isset( $settings[ 'args' ] ) ) {
435
+			$period_args = $settings[ 'args' ];
436 436
 		} else {
437 437
 			$period_args = array( $reaction->get_meta( 'target' ) );
438 438
 		}
Please login to merge, or discard this patch.
src/classes/hook/extension/conditions.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	protected function validate_condition( $settings ) {
157 157
 
158
-		if ( ! isset( $settings['type'] ) ) {
158
+		if ( ! isset( $settings[ 'type' ] ) ) {
159 159
 			$this->validator->add_error( __( 'Condition type is missing.', 'wordpoints' ) );
160 160
 			return false;
161 161
 		}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 			return false;
173 173
 		}
174 174
 
175
-		$condition = $this->conditions->get( $data_type, $settings['type'] );
175
+		$condition = $this->conditions->get( $data_type, $settings[ 'type' ] );
176 176
 
177 177
 		if ( ! $condition ) {
178 178
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 				sprintf(
181 181
 					// translators: Condition type slug.
182 182
 					__( 'Unknown condition type &#8220;%s&#8221;.', 'wordpoints' )
183
-					, $settings['type']
183
+					, $settings[ 'type' ]
184 184
 				)
185 185
 				, 'type'
186 186
 			);
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 			return false;
189 189
 		}
190 190
 
191
-		if ( ! isset( $settings['settings'] ) ) {
191
+		if ( ! isset( $settings[ 'settings' ] ) ) {
192 192
 			$this->validator->add_error( __( 'Condition settings are missing.', 'wordpoints' ) );
193 193
 			return false;
194 194
 		}
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 		// reset, so we need to back up their values and then restore them below.
201 201
 		$backup = array( $this->validator, $this->event_args );
202 202
 
203
-		$settings['settings'] = $condition->validate_settings(
203
+		$settings[ 'settings' ] = $condition->validate_settings(
204 204
 			$arg
205
-			, $settings['settings']
205
+			, $settings[ 'settings' ]
206 206
 			, $this->validator
207 207
 		);
208 208
 
@@ -246,16 +246,16 @@  discard block
 block discarded – undo
246 246
 
247 247
 			$event_args->descend( $arg_slug );
248 248
 
249
-			if ( isset( $sub_args['_conditions'] ) ) {
249
+			if ( isset( $sub_args[ '_conditions' ] ) ) {
250 250
 
251
-				foreach ( $sub_args['_conditions'] as $settings ) {
251
+				foreach ( $sub_args[ '_conditions' ] as $settings ) {
252 252
 
253 253
 					$condition = $this->conditions->get(
254 254
 						$this->get_data_type( $event_args->get_current() )
255
-						, $settings['type']
255
+						, $settings[ 'type' ]
256 256
 					);
257 257
 
258
-					$is_met = $condition->is_met( $settings['settings'], $event_args );
258
+					$is_met = $condition->is_met( $settings[ 'settings' ], $event_args );
259 259
 
260 260
 					if ( ! $is_met ) {
261 261
 						$event_args->ascend();
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 					}
264 264
 				}
265 265
 
266
-				unset( $sub_args['_conditions'] );
266
+				unset( $sub_args[ '_conditions' ] );
267 267
 			}
268 268
 
269 269
 			$are_met = $this->conditions_are_met( $sub_args, $event_args );
Please login to merge, or discard this patch.
src/classes/hook/extension/reversals.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 
78 78
 		// We cache these so that we don't run the query both before and after the
79 79
 		// fire.
80
-		if ( isset( $fire->data[ $this->slug ]['hit_ids'] ) ) {
81
-			return $fire->data[ $this->slug ]['hit_ids'];
80
+		if ( isset( $fire->data[ $this->slug ][ 'hit_ids' ] ) ) {
81
+			return $fire->data[ $this->slug ][ 'hit_ids' ];
82 82
 		}
83 83
 
84 84
 		$query = $fire->get_matching_hits_query();
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 			$ids = array();
99 99
 		}
100 100
 
101
-		$fire->data[ $this->slug ]['hit_ids'] = $ids;
101
+		$fire->data[ $this->slug ][ 'hit_ids' ] = $ids;
102 102
 
103 103
 		return $ids;
104 104
 	}
Please login to merge, or discard this patch.