Skip to content

Commit f524ed8

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

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
@@ -8019,6 +8019,7 @@ private function maybe_network_activate_addon_license( $license = null ) {
80198019
}
80208020
}
80218021

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

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

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

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

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

1991119912
return;
@@ -20039,7 +20040,7 @@ private function _store_licenses( $store = true, $module_id = false, $licenses =
2003920040
}
2004020041
}
2004120042

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

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)