Passed
Push — master ( 8ebd9d...d9ef29 )
by Mike
05:12
created
src/Controllers/Version4/SystemStatusTools.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -494,7 +494,7 @@
 block discarded – undo
494 494
 				break;
495 495
 
496 496
 			case 'clear_sessions':
497
-				$wpdb->query( "TRUNCATE {$wpdb->prefix}woocommerce_sessions" );
497
+				$wpdb->query( "truncate {$wpdb->prefix}woocommerce_sessions" );
498 498
 				$result = absint( $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key='_woocommerce_persistent_cart_" . get_current_blog_id() . "';" ) ); // WPCS: unprepared SQL ok.
499 499
 				wp_cache_flush();
500 500
 				/* translators: %d: amount of sessions */
Please login to merge, or discard this patch.
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'],
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
 
529 529
 			default:
530 530
 				$tools = $this->get_tools();
531
-				if ( isset( $tools[ $tool ]['callback'] ) ) {
532
-					$callback = $tools[ $tool ]['callback'];
531
+				if ( isset( $tools[$tool]['callback'] ) ) {
532
+					$callback = $tools[$tool]['callback'];
533 533
 					$return   = call_user_func( $callback );
534 534
 					if ( is_string( $return ) ) {
535 535
 						$message = $return;
Please login to merge, or discard this patch.
src/Autoloader.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
 		}
77 77
 
78 78
 		if ( array_key_exists( $class, self::$classmap ) ) {
79
-			return include self::$classmap[ $class ];
79
+			return include self::$classmap[$class];
80 80
 		}
81 81
 	}
82 82
 }
Please login to merge, or discard this patch.
src/Controllers/Version4/OrderRefunds.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -141,19 +141,19 @@  discard block
 block discarded – undo
141 141
 
142 142
 		// Format decimal values.
143 143
 		foreach ( $format_decimal as $key ) {
144
-			$data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] );
144
+			$data[$key] = wc_format_decimal( $data[$key], $this->request['dp'] );
145 145
 		}
146 146
 
147 147
 		// Format date values.
148 148
 		foreach ( $format_date as $key ) {
149
-			$datetime              = $data[ $key ];
150
-			$data[ $key ]          = wc_rest_prepare_date_response( $datetime, false );
151
-			$data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime );
149
+			$datetime              = $data[$key];
150
+			$data[$key]          = wc_rest_prepare_date_response( $datetime, false );
151
+			$data[$key . '_gmt'] = wc_rest_prepare_date_response( $datetime );
152 152
 		}
153 153
 
154 154
 		// Format line items.
155 155
 		foreach ( $format_line_items as $key ) {
156
-			$data[ $key ] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[ $key ] ) );
156
+			$data[$key] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[$key] ) );
157 157
 		}
158 158
 
