Completed
Push — master ( ab42dc...31131b )
by Mike
21:11 queued 57s
created
src/Controllers/Version4/CustomerDownloads.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 	 * Register the routes for customers.
28 28
 	 */
29 29
 	public function register_routes() {
30
-		$this->register_items_route( [ 'read' ] );
30
+		$this->register_items_route( ['read'] );
31 31
 	}
32 32
 
33 33
 	/**
Please login to merge, or discard this patch.
src/Controllers/Version4/SettingsOptions.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 			// Get the option value.
174 174
 			if ( is_array( $option_key ) ) {
175 175
 				$option           = get_option( $option_key[0] );
176
-				$setting['value'] = isset( $option[ $option_key[1] ] ) ? $option[ $option_key[1] ] : $default;
176
+				$setting['value'] = isset( $option[$option_key[1]] ) ? $option[$option_key[1]] : $default;
177 177
 			} else {
178 178
 				$admin_setting_value = \WC_Admin_Settings::get_option( $option_key, $default );
179 179
 				$setting['value']    = $admin_setting_value;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 				$setting['type']    = 'select';
187 187
 				$setting['options'] = $this->get_countries_and_states();
188 188
 			} elseif ( 'single_select_page' === $setting['type'] ) {
189
-				$pages   = get_pages(
189
+				$pages = get_pages(
190 190
 					array(
191 191
 						'sort_column'  => 'menu_order',
192 192
 						'sort_order'   => 'ASC',
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 				);
196 196
 				$options = array();
197 197
 				foreach ( $pages as $page ) {
198
-					$options[ $page->ID ] = ! empty( $page->post_title ) ? $page->post_title : '#' . $page->ID;
198
+					$options[$page->ID] = ! empty( $page->post_title ) ? $page->post_title : '#' . $page->ID;
199 199
 				}
200 200
 				$setting['type']    = 'select';
201 201
 				$setting['options'] = $options;
@@ -224,10 +224,10 @@  discard block
 block discarded – undo
224 224
 
225 225
 			if ( $states ) {
226 226
 				foreach ( $states as $state_key => $state_value ) {
227
-					$output[ $key . ':' . $state_key ] = $value . ' - ' . $state_value;
227
+					$output[$key . ':' . $state_key] = $value . ' - ' . $state_value;
228 228
 				}
229 229
 			} else {
230
-				$output[ $key ] = $value;
230
+				$output[$key] = $value;
231 231
 			}
232 232
 		}
233 233
 		return $output;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			return new \WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) );
259 259
 		}
260 260
 
261
-		$setting = $settings[ $array_key[0] ];
261
+		$setting = $settings[$array_key[0]];
262 262
 
263 263
 		if ( ! $this->is_setting_type_valid( $setting['type'] ) ) {
264 264
 			return new \WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) );
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	protected function get_batch_of_items_from_request( $request, $batch_type ) {
284 284
 		$params = $request->get_params();
285 285
 
286
-		if ( ! isset( $params[ $batch_type ] ) ) {
286
+		if ( ! isset( $params[$batch_type] ) ) {
287 287
 			return array();
288 288
 		}
289 289
 
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
 		 * Since our batch settings update is group-specific and matches based on the route,
292 292
 		 * we inject the URL parameters (containing group) into the batch items
293 293
 		 */
294
-		$items = array_filter( $params[ $batch_type ] );
294
+		$items = array_filter( $params[$batch_type] );
295 295
 
296 296
 		if ( 'update' === $batch_type ) {
297 297
 			foreach ( $items as $key => $item ) {
298
-				$items[ $key ] = array_merge( $request->get_url_params(), $item );
298
+				$items[$key] = array_merge( $request->get_url_params(), $item );
299 299
 			}
300 300
 		}
301 301
 
@@ -330,11 +330,11 @@  discard block
 block discarded – undo
330 330
 			$setting['value']       = $value;
331 331
 			$option_key             = $setting['option_key'];
332 332
 			$prev                   = get_option( $option_key[0] );
333
-			$prev[ $option_key[1] ] = $request['value'];
333
+			$prev[$option_key[1]] = $request['value'];
334 334
 			update_option( $option_key[0], $prev );
335 335
 		} else {
336 336
 			$update_data                           = array();
337
-			$update_data[ $setting['option_key'] ] = $value;
337
+			$update_data[$setting['option_key']] = $value;
338 338
 			$setting['value']                      = $value;
339 339
 			\WC_Admin_Settings::save_fields( array( $setting ), $update_data );
340 340
 		}
@@ -448,10 +448,10 @@  discard block
 block discarded – undo
448 448
 	 */
