Passed
Push — master ( 6176aa...f7c939 )
by Mike
03:08
created
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/Orders.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 
77 77
 		// Format decimal values.
78 78
 		foreach ( $format_decimal as $key ) {
79
-			if ( isset( $data[ $key ] ) ) {
80
-				$data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] );
79
+			if ( isset( $data[$key] ) ) {
80
+				$data[$key] = wc_format_decimal( $data[$key], $this->request['dp'] );
81 81
 			}
82 82
 		}
83 83
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 				$taxes[] = array(
96 96
 					'id'       => $tax_rate_id,
97 97
 					'total'    => $tax,
98
-					'subtotal' => isset( $data['taxes']['subtotal'][ $tax_rate_id ] ) ? $data['taxes']['subtotal'][ $tax_rate_id ] : '',
98
+					'subtotal' => isset( $data['taxes']['subtotal'][$tax_rate_id] ) ? $data['taxes']['subtotal'][$tax_rate_id] : '',
99 99
 				);
100 100
 			}
101 101
 			$data['taxes'] = $taxes;
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
 	public function get_collection_params() {
1221 1221
 		$params = parent::get_collection_params();
1222 1222
 
1223
-		$params['status']   = array(
1223
+		$params['status'] = array(
1224 1224
 			'default'           => 'any',
1225 1225
 			'description'       => __( 'Limit result set to orders which have specific statuses.', 'woocommerce' ),
1226 1226
 			'type'              => 'array',
@@ -1236,13 +1236,13 @@  discard block
 block discarded – undo
1236 1236
 			'sanitize_callback' => 'absint',
1237 1237
 			'validate_callback' => 'rest_validate_request_arg',
1238 1238
 		);
1239
-		$params['product']  = array(
1239
+		$params['product'] = array(
1240 1240
 			'description'       => __( 'Limit result set to orders assigned a specific product.', 'woocommerce' ),
1241 1241
 			'type'              => 'integer',
1242 1242
 			'sanitize_callback' => 'absint',
1243 1243
 			'validate_callback' => 'rest_validate_request_arg',
1244 1244
 		);
1245
-		$params['dp']       = array(
1245
+		$params['dp'] = array(
1246 1246
 			'default'           => wc_get_price_decimals(),
1247 1247
 			'description'       => __( 'Number of decimal points to use in each resource.', 'woocommerce' ),
1248 1248
 			'type'              => 'integer',
Please login to merge, or discard this patch.
src/Controllers/Version4/Requests/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/Requests/AbstractObjectRequest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
 	 * @param mixed  $default Default to return if not set.
38 38
 	 */
39 39
 	protected function get_param( $name, $default = null ) {
40
-		return isset( $this->request[ $name ] ) ? $this->request[ $name ] : $default;
40
+		return isset( $this->request[$name] ) ? $this->request[$name] : $default;
41 41
 	}
42 42
 
43 43
 	/**
Please login to merge, or discard this patch.
src/Controllers/Version4/Requests/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.
src/Controllers/Version4/Requests/OrderRequest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		foreach ( $request_props as $prop => $value ) {
57 57
 			switch ( $prop ) {
58 58
 				case 'customer_id':
59
-					$prop_values[ $prop ] = $this->parse_customer_id_field( $value );
59
+					$prop_values[$prop] = $this->parse_customer_id_field( $value );
60 60
 					break;
61 61
 				case 'billing':
62 62
 				case 'shipping':
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 					$prop_values = array_merge( $prop_values, $address );
65 65
 					break;
66 66
 				default:
67
-					$prop_values[ $prop ] = $value;
67
+					$prop_values[$prop] = $value;
68 68
 			}
69 69
 		}
70 70
 
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 		];
87 87
 
88 88
 		foreach ( $types as $type ) {
89
-			if ( ! isset( $this->request[ $type ] ) || ! is_array( $this->request[ $type ] ) ) {
89
+			if ( ! isset( $this->request[$type] ) || ! is_array( $this->request[$type] ) ) {
90 90
 				continue;
91 91
 			}
92
-			$items = $this->request[ $type ];
92
+			$items = $this->request[$type];
93 93
 
94 94
 			foreach ( $items as $item ) {
95 95
 				if ( ! is_array( $item ) ) {
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		$keys = array( 'product_id', 'method_id', 'method_title', 'name', 'code' );
116 116
 
117 117
 		foreach ( $keys as $key ) {
118
-			if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) {
118
+			if ( array_key_exists( $key, $item ) && is_null( $item[$key] ) ) {
119 119
 				return true;
120 120
 			}
121 121
 		}
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 * @param array          $posted Request data.
132 132
 	 */
133 133
 	protected function maybe_set_item_prop( $item, $prop, $posted ) {
134
-		if ( isset( $posted[ $prop ] ) ) {
135
-			$item->{"set_$prop"}( $posted[ $prop ] );
134
+		if ( isset( $posted[$prop] ) ) {
135
+			$item->{"set_$prop"}( $posted[$prop] );
136 136
 		}
137 137
 	}
138 138
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 		$address = [];
319 319
 		foreach ( $data as $key => $value ) {
320 320
 			if ( is_callable( array( $object, "set_{$type}_{$key}" ) ) ) {
321
-				$address[ "{$type}_{$key}" ] = $value;
321
+				$address["{$type}_{$key}"] = $value;
322 322
 			}
323 323
 		}
324 324
 		return $address;
Please login to merge, or discard this patch.
src/Controllers/Version4/Responses/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.