159 159
 		return array(
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 				$line_tax = array();
295 295
 
296 296
 				foreach ( $item_line_taxes['total'] as $tax_rate_id => $tax ) {
297
-					$line_tax[ $tax_rate_id ] = array(
297
+					$line_tax[$tax_rate_id] = array(
298 298
 						'id'       => $tax_rate_id,
299 299
 						'total'    => $tax,
300 300
 						'subtotal' => '',
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 				}
303 303
 
304 304
 				foreach ( $item_line_taxes['subtotal'] as $tax_rate_id => $tax ) {
305
-					$line_tax[ $tax_rate_id ]['subtotal'] = $tax;
305
+					$line_tax[$tax_rate_id]['subtotal'] = $tax;
306 306
 				}
307 307
 
308 308
 				$line_item['taxes'] = array_values( $line_tax );
Please login to merge, or discard this patch.
src/Controllers/Version4/SystemStatus.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 
70 70
 		foreach ( $mappings as $section => $values ) {
71 71
 			foreach ( $values as $key => $value ) {
72
-				if ( isset( $schema['properties'][ $section ]['properties'][ $key ]['type'] ) ) {
73
-					settype( $values[ $key ], $schema['properties'][ $section ]['properties'][ $key ]['type'] );
72
+				if ( isset( $schema['properties'][$section]['properties'][$key]['type'] ) ) {
73
+					settype( $values[$key], $schema['properties'][$section]['properties'][$key]['type'] );
74 74
 				}
75 75
 			}
76
-			settype( $values, $schema['properties'][ $section ]['type'] );
77
-			$response[ $section ] = $values;
76
+			settype( $values, $schema['properties'][$section]['type'] );
77
+			$response[$section] = $values;
78 78
 		}
79 79
 
80 80
 		$response = $this->prepare_item_for_response( $response, $request );
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 			}
765 765
 			$table_type = in_array( $table->name, $core_tables, true ) ? 'woocommerce' : 'other';
766 766
 
767
-			$tables[ $table_type ][ $table->name ] = array(
767
+			$tables[$table_type][$table->name] = array(
768 768
 				'data'   => $table->data,
769 769
 				'index'  => $table->index,
770 770
 				'engine' => $table->engine,
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
 		$version_latest = $data['Version'];
881 881
 
882 882
 		// Find latest version.
883
-		if ( isset( $this->available_updates[ $plugin ]->update->new_version ) ) {
884
-			$version_latest = $this->available_updates[ $plugin ]->update->new_version;
883
+		if ( isset( $this->available_updates[$plugin]->update->new_version ) ) {
884
+			$version_latest = $this->available_updates[$plugin]->update->new_version;
885 885
 		}
886 886
 
887 887
 		return array(
@@ -1023,14 +1023,14 @@  discard block
 block discarded – undo
1023 1023
 		$term_response = array();
1024 1024
 		$terms         = get_terms( 'product_type', array( 'hide_empty' => 0 ) );
1025 1025
 		foreach ( $terms as $term ) {
1026
-			$term_response[ $term->slug ] = strtolower( $term->name );
1026
+			$term_response[$term->slug] = strtolower( $term->name );
1027 1027
 		}
1028 1028
 
1029 1029
 		// Get a list of terms used for product visibility.
1030 1030
 		$product_visibility_terms = array();
1031 1031
 		$terms                    = get_terms( 'product_visibility', array( 'hide_empty' => 0 ) );
1032 1032
 		foreach ( $terms as $term ) {
1033
-			$product_visibility_terms[ $term->slug ] = strtolower( $term->name );
1033
+			$product_visibility_terms[$term->slug] = strtolower( $term->name );
1034 1034
 		}
1035 1035
 
1036 1036
 		// Check if WooCommerce.com account is connected.
Please login to merge, or discard this patch.
src/Controllers/Version4/Coupons.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -148,19 +148,19 @@  discard block
 block discarded – undo
148 148
 
149 149
 		// Format decimal values.
150 150
 		foreach ( $format_decimal as $key ) {
151
-			$data[ $key ] = wc_format_decimal( $data[ $key ], 2 );
151
+			$data[$key] = wc_format_decimal( $data[$key], 2 );
152 152
 		}
153 153
 
154 154
 		// Format date values.
155 155
 		foreach ( $format_date as $key ) {
156
-			$datetime              = $data[ $key ];
157
-			$data[ $key ]          = wc_rest_prepare_date_response( $datetime, false );
158
-			$data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime );
156
+			$datetime              = $data[$key];
157
+			$data[$key]          = wc_rest_prepare_date_response( $datetime, false );
158
+			$data[$key . '_gmt'] = wc_rest_prepare_date_response( $datetime );
159 159
 		}
160 160
 
161 161
 		// Format null values.
162 162
 		foreach ( $format_null as $key ) {
163
-			$data[ $key ] = $data[ $key ] ? $data[ $key ] : null;
163
+			$data[$key] = $data[$key] ? $data[$key] : null;
164 164
 		}
165 165
 
166 166
 		return array(
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 
267 267
 		// Handle all writable props.
268 268
 		foreach ( $data_keys as $key ) {
269
-			$value = $request[ $key ];
269
+			$value = $request[$key];
270 270
 
271 271
 			if ( ! is_null( $value ) ) {
272 272
 				switch ( $key ) {
Please login to merge, or discard this patch.
src/Controllers/Version4/Orders.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 
156 156
 		// Format decimal values.
157 157
 		foreach ( $format_decimal as $key ) {
158
-			if ( isset( $data[ $key ] ) ) {
159
-				$data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] );
158
+			if ( isset( $data[$key] ) ) {
159
+				$data[$key] = wc_format_decimal( $data[$key], $this->request['dp'] );
160 160
 			}
161 161
 		}
162 162
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 				$taxes[] = array(
175 175
 					'id'       => $tax_rate_id,
176 176
 					'total'    => $tax,
177
-					'subtotal' => isset( $data['taxes']['subtotal'][ $tax_rate_id ] ) ? $data['taxes']['subtotal'][ $tax_rate_id ] : '',
177
+					'subtotal' => isset( $data['taxes']['subtotal'][$tax_rate_id] ) ? $data['taxes']['subtotal'][$tax_rate_id] : '',
178 178
 				);
179 179
 			}
180 180
 			$data['taxes'] = $taxes;
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 
210 210
 		// Format decimal values.
211 211
 		foreach ( $format_decimal as $key ) {
212
-			$data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] );
212
+			$data[$key] = wc_format_decimal( $data[$key], $this->request['dp'] );
213 213
 		}
214 214
 
215 215
 		// Format date values.
216 216
 		foreach ( $format_date as $key ) {
217
-			$datetime              = $data[ $key ];
218
-			$data[ $key ]          = wc_rest_prepare_date_response( $datetime, false );
219
-			$data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime );
217
+			$datetime              = $data[$key];
218
+			$data[$key]          = wc_rest_prepare_date_response( $datetime, false );
219
+			$data[$key . '_gmt'] = wc_rest_prepare_date_response( $datetime );
220 220
 		}
221 221
 
222 222
 		// Format the order status.
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
 		// Format line items.
226 226
 		foreach ( $format_line_items as $key ) {
227
-			$data[ $key ] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[ $key ] ) );
227
+			$data[$key] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[$key] ) );
228 228
 		}
229 229
 
230 230
 		// Refunds.
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 
474 474
 		// Handle all writable props.
475 475
 		foreach ( $data_keys as $key ) {
476
-			$value = $request[ $key ];
476
+			$value = $request[$key];
477 477
 
478 478
 			if ( ! is_null( $value ) ) {
479 479
 				switch ( $key ) {
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
 	 * @param array         $posted Request data.
640 640
 	 */
641 641
 	protected function maybe_set_item_prop( $item, $prop, $posted ) {
642
-		if ( isset( $posted[ $prop ] ) ) {
643
-			$item->{"set_$prop"}( $posted[ $prop ] );
642
+		if ( isset( $posted[$prop] ) ) {
643
+			$item->{"set_$prop"}( $posted[$prop] );
644 644
 		}
645 645
 	}
646 646
 
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 		$keys = array( 'product_id', 'method_id', 'method_title', 'name', 'code' );
832 832
 
833 833
 		foreach ( $keys as $key ) {
834
-			if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) {
834
+			if ( array_key_exists( $key, $item ) && is_null( $item[$key] ) ) {
835 835
 				return true;
836 836
 			}
837 837
 		}
@@ -1707,7 +1707,7 @@  discard block
 block discarded – undo
1707 1707
 	public function get_collection_params() {
1708 1708
 		$params = parent::get_collection_params();
1709 1709
 
1710
-		$params['status']   = array(
1710
+		$params['status'] = array(
1711 1711
 			'default'           => 'any',
1712 1712
 			'description'       => __( 'Limit result set to orders which have specific statuses.', 'woocommerce' ),
1713 1713
 			'type'              => 'array',
@@ -1723,13 +1723,13 @@  discard block
 block discarded – undo
1723 1723
 			'sanitize_callback' => 'absint',
1724 1724
 			'validate_callback' => 'rest_validate_request_arg',
1725 1725
 		);
1726
-		$params['product']  = array(
1726
+		$params['product'] = array(
1727 1727
 			'description'       => __( 'Limit result set to orders assigned a specific product.', 'woocommerce' ),
1728 1728
 			'type'              => 'integer',
1729 1729
 			'sanitize_callback' => 'absint',
1730 1730
 			'validate_callback' => 'rest_validate_request_arg',
1731 1731
 		);
1732
-		$params['dp']       = array(
1732
+		$params['dp'] = array(
1733 1733
 			'default'           => wc_get_price_decimals(),
1734 1734
 			'description'       => __( 'Number of decimal points to use in each resource.', 'woocommerce' ),
1735 1735
 			'type'              => 'integer',
Please login to merge, or discard this patch.
src/Controllers/Version4/TaxClasses.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -232,7 +232,7 @@
 block discarded – undo
232 232
 		foreach ( $classes as $key => $class ) {
233 233
 			if ( sanitize_title( $class ) === $tax_class['slug'] ) {
234 234
 				$tax_class['name'] = $class;
235
-				unset( $classes[ $key ] );
235
+				unset( $classes[$key] );
236 236
 				$deleted = true;
237 237
 				break;
238 238
 			}
Please login to merge, or discard this patch.
src/Controllers/Version4/AbstractTermsContoller.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		$max_pages = ceil( $total_terms / $per_page );
354 354
 		$response->header( 'X-WP-TotalPages', (int) $max_pages );
355 355
 
356
-		$base  = str_replace( '(?P<attribute_id>[\d]+)', $request['attribute_id'], $this->rest_base );
356
+		$base = str_replace( '(?P<attribute_id>[\d]+)', $request['attribute_id'], $this->rest_base );
357 357
 		$base = add_query_arg( $request->get_query_params(), rest_url( '/' . $this->namespace . '/' . $base ) );
358 358
 		if ( $page > 1 ) {
359 359
 			$prev_page = $page - 1;
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 				'validate_callback' => 'rest_validate_request_arg',
729 729
 			);
730 730
 		}
731
-		$params['order']      = array(
731
+		$params['order'] = array(
732 732
 			'description'       => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
733 733
 			'type'              => 'string',
734 734
 			'sanitize_callback' => 'sanitize_key',
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 			),
740 740
 			'validate_callback' => 'rest_validate_request_arg',
741 741
 		);
742
-		$params['orderby']    = array(
742
+		$params['orderby'] = array(
743 743
 			'description'       => __( 'Sort collection by resource attribute.', 'woocommerce' ),
744 744
 			'type'              => 'string',
745 745
 			'sanitize_callback' => 'sanitize_key',
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 			'default'           => null,
776 776
 			'validate_callback' => 'rest_validate_request_arg',
777 777
 		);
778
-		$params['slug']    = array(
778
+		$params['slug'] = array(
779 779
 			'description'       => __( 'Limit result set to resources with a specific slug.', 'woocommerce' ),
780 780
 			'type'              => 'string',
781 781
 			'validate_callback' => 'rest_validate_request_arg',
Please login to merge, or discard this patch.
src/Controllers/Version4/Webhooks.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -722,13 +722,13 @@  discard block
 block discarded – undo
722 722
 
723 723
 		$params['context']['default'] = 'view';
724 724
 
725
-		$params['after']   = array(
725
+		$params['after'] = array(
726 726
 			'description'       => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
727 727
 			'type'              => 'string',
728 728
 			'format'            => 'date-time',
729 729
 			'validate_callback' => 'rest_validate_request_arg',
730 730
 		);
731
-		$params['before']  = array(
731
+		$params['before'] = array(
732 732
 			'description'       => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
733 733
 			'type'              => 'string',
734 734
 			'format'            => 'date-time',
@@ -752,13 +752,13 @@  discard block
 block discarded – undo
752 752
 			'default'           => array(),
753 753
 			'sanitize_callback' => 'wp_parse_id_list',
754 754
 		);
755
-		$params['offset']  = array(
755
+		$params['offset'] = array(
756 756
 			'description'       => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
757 757
 			'type'              => 'integer',
758 758
 			'sanitize_callback' => 'absint',
759 759
 			'validate_callback' => 'rest_validate_request_arg',
760 760
 		);
761
-		$params['order']   = array(
761
+		$params['order'] = array(
762 762
 			'description'       => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
763 763
 			'type'              => 'string',
764 764
 			'default'           => 'desc',
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 			),
777 777
 			'validate_callback' => 'rest_validate_request_arg',
778 778
 		);
779
-		$params['status']  = array(
779
+		$params['status'] = array(
780 780
 			'default'           => 'all',
781 781
 			'description'       => __( 'Limit result set to webhooks assigned a specific status.', 'woocommerce' ),
782 782
 			'type'              => 'string',
Please login to merge, or discard this patch.