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

@ -60,7 +60,7 @@ class Arr {
);
if ($flag) {
$result = $flag === self::RESULTS_FIRST ? reset($result) : end($result);
$result = self::RESULTS_FIRST === $flag ? reset($result) : end($result);
}
return $result;

View File

@ -31,6 +31,7 @@ class Screenshot {
public static function api_url($domain): string {
return 'https://image.thum.io/get/' . $domain;
}
/**
* Takes in a URL and creates it as an attachment.
*
@ -45,6 +46,7 @@ class Screenshot {
return self::save_image_from_url($url);
}
/**
* Downloads the image from the URL.
*

View File

@ -34,7 +34,7 @@ class WP_Config {
$config_path = $this->get_wp_config_path();
if ( ! is_writeable($config_path)) {
if ( ! is_writable($config_path)) {
// translators: %s is the file name.
return new \WP_Error('not-writeable', sprintf(__('The file %s is not writable', 'wp-ultimo'), $config_path));
@ -46,12 +46,12 @@ class WP_Config {
$content = str_pad(sprintf("define( '%s', '%s' );", $constant, $value), 50) . '// Automatically injected by WP Multisite WaaS;';
if ($line === false) {
if (false === $line) {
// no defined, we just need to inject
$hook_line = $this->find_reference_hook_line($config);
if ($hook_line === false) {
if (false === $hook_line) {
return new \WP_Error('unknown-wpconfig', __("WP Multisite WaaS can't recognize your wp-config.php, please revert it to original state for further process.", 'wp-ultimo'));
}
@ -61,7 +61,7 @@ class WP_Config {
} else {
[$value, $line] = $line;
if ($value !== true) {
if (true !== $value) {
$config[ $line ] = $content . PHP_EOL;
return file_put_contents($config_path, implode('', $config), LOCK_EX);
@ -177,7 +177,7 @@ class WP_Config {
$config_path = $this->get_wp_config_path();
if ( ! is_writeable($config_path)) {
if ( ! is_writable($config_path)) {
// translators: %s is the file name.
return new \WP_Error('not-writeable', sprintf(__('The file %s is not writable', 'wp-ultimo'), $config_path));
@ -187,14 +187,14 @@ class WP_Config {
$line = $this->find_injected_line($config, $constant);
if ($line === false) {
if (false === $line) {
return;
} else {
$value = $line[0];
$line = $line[1];
if ($value === 'true' || $value === '1') {
if ('true' === $value || '1' === $value) {
// value is true, we will remove this
unset($config[ $line ]);
@ -204,6 +204,7 @@ class WP_Config {
}
}
}
/**
* Checks for the injected line inside of the wp-config.php file.
*

View File

@ -28,6 +28,7 @@ class City extends Rule {
* @var array
*/
protected $fillableParams = ['country', 'state'];
/**
* Performs the actual check.
*

View File

@ -84,6 +84,7 @@ class Unique extends Rule {
if ( ! $existing) {
return true;
}
if ( $existing instanceof \WP_User) {
$id = $existing->ID;
} else {