Passed
Push — master ( 8ebd9d...d9ef29 )
by Mike
05:12
created
src/Controllers/Version4/Customers.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 		// Format date values.
241 241
 		foreach ( $format_date as $key ) {
242 242
 			// Date created is stored UTC, date modified is stored WP local time.
243
-			$datetime              = 'date_created' === $key ? get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $data[ $key ]->getTimestamp() ) ) : $data[ $key ];
244
-			$data[ $key ]          = wc_rest_prepare_date_response( $datetime, false );
245
-			$data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime );
243
+			$datetime              = 'date_created' === $key ? get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $data[$key]->getTimestamp() ) ) : $data[$key];
244
+			$data[$key]          = wc_rest_prepare_date_response( $datetime, false );
245
+			$data[$key . '_gmt'] = wc_rest_prepare_date_response( $datetime );
246 246
 		}
247 247
 
248 248
 		return array(
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 			'name'            => 'display_name',
288 288
 			'registered_date' => 'registered',
289 289
 		);
290
-		$prepared_args['orderby'] = $orderby_possibles[ $request['orderby'] ];
290
+		$prepared_args['orderby'] = $orderby_possibles[$request['orderby']];
291 291
 		$prepared_args['search']  = $request['search'];
292 292
 
293 293
 		if ( '' !== $prepared_args['search'] ) {
@@ -604,8 +604,8 @@  discard block
 block discarded – undo
604 604
 		// Customer billing address.
605 605
 		if ( isset( $request['billing'] ) ) {
606 606
 			foreach ( array_keys( $schema['properties']['billing']['properties'] ) as $field ) {
607
-				if ( isset( $request['billing'][ $field ] ) && is_callable( array( $customer, "set_billing_{$field}" ) ) ) {
608
-					$customer->{"set_billing_{$field}"}( $request['billing'][ $field ] );
607
+				if ( isset( $request['billing'][$field] ) && is_callable( array( $customer, "set_billing_{$field}" ) ) ) {
608
+					$customer->{"set_billing_{$field}"}( $request['billing'][$field] );
609 609
 				}
610 610
 			}
611 611
 		}
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
 		// Customer shipping address.
614 614
 		if ( isset( $request['shipping'] ) ) {
615 615
 			foreach ( array_keys( $schema['properties']['shipping']['properties'] ) as $field ) {
616
-				if ( isset( $request['shipping'][ $field ] ) && is_callable( array( $customer, "set_shipping_{$field}" ) ) ) {
617
-					$customer->{"set_shipping_{$field}"}( $request['shipping'][ $field ] );
616
+				if ( isset( $request['shipping'][$field] ) && is_callable( array( $customer, "set_shipping_{$field}" ) ) ) {
617
+					$customer->{"set_shipping_{$field}"}( $request['shipping'][$field] );
618 618
 				}
619 619
 			}
620 620
 		}
Please login to merge, or discard this patch.
src/Controllers/Version4/ShippingZoneMethods.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -309,17 +309,17 @@  discard block
 block discarded – undo
309 309
 			$instance_settings = $method->instance_settings;
310 310
 			$errors_found      = false;
311 311
 			foreach ( $method->get_instance_form_fields() as $key => $field ) {
312
-				if ( isset( $request['settings'][ $key ] ) ) {
312
+				if ( isset( $request['settings'][$key] ) ) {
313 313
 					if ( is_callable( array( $this, 'validate_setting_' . $field['type'] . '_field' ) ) ) {
314
-						$value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][ $key ], $field );
314
+						$value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][$key], $field );
315 315
 					} else {
316
-						$value = $this->validate_setting_text_field( $request['settings'][ $key ], $field );
316
+						$value = $this->validate_setting_text_field( $request['settings'][$key], $field );
317 317
 					}
318 318
 					if ( is_wp_error( $value ) ) {
319 319
 						$errors_found = true;
320 320
 						break;
321 321
 					}
322
-					$instance_settings[ $key ] = $value;
322
+					$instance_settings[$key] = $value;
323 323
 				}
324 324
 			}
