Completed
Push — master ( 9a7f47...7f2ea5 )
by Mike
05:50
created
src/Controllers/Version4/Products.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -694,8 +694,8 @@  discard block
 block discarded – undo
694 694
 			'low_in_stock',
695 695
 		);
696 696
 		foreach ( $custom_keys as $key ) {
697
-			if ( ! empty( $request[ $key ] ) ) {
698
-				$args[ $key ] = $request[ $key ];
697
+			if ( ! empty( $request[$key] ) ) {
698
+				$args[$key] = $request[$key];
699 699
 			}
700 700
 		}
701 701
 
@@ -712,11 +712,11 @@  discard block
 block discarded – undo
712 712
 
713 713
 		// Set tax_query for each passed arg.
714 714
 		foreach ( $taxonomies as $taxonomy => $key ) {
715
-			if ( ! empty( $request[ $key ] ) ) {
715
+			if ( ! empty( $request[$key] ) ) {
716 716
 				$tax_query[] = array(
717 717
 					'taxonomy' => $taxonomy,
718 718
 					'field'    => 'term_id',
719
-					'terms'    => $request[ $key ],
719
+					'terms'    => $request[$key],
720 720
 				);
721 721
 			}
722 722
 		}
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 			// Use 0 when there's no on sale products to avoid return all products.
780 780
 			$on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids;
781 781
 
782
-			$args[ $on_sale_key ] += $on_sale_ids;
782
+			$args[$on_sale_key] += $on_sale_ids;
783 783
 		}
784 784
 
785 785
 		// Force the post_type argument, since it's not a user input variable.
@@ -923,10 +923,10 @@  discard block
 block discarded – undo
923 923
 		$attribute  = false;
924 924
 
925 925
 		// pa_ attributes.
926
-		if ( isset( $attributes[ wc_attribute_taxonomy_name( $slug ) ] ) ) {
927
-			$attribute = $attributes[ wc_attribute_taxonomy_name( $slug ) ];
928
-		} elseif ( isset( $attributes[ $slug ] ) ) {
929
-			$attribute = $attributes[ $slug ];
926
+		if ( isset( $attributes[wc_attribute_taxonomy_name( $slug )] ) ) {
927
+			$attribute = $attributes[wc_attribute_taxonomy_name( $slug )];
928
+		} elseif ( isset( $attributes[$slug] ) ) {
929
+			$attribute = $attributes[$slug];
930 930
 		}
931 931
 
932 932
 		if ( ! $attribute ) {
@@ -1145,16 +1145,16 @@  discard block
 block discarded – undo
1145 1145
 	protected function prepare_links( $object, $request ) {
1146 1146
 		$links = array(
1147 1147
 			'self'       => array(
1148
-				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ),  // @codingStandardsIgnoreLine.
1148
+				'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ), // @codingStandardsIgnoreLine.
1149 1149
 			),
1150 1150
 			'collection' => array(
1151
-				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),  // @codingStandardsIgnoreLine.
1151
+				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), // @codingStandardsIgnoreLine.
1152 1152
 			),
1153 1153
 		);
1154 1154
 
1155 1155
 		if ( $object->get_parent_id() ) {
1156 1156
 			$links['up'] = array(
1157
-				'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $object->get_parent_id() ) ),  // @codingStandardsIgnoreLine.
1157
+				'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $object->get_parent_id() ) ), // @codingStandardsIgnoreLine.
1158 1158
 			);
1159 1159
 		}
1160 1160
 
@@ -1358,8 +1358,8 @@  discard block
 block discarded – undo
1358 1358
 					continue;
1359 1359
 				}
1360 1360
 
1361
-				if ( isset( $attributes[ $attribute_name ] ) ) {
1362
-					$_attribute = $attributes[ $attribute_name ];
1361
+				if ( isset( $attributes[$attribute_name] ) ) {
1362
+					$_attribute = $attributes[$attribute_name];
1363 1363
 
1364 1364
 					if ( $_attribute['is_variation'] ) {
1365 1365
 						$value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : '';
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 						}
1377 1377
 
1378 1378
 						if ( $value ) {
1379
-							$default_attributes[ $attribute_name ] = $value;
1379
+							$default_attributes[$attribute_name] = $value;
1380 1380
 						}
1381 1381
 					}
1382 1382
 				}
Please login to merge, or discard this patch.
src/Controllers/Version4/SystemStatusTools.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
 	 */