449 449
 	public function cast_image_width( $setting ) {
450 450
 		foreach ( array( 'default', 'value' ) as $key ) {
451
-			if ( isset( $setting[ $key ] ) ) {
452
-				$setting[ $key ]['width']  = intval( $setting[ $key ]['width'] );
453
-				$setting[ $key ]['height'] = intval( $setting[ $key ]['height'] );
454
-				$setting[ $key ]['crop']   = (bool) $setting[ $key ]['crop'];
451
+			if ( isset( $setting[$key] ) ) {
452
+				$setting[$key]['width']  = intval( $setting[$key]['width'] );
453
+				$setting[$key]['height'] = intval( $setting[$key]['height'] );
454
+				$setting[$key]['crop']   = (bool) $setting[$key]['crop'];
455 455
 			}
456 456
 		}
457 457
 		return $setting;
@@ -491,17 +491,17 @@  discard block
 block discarded – undo
491 491
 	public function is_setting_type_valid( $type ) {
492 492
 		return in_array(
493 493
 			$type, array(
494
-				'text',         // Validates with validate_setting_text_field.
495
-				'email',        // Validates with validate_setting_text_field.
496
-				'number',       // Validates with validate_setting_text_field.
497
-				'color',        // Validates with validate_setting_text_field.
498
-				'password',     // Validates with validate_setting_text_field.
499
-				'textarea',     // Validates with validate_setting_textarea_field.
500
-				'select',       // Validates with validate_setting_select_field.
501
-				'multiselect',  // Validates with validate_setting_multiselect_field.
502
-				'radio',        // Validates with validate_setting_radio_field (-> validate_setting_select_field).
503
-				'checkbox',     // Validates with validate_setting_checkbox_field.
504
-				'image_width',  // Validates with validate_setting_image_width_field.
494
+				'text', // Validates with validate_setting_text_field.
495
+				'email', // Validates with validate_setting_text_field.
496
+				'number', // Validates with validate_setting_text_field.
497
+				'color', // Validates with validate_setting_text_field.
498
+				'password', // Validates with validate_setting_text_field.
499
+				'textarea', // Validates with validate_setting_textarea_field.
500
+				'select', // Validates with validate_setting_select_field.
501
+				'multiselect', // Validates with validate_setting_multiselect_field.
502
+				'radio', // Validates with validate_setting_radio_field (-> validate_setting_select_field).
503
+				'checkbox', // Validates with validate_setting_checkbox_field.
504
+				'image_width', // Validates with validate_setting_image_width_field.
505 505
 				'thumbnail_cropping', // Validates with validate_setting_text_field.
506 506
 			)
507 507
 		);
Please login to merge, or discard this patch.
src/Controllers/Version4/BatchTrait.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 			return $limit;
26 26
 		}
27 27
 
28
-		$batches  = [ 'create', 'update', 'delete' ];
28
+		$batches  = ['create', 'update', 'delete'];
29 29
 		$response = [];
30 30
 
31 31
 		foreach ( $batches as $batch ) {
32
-			$response[ $batch ] = $this->{"batch_$batch"}( $this->get_batch_of_items_from_request( $request, $batch ) );
32
+			$response[$batch] = $this->{"batch_$batch"}( $this->get_batch_of_items_from_request( $request, $batch ) );
33 33
 		}
34 34
 
35 35
 		return array_filter( $response );
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 	protected function get_batch_of_items_from_request( $request, $batch_type ) {
46 46
 		$params = $request->get_params();
47 47
 
48
-		if ( ! isset( $params[ $batch_type ] ) ) {
48
+		if ( ! isset( $params[$batch_type] ) ) {
49 49
 			return array();
50 50
 		}
51 51
 
52
-		return array_filter( $params[ $batch_type ] );
52
+		return array_filter( $params[$batch_type] );
53 53
 	}
54 54
 
55 55
 	/**
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
 	protected function check_batch_limit( $items ) {
142 142
 		$limit   = apply_filters( 'woocommerce_rest_batch_items_limit', 100, $this->get_normalized_rest_base() );
143 143
 		$total   = 0;
144
-		$batches = [ 'create', 'update', 'delete' ];
144
+		$batches = ['create', 'update', 'delete'];
145 145
 
146 146
 		foreach ( $batches as $batch ) {
147
-			if ( ! isset( $items[ $batch ] ) ) {
147
+			if ( ! isset( $items[$batch] ) ) {
148 148
 				continue;
149 149
 			}
150
-			$total = $total + count( $items[ $batch ] );
150
+			$total = $total + count( $items[$batch] );
151 151
 		}
152 152
 
153 153
 		if ( $total > $limit ) {
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		$schema   = $this->get_public_item_schema();
169 169
 		foreach ( $schema['properties'] as $arg => $options ) {
170 170
 			if ( isset( $options['default'] ) ) {
171
-				$defaults[ $arg ] = $options['default'];
171
+				$defaults[$arg] = $options['default'];
172 172
 			}
173 173
 		}
174 174
 		return $defaults;
Please login to merge, or discard this patch.
src/Controllers/Version4/AbstractController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @param array $methods Supported methods. read, create.
47 47
 	 */
48
-	protected function register_items_route( $methods = [ 'read', 'create' ] ) {
48
+	protected function register_items_route( $methods = ['read', 'create'] ) {
49 49
 		$routes           = [];
50
-		$routes['schema'] = [ $this, 'get_public_item_schema' ];
50
+		$routes['schema'] = [$this, 'get_public_item_schema'];
51 51
 
52 52
 		if ( in_array( 'read', $methods, true ) ) {
53 53
 			$routes[] = array(
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param array $methods Supported methods. read, create.
82 82
 	 */
83
-	protected function register_item_route( $methods = [ 'read', 'edit', 'delete' ] ) {
83
+	protected function register_item_route( $methods = ['read', 'edit', 'delete'] ) {
84 84
 		$routes           = [];
85
-		$routes['schema'] = [ $this, 'get_public_item_schema' ];
85
+		$routes['schema'] = [$this, 'get_public_item_schema'];
86 86
 		$routes['args']   = [
87 87
 			'id' => [
88 88
 				'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
Please login to merge, or discard this patch.
src/Controllers/Version4/Products.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
 			'low_in_stock',
352 352
 		);
353 353
 		foreach ( $custom_keys as $key ) {
354
-			if ( ! empty( $request[ $key ] ) ) {
355
-				$args[ $key ] = $request[ $key ];
354
+			if ( ! empty( $request[$key] ) ) {
355
+				$args[$key] = $request[$key];
356 356
 			}
357 357
 		}
358 358
 
@@ -369,11 +369,11 @@  discard block
 block discarded – undo
369 369
 
370 370
 		// Set tax_query for each passed arg.
371 371
 		foreach ( $taxonomies as $taxonomy => $key ) {
372
-			if ( ! empty( $request[ $key ] ) ) {
372
+			if ( ! empty( $request[$key] ) ) {
373 373
 				$tax_query[] = array(
374 374
 					'taxonomy' => $taxonomy,
375 375
 					'field'    => 'term_id',
376
-					'terms'    => $request[ $key ],
376
+					'terms'    => $request[$key],
377 377
 				);
378 378
 			}
379 379
 		}
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 			// Use 0 when there's no on sale products to avoid return all products.
437 437
 			$on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids;
438 438
 
439
-			$args[ $on_sale_key ] += $on_sale_ids;
439
+			$args[$on_sale_key] += $on_sale_ids;
440 440
 		}
441 441
 
442 442
 		// Force the post_type argument, since it's not a user input variable.
@@ -470,16 +470,16 @@  discard block
 block discarded – undo
470 470
 	protected function prepare_links( $object, $request ) {
471 471
 		$links = array(
472 472
 			'self'       => array(
473
-				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ),  // @codingStandardsIgnoreLine.
473
+				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ), // @codingStandardsIgnoreLine.
474 474
 			),
475 475
 			'collection' => array(
476
-				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),  // @codingStandardsIgnoreLine.
476
+				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), // @codingStandardsIgnoreLine.
477 477
 			),
478 478
 		);
479 479
 
480 480
 		if ( $object->get_parent_id() ) {
481 481
 			$links['up'] = array(
482
-				'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $object->get_parent_id() ) ),  // @codingStandardsIgnoreLine.
482
+				'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $object->get_parent_id() ) ), // @codingStandardsIgnoreLine.
483 483
 			);
484 484
 		}
485 485
 
Please login to merge, or discard this patch.
src/Controllers/Version4/ProductVariations.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 			'low_in_stock',
261 261
 		);
262 262
 		foreach ( $custom_keys as $key ) {
263
-			if ( ! empty( $request[ $key ] ) ) {
264
-				$args[ $key ] = $request[ $key ];
263
+			if ( ! empty( $request[$key] ) ) {
264
+				$args[$key] = $request[$key];
265 265
 			}
266 266
 		}
267 267
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 			// Use 0 when there's no on sale products to avoid return all products.
285 285
 			$on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids;
286 286
 
287
-			$args[ $on_sale_key ] += $on_sale_ids;
287
+			$args[$on_sale_key] += $on_sale_ids;
288 288
 		}
289 289
 
290 290
 		// Force the post_type argument, since it's not a user input variable.
@@ -447,15 +447,15 @@  discard block
 block discarded – undo
447 447
 		$url_params = $request->get_url_params();
448 448
 		$product_id = $url_params['product_id'];
449 449
 
450
-		if ( ! isset( $params[ $batch_type ] ) ) {
450
+		if ( ! isset( $params[$batch_type] ) ) {
451 451
 			return array();
452 452
 		}
453 453
 
454
-		$items = array_filter( $params[ $batch_type ] );
454
+		$items = array_filter( $params[$batch_type] );
455 455
 
456 456
 		if ( 'update' === $batch_type || 'create' === $batch_type ) {
457 457
 			foreach ( $items as $key => $item ) {
458
-				$items[ $key ] = array_merge(
458
+				$items[$key] = array_merge(
459 459
 					array(
460 460
 						'product_id' => $product_id,
461 461
 					),
Please login to merge, or discard this patch.
src/Controllers/Version4/Schema/ProductResponse.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -308,10 +308,10 @@
 block discarded – undo
308 308
 		$attribute  = false;
309 309
 
310 310
 		// pa_ attributes.
311
-		if ( isset( $attributes[ wc_attribute_taxonomy_name( $slug ) ] ) ) {
312
-			$attribute = $attributes[ wc_attribute_taxonomy_name( $slug ) ];
313
-		} elseif ( isset( $attributes[ $slug ] ) ) {
314
-			$attribute = $attributes[ $slug ];
311
+		if ( isset( $attributes[wc_attribute_taxonomy_name( $slug )] ) ) {
312
+			$attribute = $attributes[wc_attribute_taxonomy_name( $slug )];
313
+		} elseif ( isset( $attributes[$slug] ) ) {
314
+			$attribute = $attributes[$slug];
315 315
 		}
316 316
 
317 317
 		if ( ! $attribute ) {
Please login to merge, or discard this patch.
src/Controllers/Version4/Schema/ProductVariationRequest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 					$prop_values['shipping_class_id'] = $this->parse_shipping_class( $value, $object );
94 94
 					break;
95 95
 				default:
96
-					$prop_values[ $prop ] = $value;
96
+					$prop_values[$prop] = $value;
97 97
 			}
98 98
 		}
99 99
 
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 				continue;
130 130
 			}
131 131
 
132
-			if ( ! isset( $parent_attributes[ $attribute_name ] ) || ! $parent_attributes[ $attribute_name ]->get_variation() ) {
132
+			if ( ! isset( $parent_attributes[$attribute_name] ) || ! $parent_attributes[$attribute_name]->get_variation() ) {
133 133
 				continue;
134 134
 			}
135 135
 
136
-			$attribute_key   = sanitize_title( $parent_attributes[ $attribute_name ]->get_name() );
136
+			$attribute_key   = sanitize_title( $parent_attributes[$attribute_name]->get_name() );
137 137
 			$attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : '';
138 138
 
139
-			if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) {
139
+			if ( $parent_attributes[$attribute_name]->is_taxonomy() ) {
140 140
 				// If dealing with a taxonomy, we need to get the slug from the name posted to the API.
141 141
 				$term = get_term_by( 'name', $attribute_value, $attribute_name );
142 142
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 				}
148 148
 			}
149 149
 
150
-			$attributes[ $attribute_key ] = $attribute_value;
150
+			$attributes[$attribute_key] = $attribute_value;
151 151
 		}
152 152
 
153 153
 		return $attributes;
Please login to merge, or discard this patch.
src/Controllers/Version4/Schema/ProductRequest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 			switch ( $prop ) {
129 129
 				case 'date_created':
130 130
 				case 'date_created_gmt':
131
-					$prop_values[ $prop ] = rest_parse_date( $value );
131
+					$prop_values[$prop] = rest_parse_date( $value );
132 132
 					break;
133 133
 				case 'upsell_ids':
134 134
 				case 'cross_sell_ids':
135
-					$prop_values[ $prop ] = wp_parse_id_list( $value );
135
+					$prop_values[$prop] = wp_parse_id_list( $value );
136 136
 					break;
137 137
 				case 'images':
138 138
 					$images      = $this->parse_images_field( $value, $object );
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 					$prop_values['shipping_class_id'] = $this->parse_shipping_class( $value, $object );
156 156
 					break;
157 157
 				default:
158
-					$prop_values[ $prop ] = $value;
158
+					$prop_values[$prop] = $value;
159 159
 			}
160 160
 		}
161 161
 
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 				continue;
480 480
 			}
481 481
 
482
-			if ( isset( $attributes[ $attribute_name ] ) ) {
483
-				$_attribute = $attributes[ $attribute_name ];
482
+			if ( isset( $attributes[$attribute_name] ) ) {
483
+				$_attribute = $attributes[$attribute_name];
484 484
 
485 485
 				if ( $_attribute['is_variation'] ) {
486 486
 					$value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : '';
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 					}
498 498
 
499 499
 					if ( $value ) {
500
-						$default_attributes[ $attribute_name ] = $value;
500
+						$default_attributes[$attribute_name] = $value;
501 501
 					}
502 502
 				}
503 503
 			}
Please login to merge, or discard this patch.