325 325
 
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 				'label'       => $field['title'],
398 398
 				'description' => empty( $field['description'] ) ? '' : $field['description'],
399 399
 				'type'        => $field['type'],
400
-				'value'       => $item->instance_settings[ $id ],
400
+				'value'       => $item->instance_settings[$id],
401 401
 				'default'     => empty( $field['default'] ) ? '' : $field['default'],
402 402
 				'tip'         => empty( $field['description'] ) ? '' : $field['description'],
403 403
 				'placeholder' => empty( $field['placeholder'] ) ? '' : $field['placeholder'],
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 			if ( ! empty( $field['options'] ) ) {
406 406
 				$data['options'] = $field['options'];
407 407
 			}
408
-			$settings[ $id ] = $data;
408
+			$settings[$id] = $data;
409 409
 		}
410 410
 		return $settings;
411 411
 	}
Please login to merge, or discard this patch.
src/Controllers/Version4/NetworkOrders.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,25 +46,25 @@
 block discarded – undo
46 46
 	public function get_public_item_schema() {
47 47
 		$schema = parent::get_public_item_schema();
48 48
 
49
-		$schema['properties']['blog']              = array(
49
+		$schema['properties']['blog'] = array(
50 50
 			'description' => __( 'Blog id of the record on the multisite.', 'woocommerce' ),
51 51
 			'type'        => 'integer',
52 52
 			'context'     => array( 'view' ),
53 53
 			'readonly'    => true,
54 54
 		);
55
-		$schema['properties']['edit_url']          = array(
55
+		$schema['properties']['edit_url'] = array(
56 56
 			'description' => __( 'URL to edit the order', 'woocommerce' ),
57 57
 			'type'        => 'string',
58 58
 			'context'     => array( 'view' ),
59 59
 			'readonly'    => true,
60 60
 		);
61
-		$schema['properties']['customer'][]        = array(
61
+		$schema['properties']['customer'][] = array(
62 62
 			'description' => __( 'Name of the customer for the order', 'woocommerce' ),
63 63
 			'type'        => 'string',
64 64
 			'context'     => array( 'view' ),
65 65
 			'readonly'    => true,
66 66
 		);
67
-		$schema['properties']['status_name'][]     = array(
67
+		$schema['properties']['status_name'][] = array(
68 68
 			'description' => __( 'Order Status', 'woocommerce' ),
69 69
 			'type'        => 'string',
70 70
 			'context'     => array( 'view' ),
Please login to merge, or discard this patch.
src/Controllers/Version4/PaymentGateways.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -166,17 +166,17 @@  discard block
 block discarded – undo
166 166
 		if ( isset( $request['settings'] ) ) {
167 167
 			$errors_found = false;
168 168
 			foreach ( $gateway->form_fields as $key => $field ) {
169
-				if ( isset( $request['settings'][ $key ] ) ) {
169
+				if ( isset( $request['settings'][$key] ) ) {
170 170
 					if ( is_callable( array( $this, 'validate_setting_' . $field['type'] . '_field' ) ) ) {
171
-						$value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][ $key ], $field );
171
+						$value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][$key], $field );
172 172
 					} else {
173
-						$value = $this->validate_setting_text_field( $request['settings'][ $key ], $field );
173
+						$value = $this->validate_setting_text_field( $request['settings'][$key], $field );
174 174
 					}
175 175
 					if ( is_wp_error( $value ) ) {
176 176
 						$errors_found = true;
177 177
 						break;
178 178
 					}
179
-					$settings[ $key ] = $value;
179
+					$settings[$key] = $value;
180 180
 				}
181 181
 			}
182 182
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 		// Update order.
211 211
 		if ( isset( $request['order'] ) ) {
212 212
 			$order                 = (array) get_option( 'woocommerce_gateway_order' );
213
-			$order[ $gateway->id ] = $request['order'];
213
+			$order[$gateway->id] = $request['order'];
214 214
 			update_option( 'woocommerce_gateway_order', $order );
215 215
 			$gateway->order = absint( $request['order'] );
216 216
 		}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 			'id'                 => $gateway->id,
252 252
 			'title'              => $gateway->title,
253 253
 			'description'        => $gateway->description,
254
-			'order'              => isset( $order[ $gateway->id ] ) ? $order[ $gateway->id ] : '',
254
+			'order'              => isset( $order[$gateway->id] ) ? $order[$gateway->id] : '',
255 255
 			'enabled'            => ( 'yes' === $gateway->enabled ),
256 256
 			'method_title'       => $gateway->get_method_title(),
257 257
 			'method_description' => $gateway->get_method_description(),
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 				'label'       => empty( $field['label'] ) ? $field['title'] : $field['label'],
303 303
 				'description' => empty( $field['description'] ) ? '' : $field['description'],
304 304
 				'type'        => $field['type'],
305
-				'value'       => empty( $gateway->settings[ $id ] ) ? '' : $gateway->settings[ $id ],
305
+				'value'       => empty( $gateway->settings[$id] ) ? '' : $gateway->settings[$id],
306 306
 				'default'     => empty( $field['default'] ) ? '' : $field['default'],
307 307
 				'tip'         => empty( $field['description'] ) ? '' : $field['description'],
308 308
 				'placeholder' => empty( $field['placeholder'] ) ? '' : $field['placeholder'],
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			if ( ! empty( $field['options'] ) ) {
311 311
 				$data['options'] = $field['options'];
312 312
 			}
313
-			$settings[ $id ] = $data;
313
+			$settings[$id] = $data;
314 314
 		}
315 315
 		return $settings;
316 316
 	}
Please login to merge, or discard this patch.
src/Controllers/Version4/Products.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -714,11 +714,11 @@  discard block
 block discarded – undo
714 714
 
715 715
 		// Set tax_query for each passed arg.
716 716
 		foreach ( $taxonomies as $taxonomy => $key ) {
717
-			if ( ! empty( $request[ $key ] ) ) {
717
+			if ( ! empty( $request[$key] ) ) {
718 718
 				$tax_query[] = array(
719 719
 					'taxonomy' => $taxonomy,
720 720
 					'field'    => 'term_id',
721
-					'terms'    => $request[ $key ],
721
+					'terms'    => $request[$key],
722 722
 				);
723 723
 			}
724 724
 		}
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 
794 794
 		// Price filter.
795 795
 		if ( ! empty( $request['min_price'] ) || ! empty( $request['max_price'] ) ) {
796
-			$args['meta_query'] = $this->add_meta_query( $args, wc_get_min_max_price_meta_query( $request ) );  // WPCS: slow query ok.
796
+			$args['meta_query'] = $this->add_meta_query( $args, wc_get_min_max_price_meta_query( $request ) ); // WPCS: slow query ok.
797 797
 		}
798 798
 
799 799
 		// Filter product by stock_status.
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 			// Use 0 when there's no on sale products to avoid return all products.
816 816
 			$on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids;
817 817
 
818
-			$args[ $on_sale_key ] += $on_sale_ids;
818
+			$args[$on_sale_key] += $on_sale_ids;
819 819
 		}
820 820
 
821 821
 		// Force the post_type argument, since it's not a user input variable.
@@ -959,10 +959,10 @@  discard block
 block discarded – undo
959 959
 		$attribute  = false;
960 960
 
961 961
 		// pa_ attributes.
962
-		if ( isset( $attributes[ wc_attribute_taxonomy_name( $slug ) ] ) ) {
963
-			$attribute = $attributes[ wc_attribute_taxonomy_name( $slug ) ];
964
-		} elseif ( isset( $attributes[ $slug ] ) ) {
965
-			$attribute = $attributes[ $slug ];
962
+		if ( isset( $attributes[wc_attribute_taxonomy_name( $slug )] ) ) {
963
+			$attribute = $attributes[wc_attribute_taxonomy_name( $slug )];
964
+		} elseif ( isset( $attributes[$slug] ) ) {
965
+			$attribute = $attributes[$slug];
966 966
 		}
967 967
 
968 968
 		if ( ! $attribute ) {
@@ -1181,16 +1181,16 @@  discard block
 block discarded – undo
1181 1181
 	protected function prepare_links( $object, $request ) {
1182 1182
 		$links = array(
1183 1183
 			'self'       => array(
1184
-				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ),  // @codingStandardsIgnoreLine.
1184
+				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ), // @codingStandardsIgnoreLine.
1185 1185
 			),
1186 1186
 			'collection' => array(
1187
-				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),  // @codingStandardsIgnoreLine.
1187
+				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), // @codingStandardsIgnoreLine.
1188 1188
 			),
1189 1189
 		);
1190 1190
 
1191 1191
 		if ( $object->get_parent_id() ) {
1192 1192
 			$links['up'] = array(
1193
-				'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $object->get_parent_id() ) ),  // @codingStandardsIgnoreLine.
1193
+				'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $object->get_parent_id() ) ), // @codingStandardsIgnoreLine.
1194 1194
 			);
1195 1195
 		}
1196 1196
 
@@ -1394,8 +1394,8 @@  discard block
 block discarded – undo
1394 1394
 					continue;
1395 1395
 				}
