Passed
Push — master ( 6e82a3...cd847f )
by Mike
04:08
created
src/Controllers/Version4/ProductReviews.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -259,15 +259,15 @@  discard block
 block discarded – undo
259 259
 		 * set the parameter's value on the query $prepared_args.
260 260
 		 */
261 261
 		foreach ( $parameter_mappings as $api_param => $wp_param ) {
262
-			if ( isset( $registered[ $api_param ], $request[ $api_param ] ) ) {
263
-				$prepared_args[ $wp_param ] = $request[ $api_param ];
262
+			if ( isset( $registered[$api_param], $request[$api_param] ) ) {
263
+				$prepared_args[$wp_param] = $request[$api_param];
264 264
 			}
265 265
 		}
266 266
 
267 267
 		// Ensure certain parameter values default to empty strings.
268 268
 		foreach ( array( 'author_email', 'search' ) as $param ) {
269
-			if ( ! isset( $prepared_args[ $param ] ) ) {
270
-				$prepared_args[ $param ] = '';
269
+			if ( ! isset( $prepared_args[$param] ) ) {
270
+				$prepared_args[$param] = '';
271 271
 			}
272 272
 		}
273 273
 
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 			$avatar_sizes      = rest_get_avatar_sizes();
895 895
 
896 896
 			foreach ( $avatar_sizes as $size ) {
897
-				$avatar_properties[ $size ] = array(
897
+				$avatar_properties[$size] = array(
898 898
 					/* translators: %d: avatar image size in pixels */
899 899
 					'description' => sprintf( __( 'Avatar URL with image size of %d pixels.', 'woocommerce' ), $size ),
900 900
 					'type'        => 'string',
@@ -924,17 +924,17 @@  discard block
 block discarded – undo
924 924
 
925 925
 		$params['context']['default'] = 'view';
926 926
 
927
-		$params['after']            = array(
927
+		$params['after'] = array(
928 928
 			'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
929 929
 			'type'        => 'string',
930 930
 			'format'      => 'date-time',
931 931
 		);
932
-		$params['before']           = array(
932
+		$params['before'] = array(
933 933
 			'description' => __( 'Limit response to reviews published before a given ISO8601 compliant date.', 'woocommerce' ),
934 934
 			'type'        => 'string',
935 935
 			'format'      => 'date-time',
936 936
 		);
937
-		$params['exclude']          = array(
937
+		$params['exclude'] = array(
938 938
 			'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
939 939
 			'type'        => 'array',
940 940
 			'items'       => array(
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 			),
943 943
 			'default'     => array(),
944 944
 		);
945
-		$params['include']          = array(
945
+		$params['include'] = array(
946 946
 			'description' => __( 'Limit result set to specific IDs.', 'woocommerce' ),
947 947
 			'type'        => 'array',
948 948
 			'items'       => array(
@@ -950,11 +950,11 @@  discard block
 block discarded – undo
950 950
 			),
951 951
 			'default'     => array(),
952 952
 		);
953
-		$params['offset']           = array(
953
+		$params['offset'] = array(
954 954
 			'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
955 955
 			'type'        => 'integer',
956 956
 		);
957
-		$params['order']            = array(
957
+		$params['order'] = array(
958 958
 			'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
959 959
 			'type'        => 'string',
960 960
 			'default'     => 'desc',
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
 				'desc',
964 964
 			),
965 965
 		);
966
-		$params['orderby']          = array(
966
+		$params['orderby'] = array(
967 967
 			'description' => __( 'Sort collection by object attribute.', 'woocommerce' ),
968 968
 			'type'        => 'string',
969 969
 			'default'     => 'date_gmt',
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
 				'product',
976 976
 			),
977 977
 		);
978
-		$params['reviewer']         = array(
978
+		$params['reviewer'] = array(
979 979
 			'description' => __( 'Limit result set to reviews assigned to specific user IDs.', 'woocommerce' ),
980 980
 			'type'        => 'array',
981 981
 			'items'       => array(
@@ -989,13 +989,13 @@  discard block
 block discarded – undo
989 989
 				'type' => 'integer',
990 990
 			),
991 991
 		);
992
-		$params['reviewer_email']   = array(
992
+		$params['reviewer_email'] = array(
993 993
 			'default'     => null,
994 994
 			'description' => __( 'Limit result set to that from a specific author email.', 'woocommerce' ),
995 995
 			'format'      => 'email',
996 996
 			'type'        => 'string',
997 997
 		);
998
-		$params['product']          = array(
998
+		$params['product'] = array(
999 999
 			'default'     => array(),
1000 1000
 			'description' => __( 'Limit result set to reviews assigned to specific product IDs.', 'woocommerce' ),
1001 1001
 			'type'        => 'array',
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 				'type' => 'integer',
1004 1004
 			),
1005 1005
 		);
1006
-		$params['status']           = array(
1006
+		$params['status'] = array(
1007 1007
 			'default'           => 'approved',
1008 1008
 			'description'       => __( 'Limit result set to reviews assigned a specific status.', 'woocommerce' ),
1009 1009
 			'sanitize_callback' => 'sanitize_key',
Please login to merge, or discard this patch.
src/Controllers/Version4/Taxes.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 			'id'    => 'tax_rate_id',
215 215
 			'order' => 'tax_rate_order',
216 216
 		);
217
-		$prepared_args['orderby'] = $orderby_possibles[ $request['orderby'] ];
217
+		$prepared_args['orderby'] = $orderby_possibles[$request['orderby']];
218 218
 		$prepared_args['class']   = $request['class'];
219 219
 		$prepared_args['code']    = $request['code'];
220 220
 		$prepared_args['include'] = $request['include'];
@@ -329,12 +329,12 @@  discard block
 block discarded – undo
329 329
 			$key = 'tax_rate' === $field ? 'rate' : str_replace( 'tax_rate_', '', $field );
330 330
 
331 331
 			// Remove data that was not posted.
332
-			if ( ! isset( $request[ $key ] ) ) {
332
+			if ( ! isset( $request[$key] ) ) {
333 333
 				continue;
334 334
 			}
335 335
 
336 336
 			// Test new data against current data.
337
-			if ( $current && $current->$field === $request[ $key ] ) {
337
+			if ( $current && $current->$field === $request[$key] ) {
338 338
 				continue;
339 339
 			}
340 340
 
@@ -344,13 +344,13 @@  discard block
 block discarded – undo
344 344
 				case 'tax_rate_compound':
345 345
 				case 'tax_rate_shipping':
346 346
 				case 'tax_rate_order':
347
-					$data[ $field ] = absint( $request[ $key ] );
347
+					$data[$field] = absint( $request[$key] );
348 348
 					break;
349 349
 				case 'tax_rate_class':
350
-					$data[ $field ] = 'standard' !== $request['tax_rate_class'] ? $request['tax_rate_class'] : '';
350
+					$data[$field] = 'standard' !== $request['tax_rate_class'] ? $request['tax_rate_class'] : '';
351 351
 					break;
352 352
 				default:
353
-					$data[ $field ] = wc_clean( $request[ $key ] );
353
+					$data[$field] = wc_clean( $request[$key] );
354 354
 					break;
355 355
 			}
356 356
 		}
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 
544 544
 		if ( ! is_wp_error( $tax ) && ! is_null( $tax ) ) {
545 545
 			foreach ( $locales as $locale ) {
546
-				$data[ $locale->location_type ] = $locale->location_code;
546
+				$data[$locale->location_type] = $locale->location_code;
547 547
 			}
548 548
 		}
549 549
 
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 			'type'               => 'string',
728 728
 			'validate_callback'  => 'rest_validate_request_arg',
729 729
 		);
730
-		$params['code']    = array(
730
+		$params['code'] = array(
731 731
 			'description'       => __( 'Search by similar tax code.', 'woocommerce' ),
732 732
 			'type'              => 'string',
733 733
 			'validate_callback' => 'rest_validate_request_arg',
Please login to merge, or discard this patch.
src/Server.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@
 block discarded – undo
37 37
 	public function register_rest_routes() {
38 38
 		foreach ( $this->get_rest_namespaces() as $namespace => $controllers ) {
39 39
 			foreach ( $controllers as $controller_name => $controller_class ) {
40
-				$this->controllers[ $namespace ][ $controller_name ] = new $controller_class();
41
-				$this->controllers[ $namespace ][ $controller_name ]->register_routes();
40
+				$this->controllers[$namespace][$controller_name] = new $controller_class();
41
+				$this->controllers[$namespace][$controller_name]->register_routes();
42 42
 			}
43 43
 		}
44 44
 	}
Please login to merge, or discard this patch.
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/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 );
@@ -738,9 +738,9 @@  discard block
 block discarded – undo
738 738
 		$body_params = array();
739 739
 
740 740
 		foreach ( array( 'update', 'create', 'delete' ) as $batch_type ) {
741
-			if ( ! empty( $items[ $batch_type ] ) ) {
741
+			if ( ! empty( $items[$batch_type] ) ) {
742 742
 				$injected_items = array();
743
-				foreach ( $items[ $batch_type ] as $item ) {
743
+				foreach ( $items[$batch_type] as $item ) {
744 744
 					$injected_items[] = is_array( $item ) ? array_merge(
745 745
 						array(
746 746
 							'product_id' => $product_id,
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 						$item
749 749
 					) : $item;
750 750
 				}
751
-				$body_params[ $batch_type ] = $injected_items;
751
+				$body_params[$batch_type] = $injected_items;
752 752
 			}
753 753
 		}
754 754
 
Please login to merge, or discard this patch.