From 62d6b05b589211c019807e5a226c86bf38f3188e Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 20 Dec 2019 14:21:08 -0300 Subject: [PATCH] Fix Generic.Formatting.MultipleStatementAlignment violations This commit fixes all violations of the Generic.Formatting.MultipleStatementAlignment sniff automatically using phpcbf. --- includes/abstracts/abstract-wc-integration.php | 2 +- includes/abstracts/abstract-wc-log-handler.php | 4 ++-- includes/abstracts/abstract-wc-payment-gateway.php | 6 +++--- includes/abstracts/abstract-wc-privacy.php | 4 ++-- includes/admin/class-wc-admin-addons.php | 2 +- includes/admin/class-wc-admin-assets.php | 2 +- includes/admin/class-wc-admin-setup-wizard.php | 2 +- .../list-tables/class-wc-admin-list-table-products.php | 10 +++++----- .../admin/reports/class-wc-report-taxes-by-code.php | 8 ++++---- includes/class-wc-query.php | 4 ++-- includes/class-wc-rate-limiter.php | 2 +- includes/class-wc-shipping-zones.php | 6 +++--- includes/class-wc-tax.php | 2 +- includes/data-stores/class-wc-webhook-data-store.php | 2 +- includes/theme-support/class-wc-twenty-twenty.php | 2 +- includes/wc-cart-functions.php | 4 ++-- includes/wc-stock-functions.php | 6 +++--- includes/wc-user-functions.php | 2 +- includes/wccom-site/class-wc-wccom-site-installer.php | 2 +- templates/emails/plain/email-order-items.php | 2 +- tests/framework/helpers/class-wc-helper-product.php | 2 +- tests/unit-tests/cart/cart.php | 4 ++-- tests/unit-tests/order/class-wc-tests-orders.php | 2 +- tests/unit-tests/util/class-wc-rate-limiter.php | 4 ++-- 24 files changed, 43 insertions(+), 43 deletions(-) diff --git a/includes/abstracts/abstract-wc-integration.php b/includes/abstracts/abstract-wc-integration.php index ca127be45cb..8ad46759b09 100644 --- a/includes/abstracts/abstract-wc-integration.php +++ b/includes/abstracts/abstract-wc-integration.php @@ -80,6 +80,6 @@ abstract class WC_Integration extends WC_Settings_API { */ public function init_settings() { parent::init_settings(); - $this->enabled = ! empty( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled'] ? 'yes' : 'no'; + $this->enabled = ! empty( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled'] ? 'yes' : 'no'; } } diff --git a/includes/abstracts/abstract-wc-log-handler.php b/includes/abstracts/abstract-wc-log-handler.php index 5f07608ca69..3d2c378eecb 100644 --- a/includes/abstracts/abstract-wc-log-handler.php +++ b/includes/abstracts/abstract-wc-log-handler.php @@ -39,9 +39,9 @@ abstract class WC_Log_Handler implements WC_Log_Handler_Interface { * @return string Formatted log entry. */ protected static function format_entry( $timestamp, $level, $message, $context ) { - $time_string = self::format_time( $timestamp ); + $time_string = self::format_time( $timestamp ); $level_string = strtoupper( $level ); - $entry = "{$time_string} {$level_string} {$message}"; + $entry = "{$time_string} {$level_string} {$message}"; return apply_filters( 'woocommerce_format_log_entry', $entry, array( 'timestamp' => $timestamp, diff --git a/includes/abstracts/abstract-wc-payment-gateway.php b/includes/abstracts/abstract-wc-payment-gateway.php index 6276717b6a2..43555109d4f 100644 --- a/includes/abstracts/abstract-wc-payment-gateway.php +++ b/includes/abstracts/abstract-wc-payment-gateway.php @@ -197,7 +197,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API { */ public function init_settings() { parent::init_settings(); - $this->enabled = ! empty( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled'] ? 'yes' : 'no'; + $this->enabled = ! empty( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled'] ? 'yes' : 'no'; } /** @@ -237,7 +237,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API { */ public function get_transaction_url( $order ) { - $return_url = ''; + $return_url = ''; $transaction_id = $order->get_transaction_id(); if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { @@ -254,7 +254,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API { */ protected function get_order_total() { - $total = 0; + $total = 0; $order_id = absint( get_query_var( 'order-pay' ) ); // Gets order total from "pay for order" page. diff --git a/includes/abstracts/abstract-wc-privacy.php b/includes/abstracts/abstract-wc-privacy.php index 4e56d4ce72d..5908915e6de 100644 --- a/includes/abstracts/abstract-wc-privacy.php +++ b/includes/abstracts/abstract-wc-privacy.php @@ -61,9 +61,9 @@ abstract class WC_Abstract_Privacy { * @param int $erase_priority Erase priority. */ public function __construct( $name = '', $export_priority = 5, $erase_priority = 10 ) { - $this->name = $name; + $this->name = $name; $this->export_priority = $export_priority; - $this->erase_priority = $erase_priority; + $this->erase_priority = $erase_priority; $this->init(); } diff --git a/includes/admin/class-wc-admin-addons.php b/includes/admin/class-wc-admin-addons.php index 428ff7ce1d3..c4ba6b50c9a 100644 --- a/includes/admin/class-wc-admin-addons.php +++ b/includes/admin/class-wc-admin-addons.php @@ -537,7 +537,7 @@ class WC_Admin_Addons { */ public static function output() { $section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : '_featured'; - $search = isset( $_GET['search'] ) ? sanitize_text_field( wp_unslash( $_GET['search'] ) ) : ''; + $search = isset( $_GET['search'] ) ? sanitize_text_field( wp_unslash( $_GET['search'] ) ) : ''; if ( isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) { do_action( 'woocommerce_helper_output' ); diff --git a/includes/admin/class-wc-admin-assets.php b/includes/admin/class-wc-admin-assets.php index 34defe99fc6..baabe2594c2 100644 --- a/includes/admin/class-wc-admin-assets.php +++ b/includes/admin/class-wc-admin-assets.php @@ -295,7 +295,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) : if ( $post_id && in_array( get_post_type( $post_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) { $order = wc_get_order( $post_id ); if ( $order ) { - $currency = $order->get_currency(); + $currency = $order->get_currency(); if ( ! $order->has_status( array( 'pending', 'failed', 'cancelled' ) ) ) { $remove_item_notice = $remove_item_notice . ' ' . __( "You may need to manually restore the item's stock.", 'woocommerce' ); diff --git a/includes/admin/class-wc-admin-setup-wizard.php b/includes/admin/class-wc-admin-setup-wizard.php index c4fd693edd9..d8e00367b09 100644 --- a/includes/admin/class-wc-admin-setup-wizard.php +++ b/includes/admin/class-wc-admin-setup-wizard.php @@ -1676,7 +1676,7 @@ class WC_Admin_Setup_Wizard { if ( in_array( $klarna_or_square, array( 'klarna_checkout', 'klarna_payments' ), true ) ) { $gateways[ $klarna_or_square ]['enabled'] = true; $gateways[ $klarna_or_square ]['featured'] = false; - $offered_gateways += array( + $offered_gateways += array( $klarna_or_square => $gateways[ $klarna_or_square ], ); } else { diff --git a/includes/admin/list-tables/class-wc-admin-list-table-products.php b/includes/admin/list-tables/class-wc-admin-list-table-products.php index a9ea4e7ded5..f864efa4e4d 100644 --- a/includes/admin/list-tables/class-wc-admin-list-table-products.php +++ b/includes/admin/list-tables/class-wc-admin-list-table-products.php @@ -124,11 +124,11 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table { $show_columns['is_in_stock'] = __( 'Stock', 'woocommerce' ); } - $show_columns['price'] = __( 'Price', 'woocommerce' ); - $show_columns['product_cat'] = __( 'Categories', 'woocommerce' ); - $show_columns['product_tag'] = __( 'Tags', 'woocommerce' ); - $show_columns['featured'] = '' . __( 'Featured', 'woocommerce' ) . ''; - $show_columns['date'] = __( 'Date', 'woocommerce' ); + $show_columns['price'] = __( 'Price', 'woocommerce' ); + $show_columns['product_cat'] = __( 'Categories', 'woocommerce' ); + $show_columns['product_tag'] = __( 'Tags', 'woocommerce' ); + $show_columns['featured'] = '' . __( 'Featured', 'woocommerce' ) . ''; + $show_columns['date'] = __( 'Date', 'woocommerce' ); return array_merge( $show_columns, $columns ); } diff --git a/includes/admin/reports/class-wc-report-taxes-by-code.php b/includes/admin/reports/class-wc-report-taxes-by-code.php index 9ce47f74694..024b4c3c383 100644 --- a/includes/admin/reports/class-wc-report-taxes-by-code.php +++ b/includes/admin/reports/class-wc-report-taxes-by-code.php @@ -160,8 +160,8 @@ class WC_Report_Taxes_By_Code extends WC_Admin_Report { $tax_rows = array(); foreach ( $tax_rows_orders + $tax_rows_partial_refunds as $tax_row ) { - $key = $tax_row->rate_id; - $tax_rows[ $key ] = isset( $tax_rows[ $key ] ) ? $tax_rows[ $key ] : (object) array( + $key = $tax_row->rate_id; + $tax_rows[ $key ] = isset( $tax_rows[ $key ] ) ? $tax_rows[ $key ] : (object) array( 'tax_amount' => 0, 'shipping_tax_amount' => 0, 'total_orders' => 0, @@ -173,8 +173,8 @@ class WC_Report_Taxes_By_Code extends WC_Admin_Report { } foreach ( $tax_rows_full_refunds as $tax_row ) { - $key = $tax_row->rate_id; - $tax_rows[ $key ] = isset( $tax_rows[ $key ] ) ? $tax_rows[ $key ] : (object) array( + $key = $tax_row->rate_id; + $tax_rows[ $key ] = isset( $tax_rows[ $key ] ) ? $tax_rows[ $key ] : (object) array( 'tax_amount' => 0, 'shipping_tax_amount' => 0, 'total_orders' => 0, diff --git a/includes/class-wc-query.php b/includes/class-wc-query.php index c01767ab2e0..66dc05e4dce 100644 --- a/includes/class-wc-query.php +++ b/includes/class-wc-query.php @@ -290,8 +290,8 @@ class WC_Query { } } elseif ( ! empty( $_GET['orderby'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $q->set( 'page_id', (int) get_option( 'page_on_front' ) ); - $q->is_page = true; - $q->is_home = false; + $q->is_page = true; + $q->is_home = false; $q->is_singular = true; } } diff --git a/includes/class-wc-rate-limiter.php b/includes/class-wc-rate-limiter.php index 296707a0e0e..f50bd229b52 100644 --- a/includes/class-wc-rate-limiter.php +++ b/includes/class-wc-rate-limiter.php @@ -72,7 +72,7 @@ class WC_Rate_Limiter { * @return bool True if the option setting was successful, false otherwise. */ public static function set_rate_limit( $action_id, $delay ) { - $option_name = self::storage_id( $action_id ); + $option_name = self::storage_id( $action_id ); $next_try_allowed_at = time() + $delay; return update_option( $option_name, $next_try_allowed_at ); } diff --git a/includes/class-wc-shipping-zones.php b/includes/class-wc-shipping-zones.php index 229d709ebd5..cb71dcd1abd 100644 --- a/includes/class-wc-shipping-zones.php +++ b/includes/class-wc-shipping-zones.php @@ -29,9 +29,9 @@ class WC_Shipping_Zones { $zones = array(); foreach ( $raw_zones as $raw_zone ) { - $zone = new WC_Shipping_Zone( $raw_zone ); - $zones[ $zone->get_id() ] = $zone->get_data(); - $zones[ $zone->get_id() ]['zone_id'] = $zone->get_id(); + $zone = new WC_Shipping_Zone( $raw_zone ); + $zones[ $zone->get_id() ] = $zone->get_data(); + $zones[ $zone->get_id() ]['zone_id'] = $zone->get_id(); $zones[ $zone->get_id() ]['formatted_zone_location'] = $zone->get_formatted_location(); $zones[ $zone->get_id() ]['shipping_methods'] = $zone->get_shipping_methods( false, $context ); } diff --git a/includes/class-wc-tax.php b/includes/class-wc-tax.php index 7ae345a0959..53b9cabc18a 100644 --- a/includes/class-wc-tax.php +++ b/includes/class-wc-tax.php @@ -674,7 +674,7 @@ class WC_Tax { */ public static function get_rate_percent( $key_or_rate ) { $rate_percent_value = self::get_rate_percent_value( $key_or_rate ); - $tax_rate_id = is_object( $key_or_rate ) ? $key_or_rate->tax_rate_id : $key_or_rate; + $tax_rate_id = is_object( $key_or_rate ) ? $key_or_rate->tax_rate_id : $key_or_rate; return apply_filters( 'woocommerce_rate_percent', $rate_percent_value . '%', $tax_rate_id ); } diff --git a/includes/data-stores/class-wc-webhook-data-store.php b/includes/data-stores/class-wc-webhook-data-store.php index c16d964dc9f..a684981238b 100644 --- a/includes/data-stores/class-wc-webhook-data-store.php +++ b/includes/data-stores/class-wc-webhook-data-store.php @@ -372,7 +372,7 @@ class WC_Webhook_Data_Store implements WC_Webhook_Data_Store_Interface { protected function get_webhook_count( $status = 'active' ) { global $wpdb; $cache_key = WC_Cache_Helper::get_cache_prefix( 'webhooks' ) . $status . '_count'; - $count = wp_cache_get( $cache_key, 'webhooks' ); + $count = wp_cache_get( $cache_key, 'webhooks' ); if ( false === $count ) { $count = absint( $wpdb->get_var( $wpdb->prepare( "SELECT count( webhook_id ) FROM {$wpdb->prefix}wc_webhooks WHERE `status` = %s;", $status ) ) ); diff --git a/includes/theme-support/class-wc-twenty-twenty.php b/includes/theme-support/class-wc-twenty-twenty.php index 96726fc6056..4045ef6a30e 100644 --- a/includes/theme-support/class-wc-twenty-twenty.php +++ b/includes/theme-support/class-wc-twenty-twenty.php @@ -68,7 +68,7 @@ class WC_Twenty_Twenty { * Set background color to white if it's default, otherwise don't touch it. */ public static function set_white_background() { - $background = sanitize_hex_color_no_hash( get_theme_mod( 'background_color' ) ); + $background = sanitize_hex_color_no_hash( get_theme_mod( 'background_color' ) ); $background_default = 'f5efe0'; // Don't change user's choice of background color. diff --git a/includes/wc-cart-functions.php b/includes/wc-cart-functions.php index ca15a14dfcf..f872d1dd239 100644 --- a/includes/wc-cart-functions.php +++ b/includes/wc-cart-functions.php @@ -203,8 +203,8 @@ function wc_cart_totals_subtotal_html() { * Get shipping methods. */ function wc_cart_totals_shipping_html() { - $packages = WC()->shipping()->get_packages(); - $first = true; + $packages = WC()->shipping()->get_packages(); + $first = true; foreach ( $packages as $i => $package ) { $chosen_method = isset( WC()->session->chosen_shipping_methods[ $i ] ) ? WC()->session->chosen_shipping_methods[ $i ] : ''; diff --git a/includes/wc-stock-functions.php b/includes/wc-stock-functions.php index 2fb6d112338..2deb1580e4c 100644 --- a/includes/wc-stock-functions.php +++ b/includes/wc-stock-functions.php @@ -120,7 +120,7 @@ function wc_maybe_increase_stock_levels( $order_id ) { return; } - $stock_reduced = $order->get_data_store()->get_stock_reduced( $order_id ); + $stock_reduced = $order->get_data_store()->get_stock_reduced( $order_id ); $trigger_increase = (bool) $stock_reduced; // Only continue if we're increasing stock. @@ -207,8 +207,8 @@ function wc_trigger_stock_change_notifications( $order, $changes ) { return; } - $order_notes = array(); - $no_stock_amount = absint( get_option( 'woocommerce_notify_no_stock_amount', 0 ) ); + $order_notes = array(); + $no_stock_amount = absint( get_option( 'woocommerce_notify_no_stock_amount', 0 ) ); foreach ( $changes as $change ) { $order_notes[] = $change['product']->get_formatted_name() . ' ' . $change['from'] . '→' . $change['to']; diff --git a/includes/wc-user-functions.php b/includes/wc-user-functions.php index 4313e50eb7c..2b5b5ffaac1 100644 --- a/includes/wc-user-functions.php +++ b/includes/wc-user-functions.php @@ -538,7 +538,7 @@ function wc_modify_map_meta_cap( $caps, $cap, $user_id, $args ) { $caps[] = 'do_not_allow'; } elseif ( wc_current_user_has_role( 'shop_manager' ) ) { // Shop managers can only edit customer info. - $userdata = get_userdata( $args[0] ); + $userdata = get_userdata( $args[0] ); $shop_manager_editable_roles = apply_filters( 'woocommerce_shop_manager_editable_roles', array( 'customer' ) ); if ( property_exists( $userdata, 'roles' ) && ! empty( $userdata->roles ) && ! array_intersect( $userdata->roles, $shop_manager_editable_roles ) ) { $caps[] = 'do_not_allow'; diff --git a/includes/wccom-site/class-wc-wccom-site-installer.php b/includes/wccom-site/class-wc-wccom-site-installer.php index 8a36af027ae..efe4c48c05b 100644 --- a/includes/wccom-site/class-wc-wccom-site-installer.php +++ b/includes/wccom-site/class-wc-wccom-site-installer.php @@ -564,7 +564,7 @@ class WC_WCCOM_Site_Installer { ); if ( 1 === count( $related_plugins ) ) { - $plugin_key = array_keys( $related_plugins )[0]; + $plugin_key = array_keys( $related_plugins )[0]; $plugin_data = $plugins[ $plugin_key ]; return array( 'name' => $plugin_data['Name'], diff --git a/templates/emails/plain/email-order-items.php b/templates/emails/plain/email-order-items.php index 511edd91677..966b3baa1b5 100644 --- a/templates/emails/plain/email-order-items.php +++ b/templates/emails/plain/email-order-items.php @@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) { foreach ( $items as $item_id => $item ) : if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) { - $product = $item->get_product(); + $product = $item->get_product(); $sku = ''; $purchase_note = ''; diff --git a/tests/framework/helpers/class-wc-helper-product.php b/tests/framework/helpers/class-wc-helper-product.php index baa947e0531..6a6aaab680d 100644 --- a/tests/framework/helpers/class-wc-helper-product.php +++ b/tests/framework/helpers/class-wc-helper-product.php @@ -116,7 +116,7 @@ class WC_Helper_Product { ) ); - $attributes = array(); + $attributes = array(); $attribute = new WC_Product_Attribute(); $attribute_data = self::create_attribute( 'size', array( 'small', 'large', 'huge' ) ); diff --git a/tests/unit-tests/cart/cart.php b/tests/unit-tests/cart/cart.php index a31068c9931..2263282a4fb 100644 --- a/tests/unit-tests/cart/cart.php +++ b/tests/unit-tests/cart/cart.php @@ -260,7 +260,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { update_option( 'woocommerce_calc_taxes', 'yes' ); update_option( 'woocommerce_tax_round_at_subtotal', 'yes' ); - $tax_rate = array( + $tax_rate = array( 'tax_rate_country' => '', 'tax_rate_state' => '', 'tax_rate' => '24.0000', @@ -273,7 +273,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { ); WC_Tax::_insert_tax_rate( $tax_rate ); - $tax_rate = array( + $tax_rate = array( 'tax_rate_country' => '', 'tax_rate_state' => '', 'tax_rate' => '24.0000', diff --git a/tests/unit-tests/order/class-wc-tests-orders.php b/tests/unit-tests/order/class-wc-tests-orders.php index 72f41dff20b..34d7227143d 100644 --- a/tests/unit-tests/order/class-wc-tests-orders.php +++ b/tests/unit-tests/order/class-wc-tests-orders.php @@ -20,7 +20,7 @@ class WC_Tests_Order extends WC_Unit_Test_Case { update_option( 'woocommerce_calc_taxes', 'yes' ); update_option( 'woocommerce_tax_round_at_subtotal', 'yes' ); - $tax_rate = array( + $tax_rate = array( 'tax_rate_country' => '', 'tax_rate_state' => '', 'tax_rate' => '7.0000', diff --git a/tests/unit-tests/util/class-wc-rate-limiter.php b/tests/unit-tests/util/class-wc-rate-limiter.php index e630e9873d9..7ec2562d042 100644 --- a/tests/unit-tests/util/class-wc-rate-limiter.php +++ b/tests/unit-tests/util/class-wc-rate-limiter.php @@ -31,8 +31,8 @@ class WC_Tests_Rate_Limiter extends WC_Unit_Test_Case { */ public function test_rate_limit_limits() { $action_identifier = 'action_1'; - $user_1_id = 10; - $user_2_id = 15; + $user_1_id = 10; + $user_2_id = 15; $rate_limit_id_1 = $action_identifier . $user_1_id; $rate_limit_id_2 = $action_identifier . $user_2_id;