More yoda conditions
This commit is contained in:
@ -626,7 +626,7 @@ class Cart implements \JsonSerializable {
|
||||
$product = $line_item->get_product();
|
||||
|
||||
if ($product) {
|
||||
if ($product->is_recurring() && ($this->duration_unit !== $product->get_duration_unit() || $this->duration !== $product->get_duration())) {
|
||||
if ($product->is_recurring() && ($product->get_duration_unit() !== $this->duration_unit || $product->get_duration() !== $this->duration)) {
|
||||
$product_variation = $product->get_as_variation($this->duration, $this->duration_unit);
|
||||
|
||||
/*
|
||||
@ -876,7 +876,7 @@ class Cart implements \JsonSerializable {
|
||||
*/
|
||||
$is_plan_change = false;
|
||||
|
||||
if ($membership->get_plan_id() !== $this->plan_id || $this->duration_unit !== $membership->get_duration_unit() || $this->duration !== $membership->get_duration()) {
|
||||
if ($membership->get_plan_id() !== $this->plan_id || $membership->get_duration_unit() !== $this->duration_unit || $membership->get_duration() !== $this->duration) {
|
||||
$is_plan_change = true;
|
||||
}
|
||||
|
||||
@ -934,7 +934,7 @@ class Cart implements \JsonSerializable {
|
||||
* We'll probably never enter in this if, but we
|
||||
* hev it here to prevent bugs.
|
||||
*/
|
||||
if ( ! $is_plan_change || ($this->get_plan_id() === $membership->get_plan_id() && $this->duration_unit === $membership->get_duration_unit() && $this->duration === $membership->get_duration())) {
|
||||
if ( ! $is_plan_change || ($this->get_plan_id() === $membership->get_plan_id() && $membership->get_duration_unit() === $this->duration_unit && $membership->get_duration() === $this->duration)) {
|
||||
$this->products = [];
|
||||
$this->line_items = [];
|
||||
|
||||
@ -969,7 +969,7 @@ class Cart implements \JsonSerializable {
|
||||
$old_price_per_day = $days_in_old_cycle > 0 ? $membership->get_amount() / $days_in_old_cycle : $membership->get_amount();
|
||||
$new_price_per_day = $days_in_new_cycle > 0 ? $this->get_recurring_total() / $days_in_new_cycle : $this->get_recurring_total();
|
||||
|
||||
$is_same_product = $this->plan_id === $membership->get_plan_id();
|
||||
$is_same_product = $membership->get_plan_id() === $this->plan_id;
|
||||
|
||||
/**
|
||||
* Here we search for variations of the plans
|
||||
@ -1088,7 +1088,7 @@ class Cart implements \JsonSerializable {
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->duration_unit && $this->duration && ($this->duration_unit !== $plan_b->get_duration_unit() || $this->duration !== $plan_b->get_duration())) {
|
||||
if ($this->duration_unit && $this->duration && ($plan_b->get_duration_unit() !== $this->duration_unit || $plan_b->get_duration() !== $this->duration)) {
|
||||
$plan_a_variation = $plan_a->get_as_variation($this->duration, $this->duration_unit);
|
||||
|
||||
if ( ! $plan_a_variation) {
|
||||
@ -1511,7 +1511,7 @@ class Cart implements \JsonSerializable {
|
||||
}
|
||||
|
||||
// Here we check if the product is recurring and if so, get the correct variation
|
||||
if ($product->is_recurring() && ! empty($this->duration) && ($this->duration !== $product->get_duration() || $this->duration_unit !== $product->get_duration_unit())) {
|
||||
if ($product->is_recurring() && ! empty($this->duration) && ($product->get_duration() !== $this->duration || $product->get_duration_unit() !== $this->duration_unit)) {
|
||||
$product = $product->get_as_variation($this->duration, $this->duration_unit);
|
||||
|
||||
if ( ! $product) {
|
||||
@ -1576,7 +1576,7 @@ class Cart implements \JsonSerializable {
|
||||
* the cart.
|
||||
*/
|
||||
if ($product->is_free() === false) {
|
||||
if (absint($this->duration) !== $product->get_duration() || $this->duration_unit !== $product->get_duration_unit()) {
|
||||
if (absint($this->duration) !== $product->get_duration() || $product->get_duration_unit() !== $this->duration_unit) {
|
||||
$price_variation = $product->get_price_variation($this->duration, $this->duration_unit);
|
||||
|
||||
if ($price_variation) {
|
||||
@ -2614,7 +2614,7 @@ class Cart implements \JsonSerializable {
|
||||
*/
|
||||
public function should_auto_renew() {
|
||||
|
||||
return $this->auto_renew === 'yes' || $this->auto_renew === true;
|
||||
return 'yes' === $this->auto_renew || true === $this->auto_renew;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -437,7 +437,7 @@ class Checkout_Pages {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if ('POST' === $_SERVER['REQUEST_METHOD']) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@ class Checkout {
|
||||
|
||||
$this->checkout_form = wu_get_checkout_form_by_slug($checkout_form_slug);
|
||||
|
||||
if ($this->session === null) {
|
||||
if (null === $this->session) {
|
||||
$this->session = wu_get_session('signup');
|
||||
}
|
||||
|
||||
@ -1434,7 +1434,7 @@ class Checkout {
|
||||
* to handle the status here as the payment is not
|
||||
* passed to process_checkout method in this case.
|
||||
*/
|
||||
if ( ! $this->order->should_collect_payment() && $this->type === 'downgrade') {
|
||||
if ( ! $this->order->should_collect_payment() && 'downgrade' === $this->type) {
|
||||
$payment_data['status'] = Payment_Status::COMPLETED;
|
||||
}
|
||||
|
||||
@ -1570,7 +1570,7 @@ class Checkout {
|
||||
if (empty($duration) && $this->steps) {
|
||||
foreach ($this->steps as $step) {
|
||||
foreach ($step['fields'] as $field) {
|
||||
if ($field['type'] === 'period_selection') {
|
||||
if ('period_selection' === $field['type']) {
|
||||
$duration = $field['period_options'][0]['duration'];
|
||||
$duration_unit = $field['period_options'][0]['duration_unit'];
|
||||
|
||||
@ -1723,7 +1723,7 @@ class Checkout {
|
||||
/*
|
||||
* Add rules for site when creating a new account.
|
||||
*/
|
||||
if ($this->type === 'new') {
|
||||
if ('new' === $this->type) {
|
||||
|
||||
// char limit according https://datatracker.ietf.org/doc/html/rfc1034#section-3.1
|
||||
$rules['site_title'] = 'min:4';
|
||||
@ -2293,7 +2293,7 @@ class Checkout {
|
||||
|
||||
$value = $default;
|
||||
|
||||
if ($this->session !== null) {
|
||||
if (null !== $this->session) {
|
||||
$session = $this->session->get('signup');
|
||||
|
||||
if (isset($session[ $key ])) {
|
||||
@ -2348,7 +2348,7 @@ class Checkout {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->step_name === array_shift($step_names);
|
||||
return array_shift($step_names) === $this->step_name;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2386,7 +2386,7 @@ class Checkout {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->step_name === array_pop($step_names);
|
||||
return array_pop($step_names) === $this->step_name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -247,7 +247,7 @@ class Legacy_Checkout {
|
||||
wp_add_inline_style('legacy-signup', $this->get_legacy_dynamic_styles());
|
||||
|
||||
// Do not get the login if the first step
|
||||
if ($this->step != 'plan') {
|
||||
if ('plan' != $this->step) {
|
||||
|
||||
wp_enqueue_style('login');
|
||||
|
||||
@ -577,7 +577,7 @@ class Legacy_Checkout {
|
||||
/**
|
||||
* Set the errors
|
||||
*/
|
||||
if ($this->results === null) {
|
||||
if (null === $this->results) {
|
||||
$this->results = ['errors' => new \WP_Error()];
|
||||
}
|
||||
|
||||
@ -979,7 +979,7 @@ class Legacy_Checkout {
|
||||
$params['customized'] = $_REQUEST['customized'];
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['skip_plan']) && $_REQUEST['skip_plan'] == 1) {
|
||||
if (isset($_REQUEST['skip_plan']) && 1 == $_REQUEST['skip_plan']) {
|
||||
unset($this->steps['plan']);
|
||||
unset($params['skip_plan']);
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ class Line_Item implements \JsonSerializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($product->is_recurring() && ($this->duration_unit !== $product->get_duration_unit() || $this->duration !== $product->get_duration())) {
|
||||
if ($product->is_recurring() && ($product->get_duration_unit() !== $this->duration_unit || $product->get_duration() !== $this->duration)) {
|
||||
$product_variation = $product->get_as_variation($this->duration, $this->duration_unit);
|
||||
|
||||
/*
|
||||
|
@ -215,7 +215,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field {
|
||||
/*
|
||||
* Backwards compatibility with previous betas
|
||||
*/
|
||||
if ($attributes['order_summary_template'] === 'simple') {
|
||||
if ('simple' === $attributes['order_summary_template']) {
|
||||
$attributes['order_summary_template'] = 'clean';
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user