Skip to content

Commit b3bd9e0

Browse files
committed
[static-analysis] Fix truthy/false statements.
1 parent df78061 commit b3bd9e0

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

includes/class-freemius.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8020,6 +8020,7 @@ private function maybe_network_activate_addon_license( $license = null ) {
80208020
}
80218021
}
80228022

8023+
// @phpstan-ignore-next-line
80238024
if ( ! empty( $site_ids ) ) {
80248025
$this->activate_license_on_many_sites( $user, $license->secret_key, $site_ids );
80258026
}
@@ -8515,7 +8516,7 @@ function _deactivate_plugin_hook() {
85158516
unset( $this->_storage->sticky_optin_added_ms );
85168517
}
85178518

8518-
if ( ! empty( $storage_keys_for_removal ) ) {
8519+
if ( count( $storage_keys_for_removal ) > 0 ) {
85198520
$sites = self::get_sites();
85208521

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

14096-
if ( true === $result && ! empty( $site_ids ) ) {
14097+
if ( true === $result && count( $site_ids ) > 0 ) {
1409714098
$result = $fs->activate_license_on_many_sites( $user, $license_key, $site_ids );
1409814099
}
1409914100
} else {
@@ -19906,7 +19907,7 @@ private function _store_site( $store = true, $network_level_or_blog_id = null, F
1990619907
$site = $this->_site;
1990719908
}
1990819909

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

1991219913
return;
@@ -20040,7 +20041,7 @@ private function _store_licenses( $store = true, $module_id = false, $licenses =
2004020041
}
2004120042
}
2004220043

20043-
if ( ! empty( $new_user_licenses_map ) ) {
20044+
if ( count( $new_user_licenses_map ) > 0 ) {
2004420045
// Add new licenses.
2004520046
$all_licenses[ $module_id ] = array_merge( array_values( $new_user_licenses_map ), $all_licenses[ $module_id ] );
2004620047
}

includes/class-fs-plugin-updater.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ function pre_set_site_transient_update_plugins_filter( $transient_data ) {
497497
return $transient_data;
498498
}
499499

500+
// @phpstan-ignore-next-line
500501
if ( empty( $transient_data ) ||
501502
defined( 'WP_FS__UNINSTALL_MODE' )
502503
) {
@@ -1046,7 +1047,7 @@ function plugins_api_filter( $data, $action = '', $args = null ) {
10461047
false
10471048
);
10481049

1049-
if ( ! empty( $addon_plugin_data ) ) {
1050+
if ( is_array( $addon_plugin_data ) && $addon_plugin_data['Version'] ) {
10501051
$addon_version = $addon_plugin_data['Version'];
10511052
}
10521053
}

includes/fs-plugin-info-dialog.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ function _get_addon_info_filter( $data, $action = '', $args = null ) {
229229
false
230230
);
231231

232-
if ( ! empty( $addon_plugin_data ) ) {
232+
if ( is_array( $addon_plugin_data ) && $addon_plugin_data['Version'] ) {
233233
$current_addon_version = $addon_plugin_data['Version'];
234234
}
235235
}

includes/managers/class-fs-admin-menu-manager.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private function get_bool_option( &$options, $key, $default = false ) {
154154
* @param bool $is_addon
155155
*/
156156
function init( $menu, $is_addon = false ) {
157-
$this->_menu_exists = ( isset( $menu['slug'] ) && ! empty( $menu['slug'] ) );
157+
$this->_menu_exists = ( ! empty( $menu['slug'] ) );
158158
$this->_network_menu_exists = ( ! empty( $menu['network'] ) && true === $menu['network'] );
159159

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

171-
if ( isset( $menu ) ) {
171+
if ( is_array( $menu ) ) {
172172
if ( ! $is_addon ) {
173173
$this->_default_submenu_items = array(
174174
'contact' => $this->get_bool_option( $menu, 'contact', true ),
@@ -318,12 +318,8 @@ function is_submenu_item_visible( $id, $default = true, $ignore_menu_existence =
318318
return false;
319319
}
320320

321-
return fs_apply_filter(
322-
$this->_module_unique_affix,
323-
'is_submenu_visible',
324-
$this->get_bool_option( $this->_default_submenu_items, $id, $default )
325-
);
326-
}
321+
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
322+
}
327323

328324
/**
329325
* Calculates admin settings menu slug.

templates/account.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157

158158
$site_view_params[] = $view_params;
159159

160-
if ( empty( $install ) ) {
160+
if ( null === $install ) {
161161
continue;
162162
}
163163

0 commit comments

Comments
 (0)