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

@ -111,6 +111,7 @@ class Billing_Address {
$this->attributes[ $name ] = $value;
}
/**
* Returns the validation rules for the billing address fields.
*
@ -168,6 +169,7 @@ class Billing_Address {
return $address_array;
}
/**
* Returns a string representation of the billing address.
*

View File

@ -82,7 +82,7 @@ class Limitations {
$module = wu_get_isset($this->modules, $name, false);
if ($module === false) {
if (false === $module) {
$repo = self::repository();
$class_name = wu_get_isset($repo, $name, false);
@ -145,6 +145,7 @@ class Limitations {
return $this;
}
/**
* Build a module, based on the data.
*
@ -315,23 +316,23 @@ class Limitations {
$original_value = wu_get_isset($array1, $key);
// If the value is 0 or '' it can be a unlimited value
$is_unlimited = (is_numeric($value) || $value === '') && (int) $value === 0;
$is_unlimited = (is_numeric($value) || '' === $value) && (int) $value === 0;
if ($should_sum && ($original_value === '' || $original_value === 0)) {
if ($should_sum && ('' === $original_value || 0 === $original_value)) {
/**
* We use values 0 or '' as unlimited in our limits
*/
continue;
} elseif (isset($array1[ $key ]) && is_numeric($array1[ $key ]) && is_numeric($value) && $should_sum && ! $is_unlimited) {
$array1[ $key ] = ((int) $array1[ $key ]) + $value;
} elseif ($key === 'visibility' && isset($array1[ $key ]) && $should_sum) {
} elseif ('visibility' === $key && isset($array1[ $key ]) && $should_sum) {
$key_priority = [
'hidden' => 0,
'visible' => 1,
];
$array1[ $key ] = $key_priority[ $value ] > $key_priority[ $array1[ $key ] ] ? $value : $array1[ $key ];
} elseif ($key === 'behavior' && isset($array1[ $key ]) && $should_sum) {
} elseif ('behavior' === $key && isset($array1[ $key ]) && $should_sum) {
$key_priority_list = [
'plugins' => [
'default' => 10,
@ -358,13 +359,14 @@ class Limitations {
} else {
// Avoid change true values
$array1[ $key ] = $original_value !== true || ! $should_sum ? $value : true;
$array1[ $key ] = true !== $original_value || ! $should_sum ? $value : true;
$array1[ $key ] = $original_value !== true || ! $should_sum ? $value : true;
$array1[ $key ] = true !== $original_value || ! $should_sum ? $value : true;
}
}
}
}
/**
* Converts the limitations list to an array.
*
@ -392,7 +394,7 @@ class Limitations {
* Reset the slug and prefixes
* for the native tables of blogs.
*/
if ($slug === 'site') {
if ('site' === $slug) {
$slug = 'blog';
$wu_prefix = '';
@ -447,7 +449,7 @@ class Limitations {
* Site apis are already available,
* so no need to use low-level sql calls.
*/
if ($slug === 'site') {
if ('site' === $slug) {
$wu_prefix = '';
$slug = 'blog';

View File

@ -168,6 +168,7 @@ class Note {
return $address_array;
}
/**
* Returns the contents of the note.
*

View File

@ -23,6 +23,7 @@ class Visits {
* Key to save on the database.
*/
const KEY = 'wu_visits';
/**
* @var int
*/
@ -38,6 +39,7 @@ class Visits {
public function __construct($site_id) {
$this->site_id = $site_id;
}
/**
* Returns the meta key to save visits.
*