Everywhere yoda conditions are

This commit is contained in:
David Stone
2025-02-09 00:20:10 -07:00
parent d74f6d1a53
commit be0ab98895
213 changed files with 691 additions and 412 deletions

View File

@ -134,7 +134,7 @@ class Broadcast_Manager extends Base_Manager {
$args['type'] = $broadcast_type;
if ($broadcast_type === 'broadcast_notice') {
if ('broadcast_notice' === $broadcast_type) {
$targets = [
'customers' => $target_customers,
'products' => $target_products,

View File

@ -163,7 +163,7 @@ class Customer_Manager extends Base_Manager {
*/
public function transition_customer_email_verification($old_status, $new_status, $customer_id): void {
if ($new_status !== 'pending') {
if ('pending' !== $new_status) {
return;
}
@ -317,7 +317,7 @@ class Customer_Manager extends Base_Manager {
$is_already_user = is_user_member_of_blog($user_id, wu_get_main_site_id());
if ($is_already_user === false) {
if (false === $is_already_user) {
$role = wu_get_setting('main_site_default_role', 'subscriber');
add_user_to_blog(wu_get_main_site_id(), $user_id, $role);

View File

@ -381,6 +381,7 @@ class Domain_Manager extends Base_Manager {
]
);
}
/**
* Returns the default instructions for domain mapping.
*
@ -481,7 +482,7 @@ class Domain_Manager extends Base_Manager {
// translators: %s is the domain name
wu_log_add("domain-{$domain_url}", sprintf(__('Starting Check for %s', 'wp-ultimo'), $domain_url));
if ($stage === 'checking-dns') {
if ('checking-dns' === $stage) {
if ($domain->has_correct_dns()) {
$domain->set_stage('checking-ssl-cert');
@ -540,7 +541,7 @@ class Domain_Manager extends Base_Manager {
return;
}
} elseif ($stage === 'checking-ssl-cert') {
} elseif ('checking-ssl-cert' === $stage) {
if ($domain->has_valid_ssl_certificate()) {
$domain->set_stage('done');
@ -685,7 +686,7 @@ class Domain_Manager extends Base_Manager {
);
}
if ($result === false) {
if (false === $result) {
wp_send_json_error(new \WP_Error('error', __('Not able to fetch DNS entries.', 'wp-ultimo')));
}

View File

@ -98,7 +98,7 @@ class Event_Manager extends Base_Manager {
*/
public function log_transitions($model, $data, $data_unserialized, $object) {
if ($model === 'event') {
if ('event' === $model) {
return;
}
@ -143,7 +143,7 @@ class Event_Manager extends Base_Manager {
foreach ($diff as $key => $new_value) {
$old_value = wu_get_isset($original, $key, '');
if ($key === 'id' && intval($old_value) === 0) {
if ('id' === $key && intval($old_value) === 0) {
return;
}
@ -561,7 +561,7 @@ class Event_Manager extends Base_Manager {
}
if (method_exists($obj, 'get_billing_address') || method_exists($obj, 'get_membership')) {
if ($model_object) {
if (null !== $model_object) {
$payload = method_exists($obj, 'get_billing_address')
? array_merge(
$payload,

View File

@ -75,9 +75,9 @@ class Limitation_Manager {
switch_to_blog($site_id);
if ($action === 'activate') {
if ('activate' === $action) {
$results = activate_plugins($plugins, '', $network_wide, $silent);
} elseif ($action === 'deactivate') {
} elseif ('deactivate' === $action) {
$results = deactivate_plugins($plugins, $silent, $network_wide);
}
@ -820,6 +820,7 @@ class Limitation_Manager {
return $listed_plugins;
}
/**
* Returns a list of all themes available as options, after filtering.
*

View File

@ -114,6 +114,7 @@ class Membership_Manager extends Base_Manager {
exit; // Just exit the request
}
/**
* Processes a delayed site publish action.
*
@ -169,6 +170,7 @@ class Membership_Manager extends Base_Manager {
exit;
}
/**
* Processes a membership swap.
*
@ -279,7 +281,7 @@ class Membership_Manager extends Base_Manager {
*/
public function mark_cancelled_date($old_value, $new_value, $item_id): void {
if ($new_value === 'cancelled' && $new_value !== $old_value) {
if ('cancelled' === $new_value && $new_value !== $old_value) {
$membership = wu_get_membership($item_id);
$membership->set_date_cancellation(wu_get_current_time('mysql', true));

View File

@ -474,7 +474,7 @@ class Notes_Manager extends Base_Manager {
$status = $object->delete_note($note_id);
if (is_wp_error($status) || $status === false) {
if (is_wp_error($status) || false === $status) {
wp_send_json_error(new \WP_Error('not-found', __('Note not found', 'wp-ultimo')));
}

View File

@ -73,11 +73,11 @@ class Notification_Manager {
$cleaner = [$this, 'clear_callback_list'];
if (wu_get_isset($wp_filter, 'admin_notices')) {
$wp_filter['admin_notices']->callbacks = array_filter($wp_filter['admin_notices']->callbacks, $cleaner ?? fn($v, $k): bool => ! empty($v), $cleaner === null ? ARRAY_FILTER_USE_BOTH : 0);
$wp_filter['admin_notices']->callbacks = array_filter($wp_filter['admin_notices']->callbacks, $cleaner ?? fn($v, $k): bool => ! empty($v), null === $cleaner ? ARRAY_FILTER_USE_BOTH : 0);
}
if (wu_get_isset($wp_filter, 'all_admin_notices')) {
$wp_filter['all_admin_notices']->callbacks = array_filter($wp_filter['all_admin_notices']->callbacks, $cleaner ?? fn($v, $k): bool => ! empty($v), $cleaner === null ? ARRAY_FILTER_USE_BOTH : 0);
$wp_filter['all_admin_notices']->callbacks = array_filter($wp_filter['all_admin_notices']->callbacks, $cleaner ?? fn($v, $k): bool => ! empty($v), null === $cleaner ? ARRAY_FILTER_USE_BOTH : 0);
}
}

View File

@ -124,7 +124,7 @@ class Site_Manager extends Base_Manager {
* if so, we remove it and re-validate with our custom rule
* which is the same, but also allows for hyphens.
*/
if ( ! empty($blogname_errors) && $error_key !== false) {
if ( ! empty($blogname_errors) && false !== $error_key) {
unset($result['errors']->errors['blogname'][ $error_key ]);
if (empty($result['errors']->errors['blogname'])) {
@ -284,14 +284,14 @@ class Site_Manager extends Base_Manager {
$status = $membership ? $membership->get_status() : false;
$is_cancelled = $status === Membership_Status::CANCELLED;
$is_cancelled = Membership_Status::CANCELLED === $status;
$is_inactive = $status && ! $membership->is_active() && $status !== Membership_Status::TRIALING;
$is_inactive = $status && ! $membership->is_active() && Membership_Status::TRIALING !== $status;
if ($is_cancelled || ($is_inactive && wu_get_setting('block_frontend', false))) {
// If membership is cancelled we do not add the grace period
$grace_period = $status !== Membership_Status::CANCELLED ? (int) wu_get_setting('block_frontend_grace_period', 0) : 0;
$grace_period = Membership_Status::CANCELLED !== $status ? (int) wu_get_setting('block_frontend_grace_period', 0) : 0;
$expiration_time = wu_date($membership->get_date_expiration())->getTimestamp() + $grace_period * DAY_IN_SECONDS;
@ -305,7 +305,7 @@ class Site_Manager extends Base_Manager {
}
}
if ($can_access === false) {
if (false === $can_access) {
if ($redirect_url) {
wp_redirect($redirect_url);
@ -678,7 +678,7 @@ class Site_Manager extends Base_Manager {
*/
public function filter_illegal_search_keys($search_and_replace): array {
return array_filter($search_and_replace, fn($k) => ! is_null($k) && $k !== false && ! empty($k), ARRAY_FILTER_USE_KEY);
return array_filter($search_and_replace, fn($k) => ! is_null($k) && false !== $k && ! empty($k), ARRAY_FILTER_USE_KEY);
}
/**