Skip to content

Commit

Permalink
[static-analysis] Fix truthy/false statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
bahiirwa committed Jan 15, 2024
1 parent df78061 commit b3bd9e0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
9 changes: 5 additions & 4 deletions includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -8020,6 +8020,7 @@ private function maybe_network_activate_addon_license( $license = null ) {
}
}

// @phpstan-ignore-next-line
if ( ! empty( $site_ids ) ) {
$this->activate_license_on_many_sites( $user, $license->secret_key, $site_ids );
}
Expand Down Expand Up @@ -8515,7 +8516,7 @@ function _deactivate_plugin_hook() {
unset( $this->_storage->sticky_optin_added_ms );
}

if ( ! empty( $storage_keys_for_removal ) ) {
if ( count( $storage_keys_for_removal ) > 0 ) {
$sites = self::get_sites();

foreach ( $sites as $site ) {
Expand Down Expand Up @@ -14093,7 +14094,7 @@ private function activate_license(
$result = $fs->activate_license_on_many_installs( $user, $license_key, $blog_2_install_map );
}

if ( true === $result && ! empty( $site_ids ) ) {
if ( true === $result && count( $site_ids ) > 0 ) {
$result = $fs->activate_license_on_many_sites( $user, $license_key, $site_ids );
}
} else {
Expand Down Expand Up @@ -19906,7 +19907,7 @@ private function _store_site( $store = true, $network_level_or_blog_id = null, F
$site = $this->_site;
}

if ( !isset( $site ) || !is_object($site) || empty( $site->id ) ) {
if ( !is_object($site) || empty( $site->id ) ) {
$this->_logger->error( "Empty install ID, can't store site." );

return;
Expand Down Expand Up @@ -20040,7 +20041,7 @@ private function _store_licenses( $store = true, $module_id = false, $licenses =
}
}

if ( ! empty( $new_user_licenses_map ) ) {
if ( count( $new_user_licenses_map ) > 0 ) {
// Add new licenses.
$all_licenses[ $module_id ] = array_merge( array_values( $new_user_licenses_map ), $all_licenses[ $module_id ] );
}
Expand Down
3 changes: 2 additions & 1 deletion includes/class-fs-plugin-updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ function pre_set_site_transient_update_plugins_filter( $transient_data ) {
return $transient_data;
}

// @phpstan-ignore-next-line
if ( empty( $transient_data ) ||
defined( 'WP_FS__UNINSTALL_MODE' )
) {
Expand Down Expand Up @@ -1046,7 +1047,7 @@ function plugins_api_filter( $data, $action = '', $args = null ) {
false
);

if ( ! empty( $addon_plugin_data ) ) {
if ( is_array( $addon_plugin_data ) && $addon_plugin_data['Version'] ) {
$addon_version = $addon_plugin_data['Version'];
}
}
Expand Down
2 changes: 1 addition & 1 deletion includes/fs-plugin-info-dialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function _get_addon_info_filter( $data, $action = '', $args = null ) {
false
);

if ( ! empty( $addon_plugin_data ) ) {
if ( is_array( $addon_plugin_data ) && $addon_plugin_data['Version'] ) {
$current_addon_version = $addon_plugin_data['Version'];
}
}
Expand Down
12 changes: 4 additions & 8 deletions includes/managers/class-fs-admin-menu-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private function get_bool_option( &$options, $key, $default = false ) {
* @param bool $is_addon
*/
function init( $menu, $is_addon = false ) {
$this->_menu_exists = ( isset( $menu['slug'] ) && ! empty( $menu['slug'] ) );
$this->_menu_exists = ( ! empty( $menu['slug'] ) );
$this->_network_menu_exists = ( ! empty( $menu['network'] ) && true === $menu['network'] );

$this->_menu_slug = ( $this->_menu_exists ? $menu['slug'] : $this->_module_unique_affix );
Expand All @@ -168,7 +168,7 @@ function init( $menu, $is_addon = false ) {
// @deprecated
$this->_parent_type = 'page';

if ( isset( $menu ) ) {
if ( is_array( $menu ) ) {
if ( ! $is_addon ) {
$this->_default_submenu_items = array(
'contact' => $this->get_bool_option( $menu, 'contact', true ),
Expand Down Expand Up @@ -318,12 +318,8 @@ function is_submenu_item_visible( $id, $default = true, $ignore_menu_existence =
return false;
}

return fs_apply_filter(
$this->_module_unique_affix,
'is_submenu_visible',
$this->get_bool_option( $this->_default_submenu_items, $id, $default )
);
}
return fs_apply_filter( $this->_module_unique_affix, 'is_submenu_visible', $this->get_bool_option( $this->_default_submenu_items, $id, $default ), $id ); // @phpstan-ignore-line
}

/**
* Calculates admin settings menu slug.
Expand Down
2 changes: 1 addition & 1 deletion templates/account.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@

$site_view_params[] = $view_params;

if ( empty( $install ) ) {
if ( null === $install ) {
continue;
}

Expand Down

0 comments on commit b3bd9e0

Please sign in to comment.