diff --git a/includes/class-freemius.php b/includes/class-freemius.php index c4b67e44..354d016b 100755 --- a/includes/class-freemius.php +++ b/includes/class-freemius.php @@ -1003,7 +1003,7 @@ private static function migrate_install_plan_to_plan_id( FS_Storage $storage, $b if ( isset( $install->plan ) && is_object( $install->plan ) ) { if ( isset( $install->plan->id ) && ! empty( $install->plan->id ) ) { - $install->plan_id = self::_decrypt( $install->plan->id ); // @phpstan-ignore-line + $install->plan_id = self::_decrypt( $install->plan->id ); } unset( $install->plan ); @@ -1564,8 +1564,8 @@ private function register_constructor_hooks() { ); $this->add_filter( 'after_code_type_change', array( &$this, '_after_code_type_change' ) ); - add_action( 'admin_init', array( &$this, '_add_trial_notice' ) ); // @phpstan-ignore-line - add_action( 'admin_init', array( &$this, '_add_affiliate_program_notice' ) ); // @phpstan-ignore-line + add_action( 'admin_init', array( &$this, '_add_trial_notice' ) ); + add_action( 'admin_init', array( &$this, '_add_affiliate_program_notice' ) ); add_action( 'admin_enqueue_scripts', array( &$this, '_enqueue_common_css' ) ); /** @@ -1882,7 +1882,7 @@ private function clear_module_main_file_cache( $store_prev_path = true ) { $plugin_main_file = clone $this->_storage->plugin_main_file; // Store cached path (2nd layer cache). - $plugin_main_file->prev_path = $plugin_main_file->path; // @phpstan-ignore-line + $plugin_main_file->prev_path = $plugin_main_file->path; // Clear cached path. unset( $plugin_main_file->path ); @@ -8016,7 +8016,6 @@ 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 ); } @@ -8955,7 +8954,7 @@ private function update_plugin_version_event() { * @author Vova Feldman (@svovaf) * @since 2.0.0 * - * @param string[] $plugins + * @param array $plugins * * @return string */ @@ -14101,7 +14100,7 @@ private function activate_license( $result = $fs->activate_license_on_many_installs( $user, $license_key, $blog_2_install_map ); } - if ( true === $result && count( $site_ids ) > 0 ) { + if ( true === $result && ! empty( $site_ids ) > 0 ) { $result = $fs->activate_license_on_many_sites( $user, $license_key, $site_ids ); } } else { @@ -19923,7 +19922,7 @@ private function _store_site( $store = true, $network_level_or_blog_id = null, F $site = $this->_site; } - if ( !is_object($site) || empty( $site->id ) ) { + if ( ! is_object( $site ) || empty( $site->id ) ) { $this->_logger->error( "Empty install ID, can't store site." ); return; @@ -20057,7 +20056,7 @@ private function _store_licenses( $store = true, $module_id = false, $licenses = } } - if ( count( $new_user_licenses_map ) > 0 ) { + if ( ! empty( $new_user_licenses_map ) ) { // Add new licenses. $all_licenses[ $module_id ] = array_merge( array_values( $new_user_licenses_map ), $all_licenses[ $module_id ] ); } diff --git a/includes/class-fs-plugin-updater.php b/includes/class-fs-plugin-updater.php index 4e14c6b7..30027707 100755 --- a/includes/class-fs-plugin-updater.php +++ b/includes/class-fs-plugin-updater.php @@ -499,7 +499,6 @@ 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' ) ) { @@ -1049,7 +1048,7 @@ function plugins_api_filter( $data, $action = '', $args = null ) { false ); - if ( is_array( $addon_plugin_data ) && isset( $addon_plugin_data['Version'] ) ) { + if ( ! empty( $addon_plugin_data['Version'] ) ) { $addon_version = $addon_plugin_data['Version']; } } @@ -1070,9 +1069,11 @@ function plugins_api_filter( $data, $action = '', $args = null ) { // Fetch as much as possible info from local files. $plugin_local_data = $this->_fs->get_plugin_data(); - $data->name = $plugin_local_data['Name']; // @phpstan-ignore-line - $data->author = $plugin_local_data['Author']; // @phpstan-ignore-line - $data->sections = array( 'description' => 'Upgrade ' . $plugin_local_data['Name'] . ' to latest.' ); // @phpstan-ignore-line + $data->name = $plugin_local_data['Name']; + $data->author = $plugin_local_data['Author']; + $data->sections = array( + 'description' => 'Upgrade ' . $plugin_local_data['Name'] . ' to latest.' + ); // @todo Store extra plugin info on Freemius or parse readme.txt markup. /*$info = $this->_fs->get_api_site_scope()->call('/information.json'); @@ -1096,18 +1097,18 @@ function plugins_api_filter( $data, $action = '', $args = null ) { $data->name = $addon->title . ' ' . $this->_fs->get_text_inline( 'Add-On', 'addon' ); $data->slug = $addon->slug; $data->url = WP_FS__ADDRESS; - $data->package = $new_version->url; // @phpstan-ignore-line + $data->package = $new_version->url; } if ( ! $plugin_in_repo ) { - $data->last_updated = ! is_null( $new_version->updated ) ? $new_version->updated : $new_version->created; // @phpstan-ignore-line - $data->requires = $new_version->requires_platform_version; // @phpstan-ignore-line - $data->requires_php = $new_version->requires_programming_language_version; // @phpstan-ignore-line - $data->tested = $new_version->tested_up_to_version; // @phpstan-ignore-line + $data->last_updated = ! is_null( $new_version->updated ) ? $new_version->updated : $new_version->created; + $data->requires = $new_version->requires_platform_version; + $data->requires_php = $new_version->requires_programming_language_version; + $data->tested = $new_version->tested_up_to_version; } $data->version = $new_version->version; - $data->download_link = $new_version->url; // @phpstan-ignore-line + $data->download_link = $new_version->url; if ( isset( $new_version->readme ) && is_object( $new_version->readme ) ) { $new_version_readme_data = $new_version->readme; diff --git a/includes/entities/class-fs-entity.php b/includes/entities/class-fs-entity.php index 735cbb02..7558ff3e 100755 --- a/includes/entities/class-fs-entity.php +++ b/includes/entities/class-fs-entity.php @@ -88,8 +88,8 @@ static function equals( $entity1, $entity2 ) { * @author Vova Feldman (@svovaf) * @since 1.0.9 * - * @param array|string[] $key - * @param string|bool $val + * @param string|array $key + * @param string|bool $val * * @return bool */ @@ -156,4 +156,4 @@ static function is_valid_id($id){ public static function get_class_name() { return get_called_class(); } - } \ No newline at end of file + } diff --git a/includes/fs-core-functions.php b/includes/fs-core-functions.php index 283953fb..83b36e82 100755 --- a/includes/fs-core-functions.php +++ b/includes/fs-core-functions.php @@ -1389,8 +1389,8 @@ function fs_esc_html_echo_inline( $text, $key = '', $slug = 'freemius' ) { * @author Vova Feldman (@svovaf) * @since 1.1.6 * - * @param array|string[] $key_value - * @param string $slug + * @param array $key_value + * @param string $slug * * @global $fs_text_overrides */ diff --git a/includes/fs-essential-functions.php b/includes/fs-essential-functions.php index b9f7301e..189660d6 100644 --- a/includes/fs-essential-functions.php +++ b/includes/fs-essential-functions.php @@ -264,7 +264,7 @@ function fs_update_sdk_newest_version( $sdk_relative_path, $plugin_file = false $in_activation = ( ! is_plugin_active( $plugin_file ) ); } else { $theme = wp_get_theme(); - $in_activation = ( $newest_sdk->plugin_path == $theme->stylesheet ); // @phpstan-ignore-line + $in_activation = ( $newest_sdk->plugin_path == $theme->stylesheet ); } $fs_active_plugins->newest = (object) array( @@ -415,4 +415,4 @@ function fs_fallback_to_newest_active_sdk() { fs_update_sdk_newest_version( $newest_sdk_path, $newest_sdk_data->plugin_path ); } } - } \ No newline at end of file + } diff --git a/includes/fs-plugin-info-dialog.php b/includes/fs-plugin-info-dialog.php index a57d348a..fe562eee 100755 --- a/includes/fs-plugin-info-dialog.php +++ b/includes/fs-plugin-info-dialog.php @@ -229,7 +229,7 @@ function _get_addon_info_filter( $data, $action = '', $args = null ) { false ); - if ( is_array( $addon_plugin_data ) && isset( $addon_plugin_data['Version'] ) ) { + if ( ! empty( $addon_plugin_data['Version'] ) ) { $current_addon_version = $addon_plugin_data['Version']; } } @@ -527,7 +527,7 @@ private function get_checkout_cta( $api, $plan = null ) { $plan->plugin_id, $plan->pricing[0]->id, $this->get_billing_cycle( $plan ), - $plan->has_trial(), // @phpstan-ignore-line + $plan->has_trial(), ( $has_valid_blog_id ? false : null ) ); @@ -536,7 +536,7 @@ private function get_checkout_cta( $api, $plan = null ) { } return '' . - esc_html( ! $plan->has_trial() ? // @phpstan-ignore-line + esc_html( ! $plan->has_trial() ? ( $api->has_purchased_license ? fs_text_inline( 'Purchase More', 'purchase-more', $api->slug ) : diff --git a/includes/managers/class-fs-admin-menu-manager.php b/includes/managers/class-fs-admin-menu-manager.php index 904cf3df..e01a5709 100644 --- a/includes/managers/class-fs-admin-menu-manager.php +++ b/includes/managers/class-fs-admin-menu-manager.php @@ -1004,4 +1004,4 @@ function add_subpage_and_update( $function ); } - } \ No newline at end of file + } diff --git a/includes/managers/class-fs-cache-manager.php b/includes/managers/class-fs-cache-manager.php index 0bde407b..78edd8c8 100755 --- a/includes/managers/class-fs-cache-manager.php +++ b/includes/managers/class-fs-cache-manager.php @@ -166,8 +166,7 @@ function get( $key, $default = null ) { isset( $cache_entry->timestamp ) && is_numeric( $cache_entry->timestamp ) ) { - return $cache_entry->result; // @phpstan-ignore-line - + return $cache_entry->result; } return is_object( $default ) ? clone $default : $default; @@ -324,4 +323,4 @@ function migrate_to_network() { } #endregion - } \ No newline at end of file + } diff --git a/phpstan.neon b/phpstan.neon index 2063c9e1..9a920c25 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,21 +10,36 @@ parameters: - .phpstan/exceptions.php ignoreErrors: - - message: '#PHPDoc tag @var has invalid value#' - path: includes/managers/class-fs-plugin-manager.php - - - message: '#PHPDoc tag @use has invalid value#' - path: includes/class-freemius.php - - - message: '#PHPDoc tag @var above a method has no effect.#' + messages: + - '#PHPDoc tag @use has invalid value#' + - '#PHPDoc tag @var above a method has no effect.#' + - '#Action callback returns bool but should not return anything.#' + - '#Variable \$site_ids in empty\(\) always exists and is always falsy.#' + - '#Variable \$new_user_licenses_map in empty\(\) always exists and is not falsy.#' + - '#Cannot access property \$installs#' path: includes/class-freemius.php - message: '#Access to an undefined property#' paths: + - start.php + - templates/debug.php + - templates/add-ons.php + - templates/plugin-info/features.php - includes/class-freemius.php - includes/fs-plugin-info-dialog.php + - includes/fs-essential-functions.php + - includes/class-fs-plugin-updater.php + - includes/managers/class-fs-cache-manager.php + - + message: '#Call to an undefined method object::has_trial\(\)#' + path: includes/fs-plugin-info-dialog.php + - + message: '#PHPDoc tag @var has invalid value#' + path: includes/managers/class-fs-plugin-manager.php - - message: '#will always evaluate to true#' + messages: + - '#Variable \$transient_data in empty\(\) always exists and is not falsy.#' + - '#will always evaluate to true#' path: includes/class-fs-plugin-updater.php - message: '#Variable \$VARS might not be defined#' diff --git a/templates/account.php b/templates/account.php index bc6f83e1..2f98236f 100755 --- a/templates/account.php +++ b/templates/account.php @@ -96,14 +96,13 @@ ) ); } + $payments = []; $show_billing = ( ! $is_whitelabeled && ! $fs->apply_filters( 'hide_billing_and_payments_info', false ) ); if ( $show_billing ) { - $payments = $fs->_fetch_payments(); - - $show_billing = ( is_array( $payments ) && 0 < count( $payments ) ); + $payments = $fs->_fetch_payments(); + $show_billing = ( 0 < count( $payments ) ); } - $has_tabs = $fs->_add_tabs_before_content(); // Aliases. @@ -137,8 +136,7 @@ $show_plan_row = true; $show_license_row = is_object( $license ); - - $site_view_params = array(); + $site_view_params = array(); if ( fs_is_network_admin() ) { $sites = Freemius::get_sites(); @@ -157,7 +155,7 @@ $site_view_params[] = $view_params; - if ( is_object( $install ) ) { + if ( ! is_object( $install ) ) { continue; } @@ -871,7 +869,7 @@ class="fs-tag fs-can_use_premium_code() ? 'success' : 'warn' ?>" $VARS['id'], 'payments' => $payments ); // @phpstan-ignore-line + $view_params = array( 'id' => $VARS['id'], 'payments' => $payments ); fs_require_once_template( 'account/billing.php', $view_params ); fs_require_once_template( 'account/payments.php', $view_params ); } diff --git a/templates/account/partials/addon.php b/templates/account/partials/addon.php index bba624da..f7fa1c62 100644 --- a/templates/account/partials/addon.php +++ b/templates/account/partials/addon.php @@ -67,6 +67,10 @@ $show_upgrade = false; $is_whitelabeled = $VARS['is_whitelabeled']; + $version = ''; + $plan_name = ''; + $plan_title = ''; + if ( is_object( $fs_addon ) ) { $is_paying = $fs_addon->is_paying(); $user = $fs_addon->get_user(); @@ -158,11 +162,11 @@ - + - + diff --git a/templates/add-ons.php b/templates/add-ons.php index 4f8b031f..f22ef3dd 100755 --- a/templates/add-ons.php +++ b/templates/add-ons.php @@ -142,12 +142,8 @@ } $has_paid_plan = true; - - if ( isset( $plan->trial_period ) ) { - $has_trial = ( is_numeric( $plan->trial_period ) && ( $plan->trial_period > 0 ) ); - } - - $min_price = 999999; + $has_trial = isset( $plan->trial_period ) && is_numeric( $plan->trial_period ) && $plan->trial_period > 0; + $min_price = 999999; foreach ( $plan->pricing as $pricing ) { $pricing = new FS_Pricing( $pricing ); @@ -501,4 +497,4 @@ function toggleDropdown( $dropdown, state ) { 'module_slug' => $slug, 'module_version' => $fs->get_plugin_version(), ); - fs_require_template( 'powered-by.php', $params ); \ No newline at end of file + fs_require_template( 'powered-by.php', $params ); diff --git a/templates/debug.php b/templates/debug.php index 4623d935..99509402 100644 --- a/templates/debug.php +++ b/templates/debug.php @@ -300,21 +300,18 @@ $has_api_connectivity = false; if ( $is_active ) { - $fs = freemius( $data->id ); - $has_api_connectivity = $fs->has_api_connectivity(); - + $fs = freemius( $data->id ); $active_modules_by_id[ $data->id ] = true; } ?> - has_api_connectivity(); if ( true === $has_api_connectivity && $fs->is_on() ) { - echo 'style="background: #E6FFE6; font-weight: bold"'; + echo ' style="background: #E6FFE6; font-weight: bold"'; } else { - echo 'style="background: #ffd0d0; font-weight: bold"'; + echo ' style="background: #ffd0d0; font-weight: bold"'; } - } - ?>> + } ?>> id ?> version ?> diff --git a/templates/plugin-info/features.php b/templates/plugin-info/features.php index 8f316ccb..60d3db58 100644 --- a/templates/plugin-info/features.php +++ b/templates/plugin-info/features.php @@ -27,9 +27,7 @@ $features_plan_map[ $feature->id ] = array( 'feature' => $feature, 'plans' => array() ); } - if ( ! empty( $plan->id ) ) { - $features_plan_map[ $feature->id ]['plans'][ $plan->id ] = $feature; - } + $features_plan_map[ $feature->id ]['plans'][ $plan->id ] = $feature; } } @@ -113,4 +111,4 @@ - \ No newline at end of file +