From 0660a50e07815547085eb04494aed14fc1e2ac64 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Wed, 21 Mar 2018 19:57:10 -0300 Subject: [PATCH] Removed obvious boolean results --- includes/abstracts/abstract-wc-order.php | 2 +- includes/abstracts/abstract-wc-payment-gateway.php | 4 ++-- includes/abstracts/abstract-wc-product.php | 4 ++-- includes/api/class-wc-rest-system-status-controller.php | 2 +- includes/api/legacy/v1/class-wc-api-orders.php | 2 +- includes/api/legacy/v2/class-wc-api-orders.php | 2 +- includes/api/legacy/v3/class-wc-api-orders.php | 2 +- includes/class-wc-tax.php | 2 +- includes/cli/class-wc-cli-runner.php | 2 +- includes/gateways/cod/class-wc-gateway-cod.php | 2 +- includes/legacy/class-wc-legacy-coupon.php | 2 +- includes/shortcodes/class-wc-shortcode-checkout.php | 2 +- includes/wc-conditional-functions.php | 2 +- includes/wc-template-functions.php | 2 +- 14 files changed, 16 insertions(+), 16 deletions(-) diff --git a/includes/abstracts/abstract-wc-order.php b/includes/abstracts/abstract-wc-order.php index 557548d8b8b..8bcc2d7e83f 100644 --- a/includes/abstracts/abstract-wc-order.php +++ b/includes/abstracts/abstract-wc-order.php @@ -1876,7 +1876,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order { * @return bool */ public function has_status( $status ) { - return apply_filters( 'woocommerce_order_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status ? true : false, $this, $status ); + return apply_filters( 'woocommerce_order_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status, $this, $status ); } /** diff --git a/includes/abstracts/abstract-wc-payment-gateway.php b/includes/abstracts/abstract-wc-payment-gateway.php index f8ae77abaa7..1a175a8ecb9 100644 --- a/includes/abstracts/abstract-wc-payment-gateway.php +++ b/includes/abstracts/abstract-wc-payment-gateway.php @@ -273,7 +273,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API { * @return bool */ public function has_fields() { - return $this->has_fields ? true : false; + return (bool) $this->has_fields; } /** @@ -385,7 +385,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API { * @since 1.5.7 */ public function supports( $feature ) { - return apply_filters( 'woocommerce_payment_gateway_supports', in_array( $feature, $this->supports ) ? true : false, $feature, $this ); + return apply_filters( 'woocommerce_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this ); } /** diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index 86bc9040f55..5fe522d1c5a 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -1360,7 +1360,7 @@ class WC_Product extends WC_Abstract_Legacy_Product { * @since 2.5.0 */ public function supports( $feature ) { - return apply_filters( 'woocommerce_product_supports', in_array( $feature, $this->supports ) ? true : false, $feature, $this ); + return apply_filters( 'woocommerce_product_supports', in_array( $feature, $this->supports ), $feature, $this ); } /** @@ -1577,7 +1577,7 @@ class WC_Product extends WC_Abstract_Legacy_Product { return true; } - return $this->managing_stock() && $this->backorders_allowed() && ( $this->get_stock_quantity() - $qty_in_cart ) < 0 ? true : false; + return $this->managing_stock() && $this->backorders_allowed() && ( $this->get_stock_quantity() - $qty_in_cart ) < 0; } /** diff --git a/includes/api/class-wc-rest-system-status-controller.php b/includes/api/class-wc-rest-system-status-controller.php index fbe88042936..4404f4f11d6 100644 --- a/includes/api/class-wc-rest-system-status-controller.php +++ b/includes/api/class-wc-rest-system-status-controller.php @@ -603,7 +603,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller { 'site_url' => get_option( 'siteurl' ), 'version' => WC()->version, 'log_directory' => WC_LOG_DIR, - 'log_directory_writable' => ( @fopen( WC_LOG_DIR . 'test-log.log', 'a' ) ? true : false ), + 'log_directory_writable' => (bool) @fopen( WC_LOG_DIR . 'test-log.log', 'a' ), 'wp_version' => get_bloginfo( 'version' ), 'wp_multisite' => is_multisite(), 'wp_memory_limit' => $wp_memory_limit, diff --git a/includes/api/legacy/v1/class-wc-api-orders.php b/includes/api/legacy/v1/class-wc-api-orders.php index 2129f832eea..c4a391d5bdb 100644 --- a/includes/api/legacy/v1/class-wc-api-orders.php +++ b/includes/api/legacy/v1/class-wc-api-orders.php @@ -337,7 +337,7 @@ class WC_API_Orders extends WC_API_Resource { 'id' => $note->comment_ID, 'created_at' => $this->server->format_datetime( $note->comment_date_gmt ), 'note' => $note->comment_content, - 'customer_note' => get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? true : false, + 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ), ); } diff --git a/includes/api/legacy/v2/class-wc-api-orders.php b/includes/api/legacy/v2/class-wc-api-orders.php index 1ad7dca9450..328f6b5be43 100644 --- a/includes/api/legacy/v2/class-wc-api-orders.php +++ b/includes/api/legacy/v2/class-wc-api-orders.php @@ -1269,7 +1269,7 @@ class WC_API_Orders extends WC_API_Resource { 'id' => $note->comment_ID, 'created_at' => $this->server->format_datetime( $note->comment_date_gmt ), 'note' => $note->comment_content, - 'customer_note' => get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? true : false, + 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ), ); return array( 'order_note' => apply_filters( 'woocommerce_api_order_note_response', $order_note, $id, $fields, $note, $order_id, $this ) ); diff --git a/includes/api/legacy/v3/class-wc-api-orders.php b/includes/api/legacy/v3/class-wc-api-orders.php index ec76b6c76bf..5d30676b02e 100644 --- a/includes/api/legacy/v3/class-wc-api-orders.php +++ b/includes/api/legacy/v3/class-wc-api-orders.php @@ -1316,7 +1316,7 @@ class WC_API_Orders extends WC_API_Resource { 'id' => $note->comment_ID, 'created_at' => $this->server->format_datetime( $note->comment_date_gmt ), 'note' => $note->comment_content, - 'customer_note' => get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? true : false, + 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ), ); return array( 'order_note' => apply_filters( 'woocommerce_api_order_note_response', $order_note, $id, $fields, $note, $order_id, $this ) ); diff --git a/includes/class-wc-tax.php b/includes/class-wc-tax.php index f31a2d4aa99..273e8edb265 100644 --- a/includes/class-wc-tax.php +++ b/includes/class-wc-tax.php @@ -603,7 +603,7 @@ class WC_Tax { $compound = $key_or_rate->tax_rate_compound; } else { $key = $key_or_rate; - $compound = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_compound FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key ) ) ? true : false; + $compound = (bool) $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_compound FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key ) ); } return (bool) apply_filters( 'woocommerce_rate_compound', $compound, $key ); diff --git a/includes/cli/class-wc-cli-runner.php b/includes/cli/class-wc-cli-runner.php index 9fc90d883e7..a4194b8139b 100644 --- a/includes/cli/class-wc-cli-runner.php +++ b/includes/cli/class-wc-cli-runner.php @@ -181,7 +181,7 @@ class WC_CLI_Runner { 'name' => $name, 'type' => 'assoc', 'description' => ! empty( $args['description'] ) ? $args['description'] : '', - 'optional' => empty( $args['required'] ) ? true : false, + 'optional' => empty( $args['required'] ), ); } } diff --git a/includes/gateways/cod/class-wc-gateway-cod.php b/includes/gateways/cod/class-wc-gateway-cod.php index 06c594a941e..a51e69976cd 100644 --- a/includes/gateways/cod/class-wc-gateway-cod.php +++ b/includes/gateways/cod/class-wc-gateway-cod.php @@ -37,7 +37,7 @@ class WC_Gateway_COD extends WC_Payment_Gateway { $this->description = $this->get_option( 'description' ); $this->instructions = $this->get_option( 'instructions' ); $this->enable_for_methods = $this->get_option( 'enable_for_methods', array() ); - $this->enable_for_virtual = $this->get_option( 'enable_for_virtual', 'yes' ) === 'yes' ? true : false; + $this->enable_for_virtual = $this->get_option( 'enable_for_virtual', 'yes' ) === 'yes'; add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'thankyou_page' ) ); diff --git a/includes/legacy/class-wc-legacy-coupon.php b/includes/legacy/class-wc-legacy-coupon.php index 91c5fd893ee..cad0fc1fdb1 100644 --- a/includes/legacy/class-wc-legacy-coupon.php +++ b/includes/legacy/class-wc-legacy-coupon.php @@ -65,7 +65,7 @@ abstract class WC_Legacy_Coupon extends WC_Data { $value = $this->get_id(); break; case 'exists' : - $value = ( $this->get_id() > 0 ) ? true : false; + $value = $this->get_id() > 0; break; case 'coupon_custom_fields' : $legacy_custom_fields = array(); diff --git a/includes/shortcodes/class-wc-shortcode-checkout.php b/includes/shortcodes/class-wc-shortcode-checkout.php index 2289d325477..5a4fe2eb334 100644 --- a/includes/shortcodes/class-wc-shortcode-checkout.php +++ b/includes/shortcodes/class-wc-shortcode-checkout.php @@ -241,7 +241,7 @@ class WC_Shortcode_Checkout { } else { - $non_js_checkout = ! empty( $_POST['woocommerce_checkout_update_totals'] ) ? true : false; // WPCS: input var ok, CSRF ok. + $non_js_checkout = ! empty( $_POST['woocommerce_checkout_update_totals'] ); // WPCS: input var ok, CSRF ok. if ( wc_notice_count( 'error' ) === 0 && $non_js_checkout ) { wc_add_notice( __( 'The order totals have been updated. Please confirm your order by pressing the "Place order" button at the bottom of the page.', 'woocommerce' ) ); diff --git a/includes/wc-conditional-functions.php b/includes/wc-conditional-functions.php index 0742e2fc1c8..630e5349c91 100644 --- a/includes/wc-conditional-functions.php +++ b/includes/wc-conditional-functions.php @@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) { * @return bool */ function is_woocommerce() { - return apply_filters( 'is_woocommerce', ( is_shop() || is_product_taxonomy() || is_product() ) ? true : false ); + return apply_filters( 'is_woocommerce', is_shop() || is_product_taxonomy() || is_product() ); } if ( ! function_exists( 'is_shop' ) ) { diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index a0be45b1172..617499ab525 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -2456,7 +2456,7 @@ if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) { $name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title( $attribute ); $id = $args['id'] ? $args['id'] : sanitize_title( $attribute ); $class = $args['class']; - $show_option_none = $args['show_option_none'] ? true : false; + $show_option_none = (bool) $args['show_option_none']; $show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __( 'Choose an option', 'woocommerce' ); // We'll do our best to hide the placeholder, but we'll need to show something when resetting options. if ( empty( $options ) && ! empty( $product ) && ! empty( $attribute ) ) {