237 237
 	public function get_item( $request ) {
238 238
 		$tools = $this->get_tools();
239
-		if ( empty( $tools[ $request['id'] ] ) ) {
239
+		if ( empty( $tools[$request['id']] ) ) {
240 240
 			return new \WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce' ), array( 'status' => 404 ) );
241 241
 		}
242
-		$tool = $tools[ $request['id'] ];
242
+		$tool = $tools[$request['id']];
243 243
 		return rest_ensure_response(
244 244
 			$this->prepare_item_for_response(
245 245
 				array(
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function update_item( $request ) {
263 263
 		$tools = $this->get_tools();
264
-		if ( empty( $tools[ $request['id'] ] ) ) {
264
+		if ( empty( $tools[$request['id']] ) ) {
265 265
 			return new \WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce' ), array( 'status' => 404 ) );
266 266
 		}
267 267
 
268
-		$tool = $tools[ $request['id'] ];
268
+		$tool = $tools[$request['id']];
269 269
 		$tool = array(
270 270
 			'id'          => $request['id'],
271 271
 			'name'        => $tool['name'],
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
 		$tools = $this->get_tools();
412 412
 
413 413
 		try {
414
-			if ( ! isset( $tools[ $tool ] ) ) {
414
+			if ( ! isset( $tools[$tool] ) ) {
415 415
 				throw new Exception( __( 'There was an error calling this tool. There is no callback present.', 'woocommerce' ) );
416 416
 			}
417 417
 
418
-			$callback = isset( $tools[ $tool ]['callback'] ) ? $tools[ $tool ]['callback'] : array( $this, $tool );
418
+			$callback = isset( $tools[$tool]['callback'] ) ? $tools[$tool]['callback'] : array( $this, $tool );
419 419
 
420 420
 			if ( ! is_callable( $callback ) ) {
421 421
 				throw new Exception( __( 'There was an error calling this tool. Invalid callback.', 'woocommerce' ) );
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -572,7 +572,7 @@
 block discarded – undo
572 572
 	protected function clear_sessions() {
573 573
 		global $wpdb;
574 574
 
575
-		$wpdb->query( "TRUNCATE {$wpdb->prefix}woocommerce_sessions" );
575
+		$wpdb->query( "truncate {$wpdb->prefix}woocommerce_sessions" );
576 576
 		$result = absint( $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key='_woocommerce_persistent_cart_" . get_current_blog_id() . "';" ) ); // WPCS: unprepared SQL ok.
577 577
 		wp_cache_flush();
578 578
 		/* translators: %d: amount of sessions */
Please login to merge, or discard this patch.
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/ProductVariations.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 			'low_in_stock',
355 355
 		);
356 356
 		foreach ( $custom_keys as $key ) {
357
-			if ( ! empty( $request[ $key ] ) ) {
358
-				$args[ $key ] = $request[ $key ];
357
+			if ( ! empty( $request[$key] ) ) {
358
+				$args[$key] = $request[$key];
359 359
 			}
360 360
 		}
361 361
 
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 			// Use 0 when there's no on sale products to avoid return all products.
379 379
 			$on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids;
380 380
 
381
-			$args[ $on_sale_key ] += $on_sale_ids;
381
+			$args[$on_sale_key] += $on_sale_ids;
382 382
 		}
383 383
 
384 384
 		// Force the post_type argument, since it's not a user input variable.
@@ -558,14 +558,14 @@  discard block
 block discarded – undo
558 558
 					continue;
559 559
 				}
560 560
 
561
-				if ( ! isset( $parent_attributes[ $attribute_name ] ) || ! $parent_attributes[ $attribute_name ]->get_variation() ) {
561
+				if ( ! isset( $parent_attributes[$attribute_name] ) || ! $parent_attributes[$attribute_name]->get_variation() ) {
562 562
 					continue;
563 563
 				}
564 564
 
565
-				$attribute_key   = sanitize_title( $parent_attributes[ $attribute_name ]->get_name() );
565
+				$attribute_key   = sanitize_title( $parent_attributes[$attribute_name]->get_name() );
566 566
 				$attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : '';
567 567
 
568
-				if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) {
568
+				if ( $parent_attributes[$attribute_name]->is_taxonomy() ) {
569 569
 					// If dealing with a taxonomy, we need to get the slug from the name posted to the API.
570 570
 					$term = get_term_by( 'name', $attribute_value, $attribute_name );
571 571
 
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 					}
577 577
 				}
578 578
 
579
-				$attributes[ $attribute_key ] = $attribute_value;
579
+				$attributes[$attribute_key] = $attribute_value;
580 580
 			}
581 581
 
582 582
 			$variation->set_attributes( $attributes );
@@ -736,15 +736,15 @@  discard block
 block discarded – undo
736 736
 		$url_params = $request->get_url_params();
737 737
 		$product_id = $url_params['product_id'];
738 738
 
739
-		if ( ! isset( $params[ $batch_type ] ) ) {
739
+		if ( ! isset( $params[$batch_type] ) ) {
740 740
 			return array();
741 741
 		}
742 742
 
743
-		$items = array_filter( $params[ $batch_type ] );
743
+		$items = array_filter( $params[$batch_type] );
744 744
 
745 745
 		if ( 'update' === $batch_type || 'create' === $batch_type ) {
746 746
 			foreach ( $items as $key => $item ) {
747
-				$items[ $key ] = array_merge(
747
+				$items[$key] = array_merge(
748 748
 					array(
749 749
 						'product_id' => $product_id,
750 750
 					),
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.