1396 1396
 
1397
-				if ( isset( $attributes[ $attribute_name ] ) ) {
1398
-					$_attribute = $attributes[ $attribute_name ];
1397
+				if ( isset( $attributes[$attribute_name] ) ) {
1398
+					$_attribute = $attributes[$attribute_name];
1399 1399
 
1400 1400
 					if ( $_attribute['is_variation'] ) {
1401 1401
 						$value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : '';
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
 						}
1413 1413
 
1414 1414
 						if ( $value ) {
1415
-							$default_attributes[ $attribute_name ] = $value;
1415
+							$default_attributes[$attribute_name] = $value;
1416 1416
 						}
1417 1417
 					}
1418 1418
 				}
Please login to merge, or discard this patch.
src/Controllers/Version4/ProductVariations.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 
376 376
 		// Price filter.
377 377
 		if ( ! empty( $request['min_price'] ) || ! empty( $request['max_price'] ) ) {
378
-			$args['meta_query'] = $this->add_meta_query( $args, wc_get_min_max_price_meta_query( $request ) );  // WPCS: slow query ok.
378
+			$args['meta_query'] = $this->add_meta_query( $args, wc_get_min_max_price_meta_query( $request ) ); // WPCS: slow query ok.
379 379
 		}
380 380
 
381 381
 		// Filter product based on stock_status.
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 			// Use 0 when there's no on sale products to avoid return all products.
398 398
 			$on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids;
