Skip to content

Commit fe0f7a7

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

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
@@ -7681,6 +7681,7 @@ private function maybe_network_activate_addon_license( $license = null ) {
76817681
}
76827682
}
76837683

7684+
// @phpstan-ignore-next-line
76847685
if ( ! empty( $site_ids ) ) {
76857686
$this->activate_license_on_many_sites( $user, $license->secret_key, $site_ids );
76867687
}
@@ -8176,7 +8177,7 @@ function _deactivate_plugin_hook() {
81768177
unset( $this->_storage->sticky_optin_added_ms );
81778178
}
81788179

8179-
if ( ! empty( $storage_keys_for_removal ) ) {
8180+
if ( count( $storage_keys_for_removal ) > 0 ) {
81808181
$sites = self::get_sites();
81818182

81828183
foreach ( $sites as $site ) {
@@ -13746,7 +13747,7 @@ private function activate_license(
1374613747
$result = $fs->activate_license_on_many_installs( $user, $license_key, $blog_2_install_map );
1374713748
}
1374813749

13749-
if ( true === $result && ! empty( $site_ids ) ) {
13750+
if ( true === $result && count( $site_ids ) > 0 ) {
1375013751
$result = $fs->activate_license_on_many_sites( $user, $license_key, $site_ids );
1375113752
}
1375213753
} else {
@@ -19601,7 +19602,7 @@ private function _store_site( $store = true, $network_level_or_blog_id = null, F
1960119602
$site = $this->_site;
1960219603
}
1960319604

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

1960719608
return;
@@ -19735,7 +19736,7 @@ private function _store_licenses( $store = true, $module_id = false, $licenses =
1973519736
}
1973619737
}
1973719738

19738-
if ( ! empty( $new_user_licenses_map ) ) {
19739+
if ( count( $new_user_licenses_map ) > 0 ) {
1973919740
// Add new licenses.
1974019741
$all_licenses[ $module_id ] = array_merge( array_values( $new_user_licenses_map ), $all_licenses[ $module_id ] );
1974119742
}

includes/class-fs-plugin-updater.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ function pre_set_site_transient_update_plugins_filter( $transient_data ) {
534534
return $transient_data;
535535
}
536536

537+
// @phpstan-ignore-next-line
537538
if ( empty( $transient_data ) ||
538539
defined( 'WP_FS__UNINSTALL_MODE' )
539540
) {
@@ -1093,7 +1094,7 @@ function plugins_api_filter( $data, $action = '', $args = null ) {
10931094
false
10941095
);
10951096

1096-
if ( ! empty( $addon_plugin_data ) ) {
1097+
if ( is_array( $addon_plugin_data ) && $addon_plugin_data['Version'] ) {
10971098
$addon_version = $addon_plugin_data['Version'];
10981099
}
10991100
}

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)