Test Failed
Push — master ( 7495fa...2c1094 )
by Mike
46:10
created
woocommerce-rest-api.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
  * @package WooCommerce/RestApi
13 13
  */
14 14
 
15
-defined( 'ABSPATH' ) || exit;
15
+defined('ABSPATH') || exit;
16 16
 
17
-if ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) {
17
+if (version_compare(PHP_VERSION, '5.6.0', '<')) {
18 18
 	return;
19 19
 }
20 20
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 /**
28 28
  * This callback registers this version of the API with WooCommerce.
29 29
  */
30
-$register_callback = function() use ( $version, $init_callback ) {
31
-	if ( ! is_callable( array( wc()->api, 'register' ) ) ) {
30
+$register_callback = function() use ($version, $init_callback) {
31
+	if ( ! is_callable(array(wc()->api, 'register'))) {
32 32
 		return;
33 33
 	}
34
-	wc()->api->register( $version, $init_callback );
34
+	wc()->api->register($version, $init_callback);
35 35
 };
36 36
 
37
-add_action( 'woocommerce_loaded', $register_callback );
37
+add_action('woocommerce_loaded', $register_callback);
Please login to merge, or discard this patch.
src/Utilities/SingletonTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 * @return object Instance.
34 34
 	 */
35 35
 	final public static function instance() {
36
-		if ( null === static::$instance ) {
36
+		if (null === static::$instance) {
37 37
 			static::$instance = new static();
38 38
 		}
39 39
 		return static::$instance;
Please login to merge, or discard this patch.
src/Server.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
 
8 8
 namespace WooCommerce\RestApi;
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-if ( file_exists( __DIR__ . '/../vendor/autoload.php' ) ) {
12
+if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
13 13
 	require __DIR__ . '/../vendor/autoload.php';
14 14
 } else {
15 15
 	return;
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 34
 	 * Hook into WordPress ready to init the REST API as needed.
35 35
 	 */
36 36
 	public function init() {
37
-		add_action( 'rest_api_init', array( $this, 'register_rest_routes' ), 10 );
37
+		add_action('rest_api_init', array($this, 'register_rest_routes'), 10);
38 38
 	}
39 39
 
40 40
 	/**
41 41
 	 * Register REST API routes.
42 42
 	 */
43 43
 	public function register_rest_routes() {
44
-		foreach ( $this->get_rest_namespaces() as $namespace => $controllers ) {
45
-			foreach ( $controllers as $controller_name => $controller_class ) {
46
-				$this->controllers[ $namespace ][ $controller_name ] = new $controller_class();
47
-				$this->controllers[ $namespace ][ $controller_name ]->register_routes();
44
+		foreach ($this->get_rest_namespaces() as $namespace => $controllers) {
45
+			foreach ($controllers as $controller_name => $controller_class) {
46
+				$this->controllers[$namespace][$controller_name] = new $controller_class();
47
+				$this->controllers[$namespace][$controller_name]->register_routes();
48 48
 			}
49 49
 		}
50 50
 	}
Please login to merge, or discard this patch.
src/Controllers/Version3/class-wc-rest-order-refunds-controller.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   2.6.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Order Refunds controller class.
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 	 * @param  bool            $creating If is creating a new object.
34 34
 	 * @return WP_Error|WC_Data The prepared item, or WP_Error object on failure.
35 35
 	 */
36
-	protected function prepare_object_for_database( $request, $creating = false ) {
37
-		$order = wc_get_order( (int) $request['order_id'] );
36
+	protected function prepare_object_for_database($request, $creating = false) {
37
+		$order = wc_get_order((int) $request['order_id']);
38 38
 
39
-		if ( ! $order ) {
40
-			return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce' ), 404 );
39
+		if ( ! $order) {
40
+			return new WP_Error('woocommerce_rest_invalid_order_id', __('Invalid order ID.', 'woocommerce'), 404);
41 41
 		}
42 42
 
43
-		if ( 0 > $request['amount'] ) {
44
-			return new WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce' ), 400 );
43
+		if (0 > $request['amount']) {
44
+			return new WP_Error('woocommerce_rest_invalid_order_refund', __('Refund amount must be greater than zero.', 'woocommerce'), 400);
45 45
 		}
46 46
 
47 47
 		// Create the refund.
@@ -49,24 +49,24 @@  discard block
 block discarded – undo
49 49
 			array(
50 50
 				'order_id'       => $order->get_id(),
51 51
 				'amount'         => $request['amount'],
52
-				'reason'         => empty( $request['reason'] ) ? null : $request['reason'],
53
-				'line_items'     => empty( $request['line_items'] ) ? array() : $request['line_items'],
54
-				'refund_payment' => is_bool( $request['api_refund'] ) ? $request['api_refund'] : true,
52
+				'reason'         => empty($request['reason']) ? null : $request['reason'],
53
+				'line_items'     => empty($request['line_items']) ? array() : $request['line_items'],
54
+				'refund_payment' => is_bool($request['api_refund']) ? $request['api_refund'] : true,
55 55
 				'restock_items'  => true,
56 56
 			)
57 57
 		);
58 58
 
59
-		if ( is_wp_error( $refund ) ) {
60
-			return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', $refund->get_error_message(), 500 );
59
+		if (is_wp_error($refund)) {
60
+			return new WP_Error('woocommerce_rest_cannot_create_order_refund', $refund->get_error_message(), 500);
61 61
 		}
62 62
 
63
-		if ( ! $refund ) {
64
-			return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce' ), 500 );
63
+		if ( ! $refund) {
64
+			return new WP_Error('woocommerce_rest_cannot_create_order_refund', __('Cannot create order refund, please try again.', 'woocommerce'), 500);
65 65
 		}
66 66
 
67
-		if ( ! empty( $request['meta_data'] ) && is_array( $request['meta_data'] ) ) {
68
-			foreach ( $request['meta_data'] as $meta ) {
69
-				$refund->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' );
67
+		if ( ! empty($request['meta_data']) && is_array($request['meta_data'])) {
68
+			foreach ($request['meta_data'] as $meta) {
69
+				$refund->update_meta_data($meta['key'], $meta['value'], isset($meta['id']) ? $meta['id'] : '');
70 70
 			}
71 71
 			$refund->save_meta_data();
72 72
 		}
@@ -81,6 +81,6 @@  discard block
 block discarded – undo
81 81
 		 * @param WP_REST_Request $request  Request object.
82 82
 		 * @param bool            $creating If is creating a new object.
83 83
 		 */
84
-		return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $refund, $request, $creating );
84
+		return apply_filters("woocommerce_rest_pre_insert_{$this->post_type}_object", $refund, $request, $creating);
85 85
 	}
86 86
 }
Please login to merge, or discard this patch.
Controllers/Version3/class-wc-rest-product-shipping-classes-controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  * @since   2.6.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Product Shipping Classes controller class.
Please login to merge, or discard this patch.
src/Controllers/Version3/class-wc-rest-settings-controller.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   3.0.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Settings controller class.
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	public function register_routes() {
32 32
 		parent::register_routes();
33
-		register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array(
33
+		register_rest_route($this->namespace, '/' . $this->rest_base . '/batch', array(
34 34
 			array(
35 35
 				'methods'             => WP_REST_Server::EDITABLE,
36
-				'callback'            => array( $this, 'batch_items' ),
37
-				'permission_callback' => array( $this, 'update_items_permissions_check' ),
36
+				'callback'            => array($this, 'batch_items'),
37
+				'permission_callback' => array($this, 'update_items_permissions_check'),
38 38
 			),
39
-			'schema' => array( $this, 'get_public_batch_schema' ),
40
-		) );
39
+			'schema' => array($this, 'get_public_batch_schema'),
40
+		));
41 41
 	}
42 42
 
43 43
 	/**
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
 	 * @param WP_REST_Request $request Full data about the request.
47 47
 	 * @return WP_Error|bool
48 48
 	 */
49
-	public function update_items_permissions_check( $request ) {
50
-		if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
51
-			return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
49
+	public function update_items_permissions_check($request) {
50
+		if ( ! wc_rest_check_manager_permissions('settings', 'edit')) {
51
+			return new WP_Error('woocommerce_rest_cannot_edit', __('Sorry, you cannot edit this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
52 52
 		}
53 53
 
54 54
 		return true;
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 	 * @param  WP_REST_Request $request Request data.
61 61
 	 * @return WP_Error|WP_REST_Response
62 62
 	 */
63
-	public function update_item( $request ) {
63
+	public function update_item($request) {
64 64
 		$options_controller = new WC_REST_Setting_Options_Controller();
65
-		$response           = $options_controller->update_item( $request );
65
+		$response           = $options_controller->update_item($request);
66 66
 
67 67
 		return $response;
68 68
 	}
@@ -80,33 +80,33 @@  discard block
 block discarded – undo
80 80
 			'type'       => 'object',
81 81
 			'properties' => array(
82 82
 				'id'          => array(
83
-					'description' => __( 'A unique identifier that can be used to link settings together.', 'woocommerce' ),
83
+					'description' => __('A unique identifier that can be used to link settings together.', 'woocommerce'),
84 84
 					'type'        => 'string',
85
-					'context'     => array( 'view', 'edit' ),
85
+					'context'     => array('view', 'edit'),
86 86
 				),
87 87
 				'label'       => array(
88
-					'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ),
88
+					'description' => __('A human readable label for the setting used in interfaces.', 'woocommerce'),
89 89
 					'type'        => 'string',
90
-					'context'     => array( 'view', 'edit' ),
90
+					'context'     => array('view', 'edit'),
91 91
 				),
92 92
 				'description' => array(
93
-					'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ),
93
+					'description' => __('A human readable description for the setting used in interfaces.', 'woocommerce'),
94 94
 					'type'        => 'string',
95
-					'context'     => array( 'view', 'edit' ),
95
+					'context'     => array('view', 'edit'),
96 96
 				),
97 97
 				'parent_id'   => array(
98
-					'description' => __( 'ID of parent grouping.', 'woocommerce' ),
98
+					'description' => __('ID of parent grouping.', 'woocommerce'),
99 99
 					'type'        => 'string',
100
-					'context'     => array( 'view', 'edit' ),
100
+					'context'     => array('view', 'edit'),
101 101
 				),
102 102
 				'sub_groups'  => array(
103
-					'description' => __( 'IDs for settings sub groups.', 'woocommerce' ),
103
+					'description' => __('IDs for settings sub groups.', 'woocommerce'),
104 104
 					'type'        => 'string',
105
-					'context'     => array( 'view', 'edit' ),
105
+					'context'     => array('view', 'edit'),
106 106
 				),
107 107
 			),
108 108
 		);
109 109
 
110
-		return $this->add_additional_fields_schema( $schema );
110
+		return $this->add_additional_fields_schema($schema);
111 111
 	}
112 112
 }
Please login to merge, or discard this patch.
Controllers/Version3/class-wc-rest-shipping-zone-locations-controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  * @since   3.0.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Shipping Zone Locations class.
Please login to merge, or discard this patch.
Controllers/Version3/class-wc-rest-report-products-totals-controller.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   3.5.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Reports Products Totals controller class.
@@ -46,16 +46,16 @@  discard block
 block discarded – undo
46 46
 				'hide_empty' => false,
47 47
 			)
48 48
 		);
49
-		$data  = array();
49
+		$data = array();
50 50
 
51
-		foreach ( $terms as $product_type ) {
52
-			if ( ! isset( $types[ $product_type->name ] ) ) {
51
+		foreach ($terms as $product_type) {
52
+			if ( ! isset($types[$product_type->name])) {
53 53
 				continue;
54 54
 			}
55 55
 
56 56
 			$data[] = array(
57 57
 				'slug'  => $product_type->name,
58
-				'name'  => $types[ $product_type->name ],
58
+				'name'  => $types[$product_type->name],
59 59
 				'total' => (int) $product_type->count,
60 60
 			);
61 61
 		}
@@ -70,19 +70,19 @@  discard block
 block discarded – undo
70 70
 	 * @param  WP_REST_Request $request Request object.
71 71
 	 * @return WP_REST_Response $response Response data.
72 72
 	 */
73
-	public function prepare_item_for_response( $report, $request ) {
73
+	public function prepare_item_for_response($report, $request) {
74 74
 		$data = array(
75 75
 			'slug'  => $report->slug,
76 76
 			'name'  => $report->name,
77 77
 			'total' => $report->total,
78 78
 		);
79 79
 
80
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
81
-		$data    = $this->add_additional_fields_to_object( $data, $request );
82
-		$data    = $this->filter_response_by_context( $data, $context );
80
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
81
+		$data    = $this->add_additional_fields_to_object($data, $request);
82
+		$data    = $this->filter_response_by_context($data, $context);
83 83
 
84 84
 		// Wrap the data in a response object.
85
-		$response = rest_ensure_response( $data );
85
+		$response = rest_ensure_response($data);
86 86
 
87 87
 		/**
88 88
 		 * Filter a report returned from the API.
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		 * @param object           $report   The original report object.
94 94
 		 * @param WP_REST_Request  $request  Request used to generate the response.
95 95
 		 */
96
-		return apply_filters( 'woocommerce_rest_prepare_report_products_count', $response, $report, $request );
96
+		return apply_filters('woocommerce_rest_prepare_report_products_count', $response, $report, $request);
97 97
 	}
98 98
 
99 99
 	/**
@@ -108,26 +108,26 @@  discard block
 block discarded – undo
108 108
 			'type'       => 'object',
109 109
 			'properties' => array(
110 110
 				'slug'  => array(
111
-					'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce' ),
111
+					'description' => __('An alphanumeric identifier for the resource.', 'woocommerce'),
112 112
 					'type'        => 'string',
113
-					'context'     => array( 'view' ),
113
+					'context'     => array('view'),
114 114
 					'readonly'    => true,
115 115
 				),
116 116
 				'name'  => array(
117
-					'description' => __( 'Product type name.', 'woocommerce' ),
117
+					'description' => __('Product type name.', 'woocommerce'),
118 118
 					'type'        => 'string',
119
-					'context'     => array( 'view' ),
119
+					'context'     => array('view'),
120 120
 					'readonly'    => true,
121 121
 				),
122 122
 				'total' => array(
123
-					'description' => __( 'Amount of products.', 'woocommerce' ),
123
+					'description' => __('Amount of products.', 'woocommerce'),
124 124
 					'type'        => 'string',
125
-					'context'     => array( 'view' ),
125
+					'context'     => array('view'),
126 126
 					'readonly'    => true,
127 127
 				),
128 128
 			),
129 129
 		);
130 130
 
131
-		return $this->add_additional_fields_schema( $schema );
131
+		return $this->add_additional_fields_schema($schema);
132 132
 	}
133 133
 }
Please login to merge, or discard this patch.
src/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  * @since   3.0.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Shipping Zone Methods class.
Please login to merge, or discard this patch.