399 399
 
400
-			$args[ $on_sale_key ] += $on_sale_ids;
400
+			$args[$on_sale_key] += $on_sale_ids;
401 401
 		}
402 402
 
403 403
 		// Force the post_type argument, since it's not a user input variable.
@@ -577,14 +577,14 @@  discard block
 block discarded – undo
577 577
 					continue;
578 578
 				}
579 579
 
580
-				if ( ! isset( $parent_attributes[ $attribute_name ] ) || ! $parent_attributes[ $attribute_name ]->get_variation() ) {
580
+				if ( ! isset( $parent_attributes[$attribute_name] ) || ! $parent_attributes[$attribute_name]->get_variation() ) {
581 581
 					continue;
582 582
 				}
583 583
 
584
-				$attribute_key   = sanitize_title( $parent_attributes[ $attribute_name ]->get_name() );
584
+				$attribute_key   = sanitize_title( $parent_attributes[$attribute_name]->get_name() );
585 585
 				$attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : '';
586 586
 
587
-				if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) {
587
+				if ( $parent_attributes[$attribute_name]->is_taxonomy() ) {
588 588
 					// If dealing with a taxonomy, we need to get the slug from the name posted to the API.
589 589
 					$term = get_term_by( 'name', $attribute_value, $attribute_name );
590 590
 
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 					}
596 596
 				}
597 597
 
