Passed
Push — master ( a518b9...854ac9 )
by Mike
03:28
created
src/Controllers/Version4/OrderRefunds.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 * @return array Array of data in the correct format.
130 130
 	 */
131 131
 	protected function get_data_for_response( $object, $request ) {
132
-		$order = wc_get_order( (int) $request['order_id'] );
132
+		$order = wc_get_order( (int) $request[ 'order_id' ] );
133 133
 
134 134
 		if ( ! $order ) {
135 135
 			throw new \WC_REST_Exception( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce-rest-api' ), 404 );
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		$format_decimal    = array( 'amount' );
144 144
 		$format_date       = array( 'date_created' );
145 145
 		$format_line_items = array( 'line_items' );
146
-		$dp                = is_null( $request['dp'] ) ? wc_get_price_decimals() : absint( $request['dp'] );
146
+		$dp                = is_null( $request[ 'dp' ] ) ? wc_get_price_decimals() : absint( $request[ 'dp' ] );
147 147
 
148 148
 		// Format decimal values.
149 149
 		foreach ( $format_decimal as $key ) {
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
 
165 165
 		return array(
166 166
 			'id'               => $object->get_id(),
167
-			'date_created'     => $data['date_created'],
168
-			'date_created_gmt' => $data['date_created_gmt'],
169
-			'amount'           => $data['amount'],
170
-			'reason'           => $data['reason'],
171
-			'refunded_by'      => $data['refunded_by'],
172
-			'refunded_payment' => $data['refunded_payment'],
173
-			'meta_data'        => $data['meta_data'],
174
-			'line_items'       => $data['line_items'],
167
+			'date_created'     => $data[ 'date_created' ],
168
+			'date_created_gmt' => $data[ 'date_created_gmt' ],
169
+			'amount'           => $data[ 'amount' ],
170
+			'reason'           => $data[ 'reason' ],
171
+			'refunded_by'      => $data[ 'refunded_by' ],
172
+			'refunded_payment' => $data[ 'refunded_payment' ],
173
+			'meta_data'        => $data[ 'meta_data' ],
174
+			'line_items'       => $data[ 'line_items' ],
175 175
 		);
176 176
 	}
177 177
 
@@ -185,45 +185,45 @@  discard block
 block discarded – undo
185 185
 	protected function get_order_item_data( $item, $request ) {
186 186
 		$data           = $item->get_data();
187 187
 		$format_decimal = array( 'subtotal', 'subtotal_tax', 'total', 'total_tax', 'tax_total', 'shipping_tax_total' );
188
-		$dp             = is_null( $request['dp'] ) ? wc_get_price_decimals() : absint( $request['dp'] );
188
+		$dp             = is_null( $request[ 'dp' ] ) ? wc_get_price_decimals() : absint( $request[ 'dp' ] );
189 189
 
190 190
 		// Format decimal values.
191 191
 		foreach ( $format_decimal as $key ) {
192 192
 			if ( isset( $data[ $key ] ) ) {
193
-				$data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] );
193
+				$data[ $key ] = wc_format_decimal( $data[ $key ], $this->request[ 'dp' ] );
194 194
 			}
195 195
 		}
196 196
 
197 197
 		// Add SKU and PRICE to products.
198 198
 		if ( is_callable( array( $item, 'get_product' ) ) ) {
199
-			$data['sku']   = $item->get_product() ? $item->get_product()->get_sku() : null;
200
-			$data['price'] = $item->get_quantity() ? $item->get_total() / $item->get_quantity() : 0;
199
+			$data[ 'sku' ]   = $item->get_product() ? $item->get_product()->get_sku() : null;
200
+			$data[ 'price' ] = $item->get_quantity() ? $item->get_total() / $item->get_quantity() : 0;
201 201
 		}
202 202
 
203 203
 		// Format taxes.
204
-		if ( ! empty( $data['taxes']['total'] ) ) {
204
+		if ( ! empty( $data[ 'taxes' ][ 'total' ] ) ) {
205 205
 			$taxes = array();
206 206
 
207
-			foreach ( $data['taxes']['total'] as $tax_rate_id => $tax ) {
208
-				$taxes[] = array(
207
+			foreach ( $data[ 'taxes' ][ 'total' ] as $tax_rate_id => $tax ) {
208
+				$taxes[ ] = array(
209 209
 					'id'       => $tax_rate_id,
210 210
 					'total'    => $tax,
211
-					'subtotal' => isset( $data['taxes']['subtotal'][ $tax_rate_id ] ) ? $data['taxes']['subtotal'][ $tax_rate_id ] : '',
211
+					'subtotal' => isset( $data[ 'taxes' ][ 'subtotal' ][ $tax_rate_id ] ) ? $data[ 'taxes' ][ 'subtotal' ][ $tax_rate_id ] : '',
212 212
 				);
213 213
 			}
214
-			$data['taxes'] = $taxes;
215
-		} elseif ( isset( $data['taxes'] ) ) {
216
-			$data['taxes'] = array();
214
+			$data[ 'taxes' ] = $taxes;
215
+		} elseif ( isset( $data[ 'taxes' ] ) ) {
216
+			$data[ 'taxes' ] = array();
217 217
 		}
218 218
 
219 219
 		// Remove names for coupons, taxes and shipping.
220
-		if ( isset( $data['code'] ) || isset( $data['rate_code'] ) || isset( $data['method_title'] ) ) {
221
-			unset( $data['name'] );
220
+		if ( isset( $data[ 'code' ] ) || isset( $data[ 'rate_code' ] ) || isset( $data[ 'method_title' ] ) ) {
221
+			unset( $data[ 'name' ] );
222 222
 		}
223 223
 
224 224
 		// Remove props we don't want to expose.
225
-		unset( $data['order_id'] );
226
-		unset( $data['type'] );
225
+		unset( $data[ 'order_id' ] );
226
+		unset( $data[ 'type' ] );
227 227
 
228 228
 		return $data;
229 229
 	}
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
 	protected function prepare_objects_query( $request ) {
263 263
 		$args = parent::prepare_objects_query( $request );
264 264
 
265
-		$args['post_status']     = array_keys( wc_get_order_statuses() );
266
-		$args['post_parent__in'] = array( absint( $request['order_id'] ) );
265
+		$args[ 'post_status' ]     = array_keys( wc_get_order_statuses() );
266
+		$args[ 'post_parent__in' ] = array( absint( $request[ 'order_id' ] ) );
267 267
 
268 268
 		return $args;
269 269
 	}
@@ -275,18 +275,18 @@  discard block
 block discarded – undo
275 275
 	 * @return \WP_Error|\WP_REST_Response
276 276
 	 */
277 277
 	public function create_item( $request ) {
278
-		if ( ! empty( $request['id'] ) ) {
278
+		if ( ! empty( $request[ 'id' ] ) ) {
279 279
 			/* translators: %s: post type */
280 280
 			return new \WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 400 ) );
281 281
 		}
282 282
 
283
-		$order_data = get_post( (int) $request['order_id'] );
283
+		$order_data = get_post( (int) $request[ 'order_id' ] );
284 284
 
285 285
 		if ( empty( $order_data ) ) {
286 286
 			return new \WP_Error( 'woocommerce_rest_invalid_order', __( 'Order is invalid', 'woocommerce-rest-api' ), 400 );
287 287
 		}
288 288
 
289
-		if ( 0 > $request['amount'] ) {
289
+		if ( 0 > $request[ 'amount' ] ) {
290 290
 			return new \WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce-rest-api' ), 400 );
291 291
 		}
292 292
 
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 		$refund = wc_create_refund(
295 295
 			array(
296 296
 				'order_id'       => $order_data->ID,
297
-				'amount'         => $request['amount'],
298
-				'reason'         => empty( $request['reason'] ) ? null : $request['reason'],
299
-				'refund_payment' => is_bool( $request['api_refund'] ) ? $request['api_refund'] : true,
297
+				'amount'         => $request[ 'amount' ],
298
+				'reason'         => empty( $request[ 'reason' ] ) ? null : $request[ 'reason' ],
299
+				'refund_payment' => is_bool( $request[ 'api_refund' ] ) ? $request[ 'api_refund' ] : true,
300 300
 				'restock_items'  => true,
301 301
 			)
302 302
 		);
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
 	 * @return \WP_Error|\WC_Data The prepared item, or \WP_Error object on failure.
340 340
 	 */
341 341
 	protected function prepare_object_for_database( $request, $creating = false ) {
342
-		$order = wc_get_order( (int) $request['order_id'] );
342
+		$order = wc_get_order( (int) $request[ 'order_id' ] );
343 343
 
344 344
 		if ( ! $order ) {
345 345
 			return new \WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce-rest-api' ), 404 );
346 346
 		}
347 347
 
348
-		if ( 0 > $request['amount'] ) {
348
+		if ( 0 > $request[ 'amount' ] ) {
349 349
 			return new \WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce-rest-api' ), 400 );
350 350
 		}
351 351
 
@@ -353,10 +353,10 @@  discard block
 block discarded – undo
353 353
 		$refund = wc_create_refund(
354 354
 			array(
355 355
 				'order_id'       => $order->get_id(),
356
-				'amount'         => $request['amount'],
357
-				'reason'         => empty( $request['reason'] ) ? null : $request['reason'],
358
-				'line_items'     => empty( $request['line_items'] ) ? array() : $request['line_items'],
359
-				'refund_payment' => is_bool( $request['api_refund'] ) ? $request['api_refund'] : true,
356
+				'amount'         => $request[ 'amount' ],
357
+				'reason'         => empty( $request[ 'reason' ] ) ? null : $request[ 'reason' ],
358
+				'line_items'     => empty( $request[ 'line_items' ] ) ? array() : $request[ 'line_items' ],
359
+				'refund_payment' => is_bool( $request[ 'api_refund' ] ) ? $request[ 'api_refund' ] : true,
360 360
 				'restock_items'  => true,
361 361
 			)
362 362
 		);
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
 			return new \WP_Error( 'woocommerce_rest_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce-rest-api' ), 500 );
370 370
 		}
371 371
 
372
-		if ( ! empty( $request['meta_data'] ) && is_array( $request['meta_data'] ) ) {
373
-			foreach ( $request['meta_data'] as $meta ) {
374
-				$refund->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' );
372
+		if ( ! empty( $request[ 'meta_data' ] ) && is_array( $request[ 'meta_data' ] ) ) {
373
+			foreach ( $request[ 'meta_data' ] as $meta ) {
374
+				$refund->update_meta_data( $meta[ 'key' ], $meta[ 'value' ], isset( $meta[ 'id' ] ) ? $meta[ 'id' ] : '' );
375 375
 			}
376 376
 			$refund->save_meta_data();
377 377
 		}
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 	public function get_collection_params() {
651 651
 		$params = parent::get_collection_params();
652 652
 
653
-		$params['dp'] = array(
653
+		$params[ 'dp' ] = array(
654 654
 			'default'           => wc_get_price_decimals(),
655 655
 			'description'       => __( 'Number of decimal points to use in each resource.', 'woocommerce-rest-api' ),
656 656
 			'type'              => 'integer',
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 			'validate_callback' => 'rest_validate_request_arg',
659 659
 		);
660 660
 
661
-		unset( $params['status'], $params['customer'], $params['product'] );
661
+		unset( $params[ 'status' ], $params[ 'customer' ], $params[ 'product' ] );
662 662
 
663 663
 		return $params;
664 664
 	}
Please login to merge, or discard this patch.
src/Controllers/Version4/ProductAttributes.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		foreach ( $attributes as $attribute_obj ) {
128 128
 			$attribute = $this->prepare_item_for_response( $attribute_obj, $request );
129 129
 			$attribute = $this->prepare_response_for_collection( $attribute );
130
-			$data[]    = $attribute;
130
+			$data[ ]    = $attribute;
131 131
 		}
132 132
 
133 133
 		return rest_ensure_response( $data );
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 
145 145
 		$id = wc_create_attribute(
146 146
 			array(
147
-				'name'         => $request['name'],
148
-				'slug'         => wc_sanitize_taxonomy_name( stripslashes( $request['slug'] ) ),
149
-				'type'         => ! empty( $request['type'] ) ? $request['type'] : 'select',
150
-				'order_by'     => ! empty( $request['order_by'] ) ? $request['order_by'] : 'menu_order',
151
-				'has_archives' => true === $request['has_archives'],
147
+				'name'         => $request[ 'name' ],
148
+				'slug'         => wc_sanitize_taxonomy_name( stripslashes( $request[ 'slug' ] ) ),
149
+				'type'         => ! empty( $request[ 'type' ] ) ? $request[ 'type' ] : 'select',
150
+				'order_by'     => ! empty( $request[ 'order_by' ] ) ? $request[ 'order_by' ] : 'menu_order',
151
+				'has_archives' => true === $request[ 'has_archives' ],
152 152
 			)
153 153
 		);
154 154
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @return \WP_REST_Request|\WP_Error
191 191
 	 */
192 192
 	public function get_item( $request ) {
193
-		$attribute = $this->get_attribute( (int) $request['id'] );
193
+		$attribute = $this->get_attribute( (int) $request[ 'id' ] );
194 194
 
195 195
 		if ( is_wp_error( $attribute ) ) {
196 196
 			return $attribute;
@@ -210,15 +210,15 @@  discard block
 block discarded – undo
210 210
 	public function update_item( $request ) {
211 211
 		global $wpdb;
212 212
 
213
-		$id     = (int) $request['id'];
213
+		$id     = (int) $request[ 'id' ];
214 214
 		$edited = wc_update_attribute(
215 215
 			$id,
216 216
 			array(
217
-				'name'         => $request['name'],
218
-				'slug'         => wc_sanitize_taxonomy_name( stripslashes( $request['slug'] ) ),
219
-				'type'         => $request['type'],
220
-				'order_by'     => $request['order_by'],
221
-				'has_archives' => $request['has_archives'],
217
+				'name'         => $request[ 'name' ],
218
+				'slug'         => wc_sanitize_taxonomy_name( stripslashes( $request[ 'slug' ] ) ),
219
+				'type'         => $request[ 'type' ],
220
+				'order_by'     => $request[ 'order_by' ],
221
+				'has_archives' => $request[ 'has_archives' ],
222 222
 			)
223 223
 		);
224 224
 
@@ -257,14 +257,14 @@  discard block
 block discarded – undo
257 257
 	 * @return \WP_REST_Response|\WP_Error
258 258
 	 */
259 259
 	public function delete_item( $request ) {
260
-		$force = isset( $request['force'] ) ? (bool) $request['force'] : false;
260
+		$force = isset( $request[ 'force' ] ) ? (bool) $request[ 'force' ] : false;
261 261
 
262 262
 		// We don't support trashing for this type, error out.
263 263
 		if ( ! $force ) {
264 264
 			return new \WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Resource does not support trashing.', 'woocommerce-rest-api' ), array( 'status' => 501 ) );
265 265
 		}
266 266
 
267
-		$attribute = $this->get_attribute( (int) $request['id'] );
267
+		$attribute = $this->get_attribute( (int) $request[ 'id' ] );
268 268
 
269 269
 		if ( is_wp_error( $attribute ) ) {
270 270
 			return $attribute;
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	 */
404 404
 	public function get_collection_params() {
405 405
 		$params = array();
406
-		$params['context'] = $this->get_context_param( array( 'default' => 'view' ) );
406
+		$params[ 'context' ] = $this->get_context_param( array( 'default' => 'view' ) );
407 407
 
408 408
 		return $params;
409 409
 	}
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 			return $this->attribute;
420 420
 		}
421 421
 
422
-		if ( $request['id'] ) {
423
-			$name = wc_attribute_taxonomy_name_by_id( (int) $request['id'] );
422
+		if ( $request[ 'id' ] ) {
423
+			$name = wc_attribute_taxonomy_name_by_id( (int) $request[ 'id' ] );
424 424
 
425 425
 			$this->attribute = $name;
426 426
 		}
Please login to merge, or discard this patch.
src/Controllers/Version4/Coupons.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -74,32 +74,32 @@  discard block
 block discarded – undo
74 74
 
75 75
 		return array(
76 76
 			'id'                          => $object->get_id(),
77
-			'code'                        => $data['code'],
78
-			'amount'                      => $data['amount'],
79
-			'date_created'                => $data['date_created'],
80
-			'date_created_gmt'            => $data['date_created_gmt'],
81
-			'date_modified'               => $data['date_modified'],
82
-			'date_modified_gmt'           => $data['date_modified_gmt'],
83
-			'discount_type'               => $data['discount_type'],
84
-			'description'                 => $data['description'],
85
-			'date_expires'                => $data['date_expires'],
86
-			'date_expires_gmt'            => $data['date_expires_gmt'],
87
-			'usage_count'                 => $data['usage_count'],
88
-			'individual_use'              => $data['individual_use'],
89
-			'product_ids'                 => $data['product_ids'],
90
-			'excluded_product_ids'        => $data['excluded_product_ids'],
91
-			'usage_limit'                 => $data['usage_limit'],
92
-			'usage_limit_per_user'        => $data['usage_limit_per_user'],
93
-			'limit_usage_to_x_items'      => $data['limit_usage_to_x_items'],
94
-			'free_shipping'               => $data['free_shipping'],
95
-			'product_categories'          => $data['product_categories'],
96
-			'excluded_product_categories' => $data['excluded_product_categories'],
97
-			'exclude_sale_items'          => $data['exclude_sale_items'],
98
-			'minimum_amount'              => $data['minimum_amount'],
99
-			'maximum_amount'              => $data['maximum_amount'],
100
-			'email_restrictions'          => $data['email_restrictions'],
101
-			'used_by'                     => $data['used_by'],
102
-			'meta_data'                   => $data['meta_data'],
77
+			'code'                        => $data[ 'code' ],
78
+			'amount'                      => $data[ 'amount' ],
79
+			'date_created'                => $data[ 'date_created' ],
80
+			'date_created_gmt'            => $data[ 'date_created_gmt' ],
81
+			'date_modified'               => $data[ 'date_modified' ],
82
+			'date_modified_gmt'           => $data[ 'date_modified_gmt' ],
83
+			'discount_type'               => $data[ 'discount_type' ],
84
+			'description'                 => $data[ 'description' ],
85
+			'date_expires'                => $data[ 'date_expires' ],
86
+			'date_expires_gmt'            => $data[ 'date_expires_gmt' ],
87
+			'usage_count'                 => $data[ 'usage_count' ],
88
+			'individual_use'              => $data[ 'individual_use' ],
89
+			'product_ids'                 => $data[ 'product_ids' ],
90
+			'excluded_product_ids'        => $data[ 'excluded_product_ids' ],
91
+			'usage_limit'                 => $data[ 'usage_limit' ],
92
+			'usage_limit_per_user'        => $data[ 'usage_limit_per_user' ],
93
+			'limit_usage_to_x_items'      => $data[ 'limit_usage_to_x_items' ],
94
+			'free_shipping'               => $data[ 'free_shipping' ],
95
+			'product_categories'          => $data[ 'product_categories' ],
96
+			'excluded_product_categories' => $data[ 'excluded_product_categories' ],
97
+			'exclude_sale_items'          => $data[ 'exclude_sale_items' ],
98
+			'minimum_amount'              => $data[ 'minimum_amount' ],
99
+			'maximum_amount'              => $data[ 'maximum_amount' ],
100
+			'email_restrictions'          => $data[ 'email_restrictions' ],
101
+			'used_by'                     => $data[ 'used_by' ],
102
+			'meta_data'                   => $data[ 'meta_data' ],
103 103
 		);
104 104
 	}
105 105
 
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
 	protected function prepare_objects_query( $request ) {
114 114
 		$args = parent::prepare_objects_query( $request );
115 115
 
116
-		if ( ! empty( $request['code'] ) ) {
117
-			$id               = wc_get_coupon_id_by_code( $request['code'] );
118
-			$args['post__in'] = array( $id );
116
+		if ( ! empty( $request[ 'code' ] ) ) {
117
+			$id               = wc_get_coupon_id_by_code( $request[ 'code' ] );
118
+			$args[ 'post__in' ] = array( $id );
119 119
 		}
120 120
 
121
-		if ( ! empty( $request['search'] ) ) {
122
-			$args['search'] = $request['search'];
123
-			$args['s']      = false;
121
+		if ( ! empty( $request[ 'search' ] ) ) {
122
+			$args[ 'search' ] = $request[ 'search' ];
123
+			$args[ 's' ]      = false;
124 124
 		}
125 125
 
126 126
 		return $args;
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 	 * @return \WP_Error|\WC_Data
135 135
 	 */
136 136
 	protected function prepare_object_for_database( $request, $creating = false ) {
137
-		$id        = isset( $request['id'] ) ? absint( $request['id'] ) : 0;
137
+		$id        = isset( $request[ 'id' ] ) ? absint( $request[ 'id' ] ) : 0;
138 138
 		$coupon    = new \WC_Coupon( $id );
139 139
 		$schema    = $this->get_item_schema();
140
-		$data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) );
140
+		$data_keys = array_keys( array_filter( $schema[ 'properties' ], array( $this, 'filter_writable_props' ) ) );
141 141
 
142 142
 		// Validate required POST fields.
143
-		if ( $creating && empty( $request['code'] ) ) {
143
+		if ( $creating && empty( $request[ 'code' ] ) ) {
144 144
 			return new \WP_Error( 'woocommerce_rest_empty_coupon_code', sprintf( __( 'The coupon code cannot be empty.', 'woocommerce-rest-api' ), 'code' ), array( 'status' => 400 ) );
145 145
 		}
146 146
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 					case 'meta_data':
165 165
 						if ( is_array( $value ) ) {
166 166
 							foreach ( $value as $meta ) {
167
-								$coupon->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : 0 );
167
+								$coupon->update_meta_data( $meta[ 'key' ], $meta[ 'value' ], isset( $meta[ 'id' ] ) ? $meta[ 'id' ] : 0 );
168 168
 							}
169 169
 						}
170 170
 						break;
@@ -404,14 +404,14 @@  discard block
 block discarded – undo
404 404
 	public function get_collection_params() {
405 405
 		$params = parent::get_collection_params();
406 406
 
407
-		$params['code'] = array(
407
+		$params[ 'code' ] = array(
408 408
 			'description'       => __( 'Limit result set to resources with a specific code.', 'woocommerce-rest-api' ),
409 409
 			'type'              => 'string',
410 410
 			'sanitize_callback' => 'sanitize_text_field',
411 411
 			'validate_callback' => 'rest_validate_request_arg',
412 412
 		);
413 413
 
414
-		$params['search'] = array(
414
+		$params[ 'search' ] = array(
415 415
 			'description'       => __( 'Limit results to coupons with codes matching a given string.', 'woocommerce-rest-api' ),
416 416
 			'type'              => 'string',
417 417
 			'validate_callback' => 'rest_validate_request_arg',
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 	 * @return bool
428 428
 	 */
429 429
 	protected function filter_writable_props( $schema ) {
430
-		return empty( $schema['readonly'] );
430
+		return empty( $schema[ 'readonly' ] );
431 431
 	}
432 432
 
433 433
 	/**
Please login to merge, or discard this patch.
src/Controllers/Version4/Orders.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 	protected function get_data_for_response( $object, $request ) {
68 68
 		$formatter = new OrderResponse();
69 69
 
70
-		if ( ! is_null( $request['dp'] ) ) {
71
-			$formatter->set_dp( $request['dp'] );
70
+		if ( ! is_null( $request[ 'dp' ] ) ) {
71
+			$formatter->set_dp( $request[ 'dp' ] );
72 72
 		}
73 73
 
74 74
 		return $formatter->prepare_response( $object, $this->get_request_context( $request ) );
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
 		);
93 93
 
94 94
 		if ( 0 !== (int) $item->get_customer_id() ) {
95
-			$links['customer'] = array(
95
+			$links[ 'customer' ] = array(
96 96
 				'href' => rest_url( sprintf( '/%s/customers/%d', $this->namespace, $item->get_customer_id() ) ),
97 97
 			);
98 98
 		}
99 99
 
100 100
 		if ( 0 !== (int) $item->get_parent_id() ) {
101
-			$links['up'] = array(
101
+			$links[ 'up' ] = array(
102 102
 				'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $item->get_parent_id() ) ),
103 103
 			);
104 104
 		}
@@ -117,71 +117,71 @@  discard block
 block discarded – undo
117 117
 		global $wpdb;
118 118
 
119 119
 		// This is needed to get around an array to string notice in \WC_REST_Orders_V2_Controller::prepare_objects_query.
120
-		$statuses = $request['status'];
121
-		unset( $request['status'] );
120
+		$statuses = $request[ 'status' ];
121
+		unset( $request[ 'status' ] );
122 122
 		$args = parent::prepare_objects_query( $request );
123 123
 
124
-		$args['post_status'] = array();
124
+		$args[ 'post_status' ] = array();
125 125
 		foreach ( $statuses as $status ) {
126 126
 			if ( in_array( $status, $this->get_order_statuses(), true ) ) {
127
-				$args['post_status'][] = 'wc-' . $status;
127
+				$args[ 'post_status' ][ ] = 'wc-' . $status;
128 128
 			} elseif ( 'any' === $status ) {
129 129
 				// Set status to "any" and short-circuit out.
130
-				$args['post_status'] = 'any';
130
+				$args[ 'post_status' ] = 'any';
131 131
 				break;
132 132
 			} else {
133
-				$args['post_status'][] = $status;
133
+				$args[ 'post_status' ][ ] = $status;
134 134
 			}
135 135
 		}
136 136
 
137 137
 		// Put the statuses back for further processing (next/prev links, etc).
138
-		$request['status'] = $statuses;
138
+		$request[ 'status' ] = $statuses;
139 139
 
140 140
 		// Customer.
141
-		if ( isset( $request['customer'] ) ) {
142
-			if ( ! empty( $args['meta_query'] ) ) {
143
-				$args['meta_query'] = array(); // WPCS: slow query ok.
141
+		if ( isset( $request[ 'customer' ] ) ) {
142
+			if ( ! empty( $args[ 'meta_query' ] ) ) {
143
+				$args[ 'meta_query' ] = array(); // WPCS: slow query ok.
144 144
 			}
145 145
 
146
-			$args['meta_query'][] = array(
146
+			$args[ 'meta_query' ][ ] = array(
147 147
 				'key'   => '_customer_user',
148
-				'value' => $request['customer'],
148
+				'value' => $request[ 'customer' ],
149 149
 				'type'  => 'NUMERIC',
150 150
 			);
151 151
 		}
152 152
 
153 153
 		// Search by product.
154
-		if ( ! empty( $request['product'] ) ) {
154
+		if ( ! empty( $request[ 'product' ] ) ) {
155 155
 			$order_ids = $wpdb->get_col(
156 156
 				$wpdb->prepare(
157 157
 					"SELECT order_id
158 158
 					FROM {$wpdb->prefix}woocommerce_order_items
159 159
 					WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = '_product_id' AND meta_value = %d )
160 160
 					AND order_item_type = 'line_item'",
161
-					$request['product']
161
+					$request[ 'product' ]
162 162
 				)
163 163
 			);
164 164
 
165 165
 			// Force WP_Query return empty if don't found any order.
166 166
 			$order_ids = ! empty( $order_ids ) ? $order_ids : array( 0 );
167 167
 
168
-			$args['post__in'] = $order_ids;
168
+			$args[ 'post__in' ] = $order_ids;
169 169
 		}
170 170
 
171 171
 		// Search.
172
-		if ( ! empty( $args['s'] ) ) {
173
-			$order_ids = wc_order_search( $args['s'] );
172
+		if ( ! empty( $args[ 's' ] ) ) {
173
+			$order_ids = wc_order_search( $args[ 's' ] );
174 174
 
175 175
 			if ( ! empty( $order_ids ) ) {
176
-				unset( $args['s'] );
177
-				$args['post__in'] = array_merge( $order_ids, array( 0 ) );
176
+				unset( $args[ 's' ] );
177
+				$args[ 'post__in' ] = array_merge( $order_ids, array( 0 ) );
178 178
 			}
179 179
 		}
180 180
 
181 181
 		// Search by partial order number.
182
-		if ( ! empty( $request['number'] ) ) {
183
-			$partial_number = trim( $request['number'] );
184
-			$limit          = intval( $args['posts_per_page'] );
182
+		if ( ! empty( $request[ 'number' ] ) ) {
183
+			$partial_number = trim( $request[ 'number' ] );
184
+			$limit          = intval( $args[ 'posts_per_page' ] );
185 185
 			$order_ids      = $wpdb->get_col(
186 186
 				$wpdb->prepare(
187 187
 					"SELECT ID
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
 			// Force \WP_Query return empty if don't found any order.
198 198
 			$order_ids        = empty( $order_ids ) ? array( 0 ) : $order_ids;
199
-			$args['post__in'] = $order_ids;
199
+			$args[ 'post__in' ] = $order_ids;
200 200
 		}
201 201
 
202 202
 		return $args;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 				$object->calculate_totals();
257 257
 			} else {
258 258
 				// If items have changed, recalculate order totals.
259
-				if ( isset( $request['billing'] ) || isset( $request['shipping'] ) || isset( $request['line_items'] ) || isset( $request['shipping_lines'] ) || isset( $request['fee_lines'] ) || isset( $request['coupon_lines'] ) ) {
259
+				if ( isset( $request[ 'billing' ] ) || isset( $request[ 'shipping' ] ) || isset( $request[ 'line_items' ] ) || isset( $request[ 'shipping_lines' ] ) || isset( $request[ 'fee_lines' ] ) || isset( $request[ 'coupon_lines' ] ) ) {
260 260
 					$object->calculate_totals( true );
261 261
 				}
262 262
 			}
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 			$object->save();
265 265
 
266 266
 			// Actions for after the order is saved.
267
-			if ( true === $request['set_paid'] && ( $creating || $object->needs_payment() ) ) {
267
+			if ( true === $request[ 'set_paid' ] && ( $creating || $object->needs_payment() ) ) {
268 268
 				$object->payment_complete();
269 269
 			}
270 270
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 		$order_statuses = array();
286 286
 
287 287
 		foreach ( array_keys( wc_get_order_statuses() ) as $status ) {
288
-			$order_statuses[] = str_replace( 'wc-', '', $status );
288
+			$order_statuses[ ] = str_replace( 'wc-', '', $status );
289 289
 		}
290 290
 
291 291
 		return $order_statuses;
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 	public function get_collection_params() {
1145 1145
 		$params = parent::get_collection_params();
1146 1146
 
1147
-		$params['status']   = array(
1147
+		$params[ 'status' ] = array(
1148 1148
 			'default'           => 'any',
1149 1149
 			'description'       => __( 'Limit result set to orders which have specific statuses.', 'woocommerce-rest-api' ),
1150 1150
 			'type'              => 'array',
@@ -1154,19 +1154,19 @@  discard block
 block discarded – undo
1154 1154
 			),
1155 1155
 			'validate_callback' => 'rest_validate_request_arg',
1156 1156
 		);
1157
-		$params['customer'] = array(
1157
+		$params[ 'customer' ] = array(
1158 1158
 			'description'       => __( 'Limit result set to orders assigned a specific customer.', 'woocommerce-rest-api' ),
1159 1159
 			'type'              => 'integer',
1160 1160
 			'sanitize_callback' => 'absint',
1161 1161
 			'validate_callback' => 'rest_validate_request_arg',
1162 1162
 		);
1163
-		$params['product']  = array(
1163
+		$params[ 'product' ] = array(
1164 1164
 			'description'       => __( 'Limit result set to orders assigned a specific product.', 'woocommerce-rest-api' ),
1165 1165
 			'type'              => 'integer',
1166 1166
 			'sanitize_callback' => 'absint',
1167 1167
 			'validate_callback' => 'rest_validate_request_arg',
1168 1168
 		);
1169
-		$params['dp']       = array(
1169
+		$params[ 'dp' ] = array(
1170 1170
 			'default'           => wc_get_price_decimals(),
1171 1171
 			'description'       => __( 'Number of decimal points to use in each resource.', 'woocommerce-rest-api' ),
1172 1172
 			'type'              => 'integer',
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
 			'validate_callback' => 'rest_validate_request_arg',
1175 1175
 		);
1176 1176
 		// This needs to remain a string to support extensions that filter Order Number.
1177
-		$params['number'] = array(
1177
+		$params[ 'number' ] = array(
1178 1178
 			'description'       => __( 'Limit result set to orders matching part of an order number.', 'woocommerce-rest-api' ),
1179 1179
 			'type'              => 'string',
1180 1180
 			'validate_callback' => 'rest_validate_request_arg',
Please login to merge, or discard this patch.
src/Controllers/Version4/TaxClasses.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		$tax_classes = array();
94 94
 
95 95
 		// Add standard class.
96
-		$tax_classes[] = array(
96
+		$tax_classes[ ] = array(
97 97
 			'slug' => 'standard',
98 98
 			'name' => __( 'Standard rate', 'woocommerce-rest-api' ),
99 99
 		);
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		$classes = \WC_Tax::get_tax_classes();
102 102
 
103 103
 		foreach ( $classes as $class ) {
104
-			$tax_classes[] = array(
104
+			$tax_classes[ ] = array(
105 105
 				'slug' => sanitize_title( $class ),
106 106
 				'name' => $class,
107 107
 			);
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		foreach ( $tax_classes as $tax_class ) {
112 112
 			$class  = $this->prepare_item_for_response( $tax_class, $request );
113 113
 			$class  = $this->prepare_response_for_collection( $class );
114
-			$data[] = $class;
114
+			$data[ ] = $class;
115 115
 		}
116 116
 
117 117
 		return rest_ensure_response( $data );
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
 		$exists    = false;
128 128
 		$classes   = \WC_Tax::get_tax_classes();
129 129
 		$tax_class = array(
130
-			'slug' => sanitize_title( $request['name'] ),
131
-			'name' => $request['name'],
130
+			'slug' => sanitize_title( $request[ 'name' ] ),
131
+			'name' => $request[ 'name' ],
132 132
 		);
133 133
 
134 134
 		// Check if class exists.
135 135
 		foreach ( $classes as $key => $class ) {
136
-			if ( sanitize_title( $class ) === $tax_class['slug'] ) {
136
+			if ( sanitize_title( $class ) === $tax_class[ 'slug' ] ) {
137 137
 				$exists = true;
138 138
 				break;
139 139
 			}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		}
146 146
 
147 147
 		// Add the new class.
148
-		$classes[] = $tax_class['name'];
148
+		$classes[ ] = $tax_class[ 'name' ];
149 149
 
150 150
 		update_option( 'woocommerce_tax_classes', implode( "\n", $classes ) );
151 151
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 		$response = $this->prepare_item_for_response( $tax_class, $request );
165 165
 		$response = rest_ensure_response( $response );
166 166
 		$response->set_status( 201 );
167
-		$response->header( 'Location', rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $tax_class['slug'] ) ) );
167
+		$response->header( 'Location', rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $tax_class[ 'slug' ] ) ) );
168 168
 
169 169
 		return $response;
170 170
 	}
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	public function delete_item( $request ) {
179 179
 		global $wpdb;
180 180
 
181
-		$force = isset( $request['force'] ) ? (bool) $request['force'] : false;
181
+		$force = isset( $request[ 'force' ] ) ? (bool) $request[ 'force' ] : false;
182 182
 
183 183
 		// We don't support trashing for this type, error out.
184 184
 		if ( ! $force ) {
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 		}
187 187
 
188 188
 		$tax_class = array(
189
-			'slug' => sanitize_title( $request['slug'] ),
189
+			'slug' => sanitize_title( $request[ 'slug' ] ),
190 190
 			'name' => '',
191 191
 		);
192 192
 		$classes = \WC_Tax::get_tax_classes();
193 193
 		$deleted = false;
194 194
 
195 195
 		foreach ( $classes as $key => $class ) {
196
-			if ( sanitize_title( $class ) === $tax_class['slug'] ) {
197
-				$tax_class['name'] = $class;
196
+			if ( sanitize_title( $class ) === $tax_class[ 'slug' ] ) {
197
+				$tax_class[ 'name' ] = $class;
198 198
 				unset( $classes[ $key ] );
199 199
 				$deleted = true;
200 200
 				break;
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
 					ON rates.tax_rate_id = locations.tax_rate_id
222 222
 				WHERE rates.tax_rate_class = %s
223 223
 				",
224
-				$tax_class['slug']
224
+				$tax_class[ 'slug' ]
225 225
 			)
226 226
 		);
227 227
 
228 228
 		// Delete tax rates in the selected class.
229
-		$wpdb->delete( $wpdb->prefix . 'woocommerce_tax_rates', array( 'tax_rate_class' => $tax_class['slug'] ), array( '%s' ) );
229
+		$wpdb->delete( $wpdb->prefix . 'woocommerce_tax_rates', array( 'tax_rate_class' => $tax_class[ 'slug' ] ), array( '%s' ) );
230 230
 
231 231
 		$response = new \WP_REST_Response();
232 232
 		$response->set_data(
Please login to merge, or discard this patch.
src/Controllers/Version4/Utilities/ServerEnvironment.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -44,18 +44,18 @@  discard block
 block discarded – undo
44 44
 			'curl_version'              => $this->get_curl_version(),
45 45
 			'suhosin_installed'         => extension_loaded( 'suhosin' ),
46 46
 			'max_upload_size'           => wp_max_upload_size(),
47
-			'mysql_version'             => $database_version['number'],
48
-			'mysql_version_string'      => $database_version['string'],
47
+			'mysql_version'             => $database_version[ 'number' ],
48
+			'mysql_version_string'      => $database_version[ 'string' ],
49 49
 			'default_timezone'          => date_default_timezone_get(),
50 50
 			'fsockopen_or_curl_enabled' => $this->fsockopen_or_curl_enabled(),
51 51
 			'soapclient_enabled'        => class_exists( 'SoapClient' ),
52 52
 			'domdocument_enabled'       => class_exists( 'DOMDocument' ),
53 53
 			'gzip_enabled'              => is_callable( 'gzopen' ),
54 54
 			'mbstring_enabled'          => extension_loaded( 'mbstring' ),
55
-			'remote_post_successful'    => $post_request['success'],
56
-			'remote_post_response'      => $post_request['response'],
57
-			'remote_get_successful'     => $get_request['success'],
58
-			'remote_get_response'       => $get_request['response'],
55
+			'remote_post_successful'    => $post_request[ 'success' ],
56
+			'remote_post_response'      => $post_request[ 'response' ],
57
+			'remote_get_successful'     => $get_request[ 'success' ],
58
+			'remote_get_response'       => $get_request[ 'response' ],
59 59
 		);
60 60
 	}
61 61
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 				)
81 81
 			);
82 82
 			if ( ! is_wp_error( $response ) ) {
83
-				$post_response_code = $response['response']['code'];
83
+				$post_response_code = $response[ 'response' ][ 'code' ];
84 84
 			}
85 85
 			set_transient( 'woocommerce_test_remote_post', $post_response_code, HOUR_IN_SECONDS );
86 86
 		}
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		if ( false === $get_response_code || is_wp_error( $get_response_code ) ) {
110 110
 			$response = wp_safe_remote_get( 'https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ) );
111 111
 			if ( ! is_wp_error( $response ) ) {
112
-				$get_response_code = $response['response']['code'];
112
+				$get_response_code = $response[ 'response' ][ 'code' ];
113 113
 			}
114 114
 			set_transient( 'woocommerce_test_remote_get', $get_response_code, HOUR_IN_SECONDS );
115 115
 		}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * @return string
144 144
 	 */
145 145
 	protected function get_server_software() {
146
-		return isset( $_SERVER['SERVER_SOFTWARE'] ) ? wc_clean( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '';
146
+		return isset( $_SERVER[ 'SERVER_SOFTWARE' ] ) ? wc_clean( wp_unslash( $_SERVER[ 'SERVER_SOFTWARE' ] ) ) : '';
147 147
 	}
148 148
 
149 149
 	/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		$curl_version = '';
156 156
 		if ( function_exists( 'curl_version' ) ) {
157 157
 			$curl_version = curl_version();
158
-			$curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version'];
158
+			$curl_version = $curl_version[ 'version' ] . ', ' . $curl_version[ 'ssl_version' ];
159 159
 		} elseif ( extension_loaded( 'curl' ) ) {
160 160
 			$curl_version = __( 'cURL installed but unable to retrieve version.', 'woocommerce-rest-api' );
161 161
 		}
Please login to merge, or discard this patch.
src/Controllers/Version4/Utilities/SettingsTrait.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @return string|\WP_Error
34 34
 	 */
35 35
 	public function validate_setting_select_field( $value, $setting ) {
36
-		if ( array_key_exists( $value, $setting['options'] ) ) {
36
+		if ( array_key_exists( $value, $setting[ 'options' ] ) ) {
37 37
 			return $value;
38 38
 		} else {
39 39
 			return new \WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 
60 60
 		$final_values = array();
61 61
 		foreach ( $values as $value ) {
62
-			if ( array_key_exists( $value, $setting['options'] ) ) {
63
-				$final_values[] = $value;
62
+			if ( array_key_exists( $value, $setting[ 'options' ] ) ) {
63
+				$final_values[ ] = $value;
64 64
 			}
65 65
 		}
66 66
 
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
 			return new \WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
81 81
 		}
82 82
 
83
-		$current = $setting['value'];
84
-		if ( isset( $values['width'] ) ) {
85
-			$current['width'] = intval( $values['width'] );
83
+		$current = $setting[ 'value' ];
84
+		if ( isset( $values[ 'width' ] ) ) {
85
+			$current[ 'width' ] = intval( $values[ 'width' ] );
86 86
 		}
87
-		if ( isset( $values['height'] ) ) {
88
-			$current['height'] = intval( $values['height'] );
87
+		if ( isset( $values[ 'height' ] ) ) {
88
+			$current[ 'height' ] = intval( $values[ 'height' ] );
89 89
 		}
90
-		if ( isset( $values['crop'] ) ) {
91
-			$current['crop'] = (bool) $values['crop'];
90
+		if ( isset( $values[ 'crop' ] ) ) {
91
+			$current[ 'crop' ] = (bool) $values[ 'crop' ];
92 92
 		}
93 93
 		return $current;
94 94
 	}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		if ( in_array( $value, array( 'yes', 'no' ), true ) ) {
118 118
 			return $value;
119 119
 		} elseif ( empty( $value ) ) {
120
-			$value = isset( $setting['default'] ) ? $setting['default'] : 'no';
120
+			$value = isset( $setting[ 'default' ] ) ? $setting[ 'default' ] : 'no';
121 121
 			return $value;
122 122
 		} else {
123 123
 			return new \WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
Please login to merge, or discard this patch.
src/Controllers/Version4/AbstractTermsContoller.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -132,32 +132,32 @@  discard block
 block discarded – undo
132 132
 	public function get_items( $request ) {
133 133
 		$taxonomy      = $this->get_taxonomy( $request );
134 134
 		$prepared_args = array(
135
-			'exclude'    => $request['exclude'],
136
-			'include'    => $request['include'],
137
-			'order'      => $request['order'],
138
-			'orderby'    => $request['orderby'],
139
-			'product'    => $request['product'],
140
-			'hide_empty' => $request['hide_empty'],
141
-			'number'     => $request['per_page'],
142
-			'search'     => $request['search'],
143
-			'slug'       => $request['slug'],
135
+			'exclude'    => $request[ 'exclude' ],
136
+			'include'    => $request[ 'include' ],
137
+			'order'      => $request[ 'order' ],
138
+			'orderby'    => $request[ 'orderby' ],
139
+			'product'    => $request[ 'product' ],
140
+			'hide_empty' => $request[ 'hide_empty' ],
141
+			'number'     => $request[ 'per_page' ],
142
+			'search'     => $request[ 'search' ],
143
+			'slug'       => $request[ 'slug' ],
144 144
 		);
145 145
 
146
-		if ( ! empty( $request['offset'] ) ) {
147
-			$prepared_args['offset'] = $request['offset'];
146
+		if ( ! empty( $request[ 'offset' ] ) ) {
147
+			$prepared_args[ 'offset' ] = $request[ 'offset' ];
148 148
 		} else {
149
-			$prepared_args['offset'] = ( $request['page'] - 1 ) * $prepared_args['number'];
149
+			$prepared_args[ 'offset' ] = ( $request[ 'page' ] - 1 ) * $prepared_args[ 'number' ];
150 150
 		}
151 151
 
152 152
 		$taxonomy_obj = get_taxonomy( $taxonomy );
153 153
 
154
-		if ( $taxonomy_obj->hierarchical && isset( $request['parent'] ) ) {
155
-			if ( 0 === $request['parent'] ) {
154
+		if ( $taxonomy_obj->hierarchical && isset( $request[ 'parent' ] ) ) {
155
+			if ( 0 === $request[ 'parent' ] ) {
156 156
 				// Only query top-level terms.
157
-				$prepared_args['parent'] = 0;
157
+				$prepared_args[ 'parent' ] = 0;
158 158
 			} else {
159
-				if ( $request['parent'] ) {
160
-					$prepared_args['parent'] = $request['parent'];
159
+				if ( $request[ 'parent' ] ) {
160
+					$prepared_args[ 'parent' ] = $request[ 'parent' ];
161 161
 				}
162 162
 			}
163 163
 		}
@@ -176,20 +176,20 @@  discard block
 block discarded – undo
176 176
 		 */
177 177
 		$prepared_args = apply_filters( "woocommerce_rest_{$taxonomy}_query", $prepared_args, $request );
178 178
 
179
-		if ( ! empty( $prepared_args['product'] ) ) {
179
+		if ( ! empty( $prepared_args[ 'product' ] ) ) {
180 180
 			$query_result = $this->get_terms_for_product( $prepared_args, $request );
181 181
 			$total_terms  = $this->total_terms;
182 182
 		} else {
183 183
 			$query_result = get_terms( $taxonomy, $prepared_args );
184 184
 
185 185
 			$count_args = $prepared_args;
186
-			unset( $count_args['number'] );
187
-			unset( $count_args['offset'] );
186
+			unset( $count_args[ 'number' ] );
187
+			unset( $count_args[ 'offset' ] );
188 188
 			$total_terms = wp_count_terms( $taxonomy, $count_args );
189 189
 
190 190
 			// Ensure we don't return results when offset is out of bounds.
191 191
 			// See https://core.trac.wordpress.org/ticket/35935.
192
-			if ( $prepared_args['offset'] && $prepared_args['offset'] >= $total_terms ) {
192
+			if ( $prepared_args[ 'offset' ] && $prepared_args[ 'offset' ] >= $total_terms ) {
193 193
 				$query_result = array();
194 194
 			}
195 195
 
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 		$response = array();
202 202
 		foreach ( $query_result as $term ) {
203 203
 			$data       = $this->prepare_item_for_response( $term, $request );
204
-			$response[] = $this->prepare_response_for_collection( $data );
204
+			$response[ ] = $this->prepare_response_for_collection( $data );
205 205
 		}
206 206
 
207 207
 		// Store pagination values for headers then unset for count query.
208
-		$per_page  = (int) $prepared_args['number'];
208
+		$per_page  = (int) $prepared_args[ 'number' ];
209 209
 		$max_pages = ceil( $total_terms / $per_page );
210 210
 
211 211
 		$response = rest_ensure_response( $response );
@@ -222,21 +222,21 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	public function create_item( $request ) {
224 224
 		$taxonomy = $this->get_taxonomy( $request );
225
-		$name     = $request['name'];
225
+		$name     = $request[ 'name' ];
226 226
 		$args     = array();
227 227
 		$schema   = $this->get_item_schema();
228 228
 
229
-		if ( ! empty( $schema['properties']['description'] ) && isset( $request['description'] ) ) {
230
-			$args['description'] = $request['description'];
229
+		if ( ! empty( $schema[ 'properties' ][ 'description' ] ) && isset( $request[ 'description' ] ) ) {
230
+			$args[ 'description' ] = $request[ 'description' ];
231 231
 		}
232
-		if ( isset( $request['slug'] ) ) {
233
-			$args['slug'] = $request['slug'];
232
+		if ( isset( $request[ 'slug' ] ) ) {
233
+			$args[ 'slug' ] = $request[ 'slug' ];
234 234
 		}
235
-		if ( isset( $request['parent'] ) ) {
235
+		if ( isset( $request[ 'parent' ] ) ) {
236 236
 			if ( ! is_taxonomy_hierarchical( $taxonomy ) ) {
237 237
 				return new \WP_Error( 'woocommerce_rest_taxonomy_not_hierarchical', __( 'Can not set resource parent, taxonomy is not hierarchical.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
238 238
 			}
239
-			$args['parent'] = $request['parent'];
239
+			$args[ 'parent' ] = $request[ 'parent' ];
240 240
 		}
241 241
 
242 242
 		$term = wp_insert_term( $name, $taxonomy, $args );
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
 			// give them the identifier they can actually use.
248 248
 			$term_id = $term->get_error_data( 'term_exists' );
249 249
 			if ( $term_id ) {
250
-				$error_data['resource_id'] = $term_id;
250
+				$error_data[ 'resource_id' ] = $term_id;
251 251
 			}
252 252
 
253 253
 			return new \WP_Error( $term->get_error_code(), $term->get_error_message(), $error_data );
254 254
 		}
255 255
 
256
-		$term = get_term( $term['term_id'], $taxonomy );
256
+		$term = get_term( $term[ 'term_id' ], $taxonomy );
257 257
 
258 258
 		$this->update_additional_fields_for_object( $term, $request );
259 259
 
@@ -280,8 +280,8 @@  discard block
 block discarded – undo
280 280
 		$response->set_status( 201 );
281 281
 
282 282
 		$base = '/' . $this->namespace . '/' . $this->rest_base;
283
-		if ( ! empty( $request['attribute_id'] ) ) {
284
-			$base = str_replace( '(?P<attribute_id>[\d]+)', (int) $request['attribute_id'], $base );
283
+		if ( ! empty( $request[ 'attribute_id' ] ) ) {
284
+			$base = str_replace( '(?P<attribute_id>[\d]+)', (int) $request[ 'attribute_id' ], $base );
285 285
 		}
286 286
 
287 287
 		$response->header( 'Location', rest_url( $base . '/' . $term->term_id ) );
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	public function get_item( $request ) {
299 299
 		$taxonomy = $this->get_taxonomy( $request );
300
-		$term     = get_term( (int) $request['id'], $taxonomy );
300
+		$term     = get_term( (int) $request[ 'id' ], $taxonomy );
301 301
 
302 302
 		if ( is_wp_error( $term ) ) {
303 303
 			return $term;
@@ -316,24 +316,24 @@  discard block
 block discarded – undo
316 316
 	 */
317 317
 	public function update_item( $request ) {
318 318
 		$taxonomy      = $this->get_taxonomy( $request );
319
-		$term          = get_term( (int) $request['id'], $taxonomy );
319
+		$term          = get_term( (int) $request[ 'id' ], $taxonomy );
320 320
 		$schema        = $this->get_item_schema();
321 321
 		$prepared_args = array();
322 322
 
323
-		if ( isset( $request['name'] ) ) {
324
-			$prepared_args['name'] = $request['name'];
323
+		if ( isset( $request[ 'name' ] ) ) {
324
+			$prepared_args[ 'name' ] = $request[ 'name' ];
325 325
 		}
326
-		if ( ! empty( $schema['properties']['description'] ) && isset( $request['description'] ) ) {
327
-			$prepared_args['description'] = $request['description'];
326
+		if ( ! empty( $schema[ 'properties' ][ 'description' ] ) && isset( $request[ 'description' ] ) ) {
327
+			$prepared_args[ 'description' ] = $request[ 'description' ];
328 328
 		}
329
-		if ( isset( $request['slug'] ) ) {
330
-			$prepared_args['slug'] = $request['slug'];
329
+		if ( isset( $request[ 'slug' ] ) ) {
330
+			$prepared_args[ 'slug' ] = $request[ 'slug' ];
331 331
 		}
332
-		if ( isset( $request['parent'] ) ) {
332
+		if ( isset( $request[ 'parent' ] ) ) {
333 333
 			if ( ! is_taxonomy_hierarchical( $taxonomy ) ) {
334 334
 				return new \WP_Error( 'woocommerce_rest_taxonomy_not_hierarchical', __( 'Can not set resource parent, taxonomy is not hierarchical.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
335 335
 			}
336
-			$prepared_args['parent'] = $request['parent'];
336
+			$prepared_args[ 'parent' ] = $request[ 'parent' ];
337 337
 		}
338 338
 
339 339
 		// Only update the term if we haz something to update.
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 			}
345 345
 		}
346 346
 
347
-		$term = get_term( (int) $request['id'], $taxonomy );
347
+		$term = get_term( (int) $request[ 'id' ], $taxonomy );
348 348
 
349 349
 		$this->update_additional_fields_for_object( $term, $request );
350 350
 
@@ -376,19 +376,19 @@  discard block
 block discarded – undo
376 376
 	 */
377 377
 	public function delete_item( $request ) {
378 378
 		$taxonomy = $this->get_taxonomy( $request );
379
-		$force    = isset( $request['force'] ) ? (bool) $request['force'] : false;
379
+		$force    = isset( $request[ 'force' ] ) ? (bool) $request[ 'force' ] : false;
380 380
 
381 381
 		// We don't support trashing for this type, error out.
382 382
 		if ( ! $force ) {
383 383
 			return new \WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Resource does not support trashing.', 'woocommerce-rest-api' ), array( 'status' => 501 ) );
384 384
 		}
385 385
 
386
-		$term = get_term( (int) $request['id'], $taxonomy );
386
+		$term = get_term( (int) $request[ 'id' ], $taxonomy );
387 387
 		// Get default category id.
388 388
 		$default_category_id = absint( get_option( 'default_product_cat', 0 ) );
389 389
 
390 390
 		// Prevent deleting the default product category.
391
-		if ( $default_category_id === (int) $request['id'] ) {
391
+		if ( $default_category_id === (int) $request[ 'id' ] ) {
392 392
 			return new \WP_Error( 'woocommerce_rest_cannot_delete', __( 'Default product category cannot be deleted.', 'woocommerce-rest-api' ), array( 'status' => 500 ) );
393 393
 		}
394 394
 
@@ -422,8 +422,8 @@  discard block
 block discarded – undo
422 422
 	protected function prepare_links( $item, $request ) {
423 423
 		$base = '/' . $this->namespace . '/' . $this->rest_base;
424 424
 
425
-		if ( ! empty( $request['attribute_id'] ) ) {
426
-			$base = str_replace( '(?P<attribute_id>[\d]+)', (int) $request['attribute_id'], $base );
425
+		if ( ! empty( $request[ 'attribute_id' ] ) ) {
426
+			$base = str_replace( '(?P<attribute_id>[\d]+)', (int) $request[ 'attribute_id' ], $base );
427 427
 		}
428 428
 
429 429
 		$links = array(
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 		if ( $item->parent ) {
439 439
 			$parent_term = get_term( (int) $item->parent, $item->taxonomy );
440 440
 			if ( $parent_term ) {
441
-				$links['up'] = array(
441
+				$links[ 'up' ] = array(
442 442
 					'href' => rest_url( trailingslashit( $base ) . $parent_term->term_id ),
443 443
 				);
444 444
 			}
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 	protected function get_terms_for_product( $prepared_args, $request ) {
474 474
 		$taxonomy = $this->get_taxonomy( $request );
475 475
 
476
-		$query_result = get_the_terms( $prepared_args['product'], $taxonomy );
476
+		$query_result = get_the_terms( $prepared_args[ 'product' ], $taxonomy );
477 477
 		if ( empty( $query_result ) ) {
478 478
 			$this->total_terms = 0;
479 479
 			return array();
@@ -481,8 +481,8 @@  discard block
 block discarded – undo
481 481
 
482 482
 		// get_items() verifies that we don't have `include` set, and default.
483 483
 		// ordering is by `name`.
484
-		if ( ! in_array( $prepared_args['orderby'], array( 'name', 'none', 'include' ), true ) ) {
485
-			switch ( $prepared_args['orderby'] ) {
484
+		if ( ! in_array( $prepared_args[ 'orderby' ], array( 'name', 'none', 'include' ), true ) ) {
485
+			switch ( $prepared_args[ 'orderby' ] ) {
486 486
 				case 'id':
487 487
 					$this->sort_column = 'term_id';
488 488
 					break;
@@ -490,18 +490,18 @@  discard block
 block discarded – undo
490 490
 				case 'term_group':
491 491
 				case 'description':
492 492
 				case 'count':
493
-					$this->sort_column = $prepared_args['orderby'];
493
+					$this->sort_column = $prepared_args[ 'orderby' ];
494 494
 					break;
495 495
 			}
496 496
 			usort( $query_result, array( $this, 'compare_terms' ) );
497 497
 		}
498
-		if ( strtolower( $prepared_args['order'] ) !== 'asc' ) {
498
+		if ( strtolower( $prepared_args[ 'order' ] ) !== 'asc' ) {
499 499
 			$query_result = array_reverse( $query_result );
500 500
 		}
501 501
 
502 502
 		// Pagination.
503 503
 		$this->total_terms = count( $query_result );
504
-		$query_result      = array_slice( $query_result, $prepared_args['offset'], $prepared_args['number'] );
504
+		$query_result      = array_slice( $query_result, $prepared_args[ 'offset' ], $prepared_args[ 'number' ] );
505 505
 
506 506
 		return $query_result;
507 507
 	}
@@ -542,9 +542,9 @@  discard block
 block discarded – undo
542 542
 			$taxonomy->hierarchical = true;
543 543
 		}
544 544
 
545
-		$params['context']['default'] = 'view';
545
+		$params[ 'context' ][ 'default' ] = 'view';
546 546
 
547
-		$params['exclude'] = array(
547
+		$params[ 'exclude' ] = array(
548 548
 			'description'       => __( 'Ensure result set excludes specific IDs.', 'woocommerce-rest-api' ),
549 549
 			'type'              => 'array',
550 550
 			'items'             => array(
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 			'default'           => array(),
554 554
 			'sanitize_callback' => 'wp_parse_id_list',
555 555
 		);
556
-		$params['include'] = array(
556
+		$params[ 'include' ] = array(
557 557
 			'description'       => __( 'Limit result set to specific ids.', 'woocommerce-rest-api' ),
558 558
 			'type'              => 'array',
559 559
 			'items'             => array(
@@ -563,14 +563,14 @@  discard block
 block discarded – undo
563 563
 			'sanitize_callback' => 'wp_parse_id_list',
564 564
 		);
565 565
 		if ( ! $taxonomy->hierarchical ) {
566
-			$params['offset'] = array(
566
+			$params[ 'offset' ] = array(
567 567
 				'description'       => __( 'Offset the result set by a specific number of items.', 'woocommerce-rest-api' ),
568 568
 				'type'              => 'integer',
569 569
 				'sanitize_callback' => 'absint',
570 570
 				'validate_callback' => 'rest_validate_request_arg',
571 571
 			);
572 572
 		}
573
-		$params['order']      = array(
573
+		$params[ 'order' ] = array(
574 574
 			'description'       => __( 'Order sort attribute ascending or descending.', 'woocommerce-rest-api' ),
575 575
 			'type'              => 'string',
576 576
 			'sanitize_callback' => 'sanitize_key',
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 			),
582 582
 			'validate_callback' => 'rest_validate_request_arg',
583 583
 		);
584
-		$params['orderby']    = array(
584
+		$params[ 'orderby' ] = array(
585 585
 			'description'       => __( 'Sort collection by resource attribute.', 'woocommerce-rest-api' ),
586 586
 			'type'              => 'string',
587 587
 			'sanitize_callback' => 'sanitize_key',
@@ -597,27 +597,27 @@  discard block
 block discarded – undo
597 597
 			),
598 598
 			'validate_callback' => 'rest_validate_request_arg',
599 599
 		);
600
-		$params['hide_empty'] = array(
600
+		$params[ 'hide_empty' ] = array(
601 601
 			'description'       => __( 'Whether to hide resources not assigned to any products.', 'woocommerce-rest-api' ),
602 602
 			'type'              => 'boolean',
603 603
 			'default'           => false,
604 604
 			'validate_callback' => 'rest_validate_request_arg',
605 605
 		);
606 606
 		if ( $taxonomy->hierarchical ) {
607
-			$params['parent'] = array(
607
+			$params[ 'parent' ] = array(
608 608
 				'description'       => __( 'Limit result set to resources assigned to a specific parent.', 'woocommerce-rest-api' ),
609 609
 				'type'              => 'integer',
610 610
 				'sanitize_callback' => 'absint',
611 611
 				'validate_callback' => 'rest_validate_request_arg',
612 612
 			);
613 613
 		}
614
-		$params['product'] = array(
614
+		$params[ 'product' ] = array(
615 615
 			'description'       => __( 'Limit result set to resources assigned to a specific product.', 'woocommerce-rest-api' ),
616 616
 			'type'              => 'integer',
617 617
 			'default'           => null,
618 618
 			'validate_callback' => 'rest_validate_request_arg',
619 619
 		);
620
-		$params['slug']    = array(
620
+		$params[ 'slug' ] = array(
621 621
 			'description'       => __( 'Limit result set to resources with a specific slug.', 'woocommerce-rest-api' ),
622 622
 			'type'              => 'string',
623 623
 			'validate_callback' => 'rest_validate_request_arg',
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
 			return $this->taxonomy;
640 640
 		}
641 641
 
642
-		if ( ! empty( $request['attribute_id'] ) ) {
643
-			$taxonomy = wc_attribute_taxonomy_name_by_id( (int) $request['attribute_id'] );
642
+		if ( ! empty( $request[ 'attribute_id' ] ) ) {
643
+			$taxonomy = wc_attribute_taxonomy_name_by_id( (int) $request[ 'attribute_id' ] );
644 644
 
645 645
 			$this->taxonomy = $taxonomy;
646 646
 		}
Please login to merge, or discard this patch.
src/Controllers/Version4/Webhooks.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	public function get_items( $request ) {
142 142
 		$args            = array();
143
-		$args['order']   = $request['order'];
144
-		$args['orderby'] = $request['orderby'];
145
-		$args['status']  = 'all' === $request['status'] ? '' : $request['status'];
146
-		$args['include'] = implode( ',', $request['include'] );
147
-		$args['exclude'] = implode( ',', $request['exclude'] );
148
-		$args['limit']   = $request['per_page'];
149
-		$args['search']  = $request['search'];
150
-		$args['before']  = $request['before'];
151
-		$args['after']   = $request['after'];
152
-
153
-		if ( empty( $request['offset'] ) ) {
154
-			$args['offset'] = 1 < $request['page'] ? ( $request['page'] - 1 ) * $args['limit'] : 0;
143
+		$args[ 'order' ]   = $request[ 'order' ];
144
+		$args[ 'orderby' ] = $request[ 'orderby' ];
145
+		$args[ 'status' ]  = 'all' === $request[ 'status' ] ? '' : $request[ 'status' ];
146
+		$args[ 'include' ] = implode( ',', $request[ 'include' ] );
147
+		$args[ 'exclude' ] = implode( ',', $request[ 'exclude' ] );
148
+		$args[ 'limit' ]   = $request[ 'per_page' ];
149
+		$args[ 'search' ]  = $request[ 'search' ];
150
+		$args[ 'before' ]  = $request[ 'before' ];
151
+		$args[ 'after' ]   = $request[ 'after' ];
152
+
153
+		if ( empty( $request[ 'offset' ] ) ) {
154
+			$args[ 'offset' ] = 1 < $request[ 'page' ] ? ( $request[ 'page' ] - 1 ) * $args[ 'limit' ] : 0;
155 155
 		}
156 156
 
157 157
 		/**
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 		 * @param \WP_REST_Request $request The current request.
162 162
 		 */
163 163
 		$prepared_args = apply_filters( 'woocommerce_rest_webhook_query', $args, $request );
164
-		unset( $prepared_args['page'] );
165
-		$prepared_args['paginate'] = true;
164
+		unset( $prepared_args[ 'page' ] );
165
+		$prepared_args[ 'paginate' ] = true;
166 166
 
167 167
 		// Get the webhooks.
168 168
 		$webhooks    = array();
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 			}
179 179
 
180 180
 			$data       = $this->prepare_item_for_response( $object, $request );
181
-			$webhooks[] = $this->prepare_response_for_collection( $data );
181
+			$webhooks[ ] = $this->prepare_response_for_collection( $data );
182 182
 		}
183 183
 
184 184
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	 * @return \WP_Error|\WP_REST_Response
214 214
 	 */
215 215
 	public function get_item( $request ) {
216
-		$object = $this->get_object( (int) $request['id'] );
216
+		$object = $this->get_object( (int) $request[ 'id' ] );
217 217
 
218 218
 		if ( ! $object || 0 === $object->get_id() ) {
219 219
 			return new \WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce-rest-api' ), array( 'status' => 404 ) );
@@ -229,18 +229,18 @@  discard block
 block discarded – undo
229 229
 	 * @return \WP_Error|\WP_REST_Response
230 230
 	 */
231 231
 	public function create_item( $request ) {
232
-		if ( ! empty( $request['id'] ) ) {
232
+		if ( ! empty( $request[ 'id' ] ) ) {
233 233
 			/* translators: %s: post type */
234 234
 			return new \WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce-rest-api' ), $this->post_type ), array( 'status' => 400 ) );
235 235
 		}
236 236
 
237 237
 		// Validate topic.
238
-		if ( empty( $request['topic'] ) || ! wc_is_webhook_valid_topic( strtolower( $request['topic'] ) ) ) {
238
+		if ( empty( $request[ 'topic' ] ) || ! wc_is_webhook_valid_topic( strtolower( $request[ 'topic' ] ) ) ) {
239 239
 			return new \WP_Error( "woocommerce_rest_{$this->post_type}_invalid_topic", __( 'Webhook topic is required and must be valid.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
240 240
 		}
241 241
 
242 242
 		// Validate delivery URL.
243
-		if ( empty( $request['delivery_url'] ) || ! wc_is_valid_url( $request['delivery_url'] ) ) {
243
+		if ( empty( $request[ 'delivery_url' ] ) || ! wc_is_valid_url( $request[ 'delivery_url' ] ) ) {
244 244
 			return new \WP_Error( "woocommerce_rest_{$this->post_type}_invalid_delivery_url", __( 'Webhook delivery URL must be a valid URL starting with http:// or https://.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
245 245
 		}
246 246
 
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 		$webhook->set_name( $post->post_title );
254 254
 		$webhook->set_user_id( $post->post_author );
255 255
 		$webhook->set_status( 'publish' === $post->post_status ? 'active' : 'disabled' );
256
-		$webhook->set_topic( $request['topic'] );
257
-		$webhook->set_delivery_url( $request['delivery_url'] );
258
-		$webhook->set_secret( ! empty( $request['secret'] ) ? $request['secret'] : wp_generate_password( 50, true, true ) );
256
+		$webhook->set_topic( $request[ 'topic' ] );
257
+		$webhook->set_delivery_url( $request[ 'delivery_url' ] );
258
+		$webhook->set_secret( ! empty( $request[ 'secret' ] ) ? $request[ 'secret' ] : wp_generate_password( 50, true, true ) );
259 259
 		$webhook->set_api_version( $this->get_default_api_version() );
260 260
 		$webhook->save();
261 261
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 * @return \WP_Error|\WP_REST_Response
290 290
 	 */
291 291
 	public function update_item( $request ) {
292
-		$id      = (int) $request['id'];
292
+		$id      = (int) $request[ 'id' ];
293 293
 		$webhook = wc_get_webhook( $id );
294 294
 
295 295
 		if ( empty( $webhook ) || is_null( $webhook ) ) {
@@ -297,32 +297,32 @@  discard block
 block discarded – undo
297 297
 		}
298 298
 
299 299
 		// Update topic.
300
-		if ( ! empty( $request['topic'] ) ) {
301
-			if ( wc_is_webhook_valid_topic( strtolower( $request['topic'] ) ) ) {
302
-				$webhook->set_topic( $request['topic'] );
300
+		if ( ! empty( $request[ 'topic' ] ) ) {
301
+			if ( wc_is_webhook_valid_topic( strtolower( $request[ 'topic' ] ) ) ) {
302
+				$webhook->set_topic( $request[ 'topic' ] );
303 303
 			} else {
304 304
 				return new \WP_Error( "woocommerce_rest_{$this->post_type}_invalid_topic", __( 'Webhook topic must be valid.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
305 305
 			}
306 306
 		}
307 307
 
308 308
 		// Update delivery URL.
309
-		if ( ! empty( $request['delivery_url'] ) ) {
310
-			if ( wc_is_valid_url( $request['delivery_url'] ) ) {
311
-				$webhook->set_delivery_url( $request['delivery_url'] );
309
+		if ( ! empty( $request[ 'delivery_url' ] ) ) {
310
+			if ( wc_is_valid_url( $request[ 'delivery_url' ] ) ) {
311
+				$webhook->set_delivery_url( $request[ 'delivery_url' ] );
312 312
 			} else {
313 313
 				return new \WP_Error( "woocommerce_rest_{$this->post_type}_invalid_delivery_url", __( 'Webhook delivery URL must be a valid URL starting with http:// or https://.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
314 314
 			}
315 315
 		}
316 316
 
317 317
 		// Update secret.
318
-		if ( ! empty( $request['secret'] ) ) {
319
-			$webhook->set_secret( $request['secret'] );
318
+		if ( ! empty( $request[ 'secret' ] ) ) {
319
+			$webhook->set_secret( $request[ 'secret' ] );
320 320
 		}
321 321
 
322 322
 		// Update status.
323
-		if ( ! empty( $request['status'] ) ) {
324
-			if ( wc_is_webhook_valid_status( strtolower( $request['status'] ) ) ) {
325
-				$webhook->set_status( $request['status'] );
323
+		if ( ! empty( $request[ 'status' ] ) ) {
324
+			if ( wc_is_webhook_valid_status( strtolower( $request[ 'status' ] ) ) ) {
325
+				$webhook->set_status( $request[ 'status' ] );
326 326
 			} else {
327 327
 				return new \WP_Error( "woocommerce_rest_{$this->post_type}_invalid_status", __( 'Webhook status must be valid.', 'woocommerce-rest-api' ), array( 'status' => 400 ) );
328 328
 			}
@@ -363,8 +363,8 @@  discard block
 block discarded – undo
363 363
 	 * @return \WP_REST_Response|\WP_Error
364 364
 	 */
365 365
 	public function delete_item( $request ) {
366
-		$id    = (int) $request['id'];
367
-		$force = isset( $request['force'] ) ? (bool) $request['force'] : false;
366
+		$id    = (int) $request[ 'id' ];
367
+		$force = isset( $request[ 'force' ] ) ? (bool) $request[ 'force' ] : false;
368 368
 
369 369
 		// We don't support trashing for this type, error out.
370 370
 		if ( ! $force ) {
@@ -414,13 +414,13 @@  discard block
 block discarded – undo
414 414
 		$data = new \stdClass();
415 415
 
416 416
 		// Post ID.
417
-		if ( isset( $request['id'] ) ) {
418
-			$data->ID = absint( $request['id'] );
417
+		if ( isset( $request[ 'id' ] ) ) {
418
+			$data->ID = absint( $request[ 'id' ] );
419 419
 		}
420 420
 
421 421
 		// Validate required POST fields.
422 422
 		if ( 'POST' === $request->get_method() && empty( $data->ID ) ) {
423
-			$data->post_title = ! empty( $request['name'] ) ? $request['name'] : sprintf( __( 'Webhook created on %s', 'woocommerce-rest-api' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Webhook created on date parsed by strftime', 'woocommerce-rest-api' ) ) ); // @codingStandardsIgnoreLine
423
+			$data->post_title = ! empty( $request[ 'name' ] ) ? $request[ 'name' ] : sprintf( __( 'Webhook created on %s', 'woocommerce-rest-api' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Webhook created on date parsed by strftime', 'woocommerce-rest-api' ) ) ); // @codingStandardsIgnoreLine
424 424
 
425 425
 			// Post author.
426 426
 			$data->post_author = get_current_user_id();
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 		} else {
434 434
 
435 435
 			// Allow edit post title.
436
-			if ( ! empty( $request['name'] ) ) {
437
-				$data->post_title = $request['name'];
436
+			if ( ! empty( $request[ 'name' ] ) ) {
437
+				$data->post_title = $request[ 'name' ];
438 438
 			}
439 439
 		}
440 440
 
@@ -606,21 +606,21 @@  discard block
 block discarded – undo
606 606
 	public function get_collection_params() {
607 607
 		$params = parent::get_collection_params();
608 608
 
609
-		$params['context']['default'] = 'view';
609
+		$params[ 'context' ][ 'default' ] = 'view';
610 610
 
611
-		$params['after']   = array(
611
+		$params[ 'after' ] = array(
612 612
 			'description'       => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce-rest-api' ),
613 613
 			'type'              => 'string',
614 614
 			'format'            => 'date-time',
615 615
 			'validate_callback' => 'rest_validate_request_arg',
616 616
 		);
617
-		$params['before']  = array(
617
+		$params[ 'before' ] = array(
618 618
 			'description'       => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce-rest-api' ),
619 619
 			'type'              => 'string',
620 620
 			'format'            => 'date-time',
621 621
 			'validate_callback' => 'rest_validate_request_arg',
622 622
 		);
623
-		$params['exclude'] = array(
623
+		$params[ 'exclude' ] = array(
624 624
 			'description'       => __( 'Ensure result set excludes specific IDs.', 'woocommerce-rest-api' ),
625 625
 			'type'              => 'array',
626 626
 			'items'             => array(
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 			'default'           => array(),
630 630
 			'sanitize_callback' => 'wp_parse_id_list',
631 631
 		);
632
-		$params['include'] = array(
632
+		$params[ 'include' ] = array(
633 633
 			'description'       => __( 'Limit result set to specific ids.', 'woocommerce-rest-api' ),
634 634
 			'type'              => 'array',
635 635
 			'items'             => array(
@@ -638,20 +638,20 @@  discard block
 block discarded – undo
638 638
 			'default'           => array(),
639 639
 			'sanitize_callback' => 'wp_parse_id_list',
640 640
 		);
641
-		$params['offset']  = array(
641
+		$params[ 'offset' ] = array(
642 642
 			'description'       => __( 'Offset the result set by a specific number of items.', 'woocommerce-rest-api' ),
643 643
 			'type'              => 'integer',
644 644
 			'sanitize_callback' => 'absint',
645 645
 			'validate_callback' => 'rest_validate_request_arg',
646 646
 		);
647
-		$params['order']   = array(
647
+		$params[ 'order' ] = array(
648 648
 			'description'       => __( 'Order sort attribute ascending or descending.', 'woocommerce-rest-api' ),
649 649
 			'type'              => 'string',
650 650
 			'default'           => 'desc',
651 651
 			'enum'              => array( 'asc', 'desc' ),
652 652
 			'validate_callback' => 'rest_validate_request_arg',
653 653
 		);
654
-		$params['orderby'] = array(
654
+		$params[ 'orderby' ] = array(
655 655
 			'description'       => __( 'Sort collection by object attribute.', 'woocommerce-rest-api' ),
656 656
 			'type'              => 'string',
657 657
 			'default'           => 'date',
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 			),
663 663
 			'validate_callback' => 'rest_validate_request_arg',
664 664
 		);
665
-		$params['status']  = array(
665
+		$params[ 'status' ] = array(
666 666
 			'default'           => 'all',
667 667
 			'description'       => __( 'Limit result set to webhooks assigned a specific status.', 'woocommerce-rest-api' ),
668 668
 			'type'              => 'string',
Please login to merge, or discard this patch.