598
-				$attributes[ $attribute_key ] = $attribute_value;
598
+				$attributes[$attribute_key] = $attribute_value;
599 599
 			}
600 600
 
601 601
 			$variation->set_attributes( $attributes );
@@ -757,16 +757,16 @@  discard block
 block discarded – undo
757 757
 		$body_params = array();
758 758
 
759 759
 		foreach ( array( 'update', 'create', 'delete' ) as $batch_type ) {
760
-			if ( ! empty( $items[ $batch_type ] ) ) {
760
+			if ( ! empty( $items[$batch_type] ) ) {
761 761
 				$injected_items = array();
762
-				foreach ( $items[ $batch_type ] as $item ) {
762
+				foreach ( $items[$batch_type] as $item ) {
763 763
 					$injected_items[] = is_array( $item ) ? array_merge(
764 764
 						array(
765 765
 							'product_id' => $product_id,
766 766
 						), $item
767 767
 					) : $item;
768 768
 				}
769
-				$body_params[ $batch_type ] = $injected_items;
769
+				$body_params[$batch_type] = $injected_items;
770 770
 			}
771 771
 		}
772 772
 
Please login to merge, or discard this patch.
src/Controllers/Version4/Data/Currencies.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
 
91 91
 		$currency = array(
92 92
 			'code'   => $code,
93
-			'name'   => $currencies[ $code ],
93
+			'name'   => $currencies[$code],
94 94
 			'symbol' => get_woocommerce_currency_symbol( $code ),
95 95
 		);
96 96
 
Please login to merge, or discard this patch.
src/Controllers/Version4/Data/Continents.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			return false;
83 83
 		}
84 84
 
85
-		$continent_list = $continents[ $continent_code ];
85
+		$continent_list = $continents[$continent_code];
86 86
 
87 87
 		$continent = array(
88 88
 			'code' => $continent_code,
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
 
92 92
 		$local_countries = array();
93 93
 		foreach ( $continent_list['countries'] as $country_code ) {
94
-			if ( isset( $countries[ $country_code ] ) ) {
94
+			if ( isset( $countries[$country_code] ) ) {
95 95
 				$country = array(
96 96
 					'code' => $country_code,
97
-					'name' => $countries[ $country_code ],
97
+					'name' => $countries[$country_code],
98 98
 				);
99 99
 
100 100
 				// If we have detailed locale information include that in the response.
101 101
 				if ( array_key_exists( $country_code, $locale_info ) ) {
102 102
 					// Defensive programming against unexpected changes in locale-info.php.
103 103
 					$country_data = wp_parse_args(
104
-						$locale_info[ $country_code ],
104
+						$locale_info[$country_code],
105 105
 						array(
106 106
 							'currency_code'  => 'USD',
107 107
 							'currency_pos'   => 'left',
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 				}
118 118
 
119 119
 				$local_states = array();
120
-				if ( isset( $states[ $country_code ] ) ) {
121
-					foreach ( $states[ $country_code ] as $state_code => $state_name ) {
120
+				if ( isset( $states[$country_code] ) ) {
121
+					foreach ( $states[$country_code] as $state_code => $state_name ) {
122 122
 						$local_states[] = array(
123 123
 							'code' => $state_code,
124 124
 							'name' => $state_name,
Please login to merge, or discard this patch.
src/Controllers/Version4/Data/Countries.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -81,12 +81,12 @@
 block discarded – undo
81 81
 
82 82
 		$country = array(
83 83
 			'code' => $country_code,
84
-			'name' => $countries[ $country_code ],
84
+			'name' => $countries[$country_code],
85 85
 		);
86 86
 
87 87
 		$local_states = array();
88
-		if ( isset( $states[ $country_code ] ) ) {
89
-			foreach ( $states[ $country_code ] as $state_code => $state_name ) {
88
+		if ( isset( $states[$country_code] ) ) {
89
+			foreach ( $states[$country_code] as $state_code => $state_name ) {
90 90
 				$local_states[] = array(
91 91
 					'code' => $state_code,
92 92
 					'name' => $state_name,
Please login to merge, or discard this patch.