diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index b43adabac..000000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,19 +0,0 @@ -engines: - phpcodesniffer: - enabled: true - config: - standard: "WordPress" - checks: - Squiz Commenting InlineComment InvalidEndChar: - enabled: false - Squiz Commenting InlineComment SpacingBefore: - enabled: false - Squiz Commenting InlineComment WrongStyle: - enabled: false - Generic Commenting DocComment MissingShort: - enabled: false - Generic WhiteSpace ScopeIndent IncorrectExact: - enabled: false -ratings: - paths: - - "**.php" diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..f0601d05a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*.yml] +indent_style = space +indent_size = 2 + +[*.neon] +indent_style = space +indent_size = 4 \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index 7d36e03a2..35b457499 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11,6 +11,7 @@ composer.lock export-ignore /assets/scss/ export-ignore *.css.map export-ignore phpcs.xml export-ignore +.phpstan export-ignore # Declare files that will always have CRLF line endings on checkout. #*.php text eol=crlf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..976c868a7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,46 @@ +# Run CI tests via Github. +name: PHPCS and Static Analysis. + +on: + pull_request: + branches: + - develop + - master + +jobs: + run: + runs-on: ubuntu-latest + name: PHPCS + continue-on-error: ${{ matrix.experimental }} + strategy: + fail-fast: false + matrix: + php: [ '7.4', '8.0', '8.1', '8.2' ] + experimental: [false] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer + coverage: none + + - name: Install dependencies + uses: ramsey/composer-install@v2 + with: + composer-options: "--no-progress --no-ansi --no-interaction" + dependency-versions: "lowest" + + - name: Log debug information + run: | + php --version + composer --version + - name: PHP Static Analysis + run: composer phpstan + + - name: Run PHPCS + run: composer phpcs:ci \ No newline at end of file diff --git a/.gitignore b/.gitignore index f7d038b5c..ca4867b2a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ transifex-config.json npm-debug.log package-lock.json vendor -.DS_Store \ No newline at end of file +.DS_Store +error-phpstan.xml +error-phpcs.log \ No newline at end of file diff --git a/.phpstan/exceptions.php b/.phpstan/exceptions.php new file mode 100644 index 000000000..ece8bee73 --- /dev/null +++ b/.phpstan/exceptions.php @@ -0,0 +1,16 @@ + error-phpstan.xml" }, "require": { - "php": ">=5.2" - }, + "php": ">=5.6" + }, "require-dev": { "wp-coding-standards/wpcs": "^2.3", - "dealerdirect/phpcodesniffer-composer-installer": "^1.0" + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "squizlabs/php_codesniffer": "^3.7", + "phpcompatibility/php-compatibility": "^9.3", + "phpcompatibility/phpcompatibility-wp": "^2.1", + "szepeviktor/phpstan-wordpress": "^1.3", + "phpstan/extension-installer": "^1.3" }, + "prefer-stable": true, "config": { "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "phpstan/extension-installer": true + }, + "platform": { + "php": "8.0" } } } diff --git a/composer.lock b/composer.lock index f8c81a473..9ab44c6a8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0fa573ee1c13c3c5edd8c3b82b81eb4a", + "content-hash": "99f0f4dafbc26759cd76806c8416581e", "packages": [], "packages-dev": [ { @@ -85,6 +85,331 @@ }, "time": "2023-01-05T11:28:13+00:00" }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v6.2.1", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "0009429e639b748eef1c955200ea0d4e5ad5627d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/0009429e639b748eef1c955200ea0d4e5ad5627d", + "reference": "0009429e639b748eef1c955200ea0d4e5ad5627d", + "shasum": "" + }, + "require-dev": { + "nikic/php-parser": "< 4.12.0", + "php": "~7.3 || ~8.0", + "php-stubs/generator": "^0.8.3", + "phpdocumentor/reflection-docblock": "^5.3", + "phpstan/phpstan": "^1.10.12", + "phpunit/phpunit": "^9.5" + }, + "suggest": { + "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.2.1" + }, + "time": "2023-05-18T04:35:23+00:00" + }, + { + "name": "phpcompatibility/php-compatibility", + "version": "9.3.5", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibility" + }, + "time": "2019-12-27T09:44:58+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-paragonie", + "version": "1.3.2", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", + "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", + "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "paragonie/random_compat": "dev-master", + "paragonie/sodium_compat": "dev-master" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "paragonie", + "phpcs", + "polyfill", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" + }, + "time": "2022-10-25T01:46:02+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-wp", + "version": "2.1.4", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", + "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", + "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0", + "phpcompatibility/phpcompatibility-paragonie": "^1.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "phpcs", + "standards", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" + }, + "time": "2022-10-24T09:00:36+00:00" + }, + { + "name": "phpstan/extension-installer", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "f45734bfb9984c6c56c4486b71230355f066a58a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f45734bfb9984c6c56c4486b71230355f066a58a", + "reference": "f45734bfb9984c6c56c4486b71230355f066a58a", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.3.1" + }, + "time": "2023-05-24T08:59:17+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.10.25", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "578f4e70d117f9a90699324c555922800ac38d8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/578f4e70d117f9a90699324c555922800ac38d8c", + "reference": "578f4e70d117f9a90699324c555922800ac38d8c", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2023-07-06T12:11:37+00:00" + }, { "name": "squizlabs/php_codesniffer", "version": "3.7.2", @@ -142,6 +467,144 @@ }, "time": "2023-02-22T23:07:41+00:00" }, + { + "name": "symfony/polyfill-php73", + "version": "v1.27.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/9e8ecb5f92152187c4799efd3c96b78ccab18ff9", + "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.27-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.27.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-11-03T14:55:06+00:00" + }, + { + "name": "szepeviktor/phpstan-wordpress", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/szepeviktor/phpstan-wordpress.git", + "reference": "5b5cc77ed51fdaf64efe3f00b5aae4b709d2cfa9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/5b5cc77ed51fdaf64efe3f00b5aae4b709d2cfa9", + "reference": "5b5cc77ed51fdaf64efe3f00b5aae4b709d2cfa9", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0", + "phpstan/phpstan": "^1.10.0", + "symfony/polyfill-php73": "^1.12.0" + }, + "require-dev": { + "composer/composer": "^2.1.14", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpstan/phpstan-strict-rules": "^1.2", + "phpunit/phpunit": "^8.0 || ^9.0", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "SzepeViktor\\PHPStan\\WordPress\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress extensions for PHPStan", + "keywords": [ + "PHPStan", + "code analyse", + "code analysis", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", + "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.3.0" + }, + "time": "2023-04-23T06:15:06+00:00" + }, { "name": "wp-coding-standards/wpcs", "version": "2.3.0", @@ -197,11 +660,14 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": [], - "prefer-stable": false, + "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": ">=5.2" + "php": ">=5.6" }, "platform-dev": [], + "platform-overrides": { + "php": "8.0" + }, "plugin-api-version": "2.3.0" } diff --git a/includes/class-freemius.php b/includes/class-freemius.php index 2df11a9bc..efe97079b 100755 --- a/includes/class-freemius.php +++ b/includes/class-freemius.php @@ -1531,8 +1531,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' ) ); - add_action( 'admin_init', array( &$this, '_add_affiliate_program_notice' ) ); + 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_enqueue_scripts', array( &$this, '_enqueue_common_css' ) ); /** @@ -1642,7 +1642,7 @@ static function _remove_fs_updates_from_plugin_install_page( $updates, $transien * @author Leo Fajardo (@leorw) * @since 2.2.3 * - * @return string + * @return void */ static function _prepend_fs_allow_updater_and_dialog_flag_url_param() { $slug_basename_map = array(); @@ -4080,7 +4080,7 @@ private function should_turn_fs_on( $is_update = true ) { $max = 100; if ( function_exists( 'random_int' ) ) { - $random = random_int( $min, $max ); + $random = random_int( $min, $max ); // phpcs:ignore PHPCompatibility.FunctionUse.NewFunctions.random_intFound } else { $random = rand( $min, $max ); } @@ -4399,7 +4399,11 @@ static function is_valid_email( $email ) { } // Get the UTF encoded domain name. - $domain = idn_to_ascii( $parts[1] ) . '.'; + if ( version_compare( PHP_VERSION, '5.6.40') > 0 ) { + $domain = idn_to_ascii( $parts[1], IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46 ); + } else { + $domain = idn_to_ascii( $parts[1], IDNA_DEFAULT, INTL_IDNA_VARIANT_2003 ); // phpcs:ignore PHPCompatibility.Constants.RemovedConstants.intl_idna_variant_2003Deprecated + } return ( checkdnsrr( $domain, 'MX' ) || checkdnsrr( $domain, 'A' ) ); } @@ -9990,7 +9994,7 @@ function _uninstall_plugin_event( $check_user = true ) { * @param string $is_premium * @param string $caller * - * @return string + * @return void */ function set_basename( $is_premium, $caller ) { $basename = plugin_basename( $caller ); @@ -16697,7 +16701,7 @@ private static function decrypt_entity( FS_Entity $entity ) { * * @return FS_User|false */ - static function _get_user_by_email( $email ) { + public static function _get_user_by_email( $email ) { self::$_static_logger->entrance(); $email = trim( strtolower( $email ) ); @@ -17871,7 +17875,7 @@ private function install_with_new_user( * @param bool $trial_plan_id * @param bool $redirect * - * @return string If redirect is `false`, returns the next page the user should be redirected to. + * @return void */ private function install_many_pending_with_user( $user_id, @@ -23264,6 +23268,18 @@ private function _handle_account_edits() { } } + /** + * Adds CSS classes for the body tag in the admin. + * + * @param string $classes Space-separated string of class names. + * + * @return string $classes FS Admin body tag class names. + */ + public function fs_addons_body_class( $classes ) { + $classes .= ' plugins-php'; + return $classes; + } + /** * Account page resources load. * @@ -23280,14 +23296,7 @@ function _account_page_load() { if ( $this->has_addons() ) { wp_enqueue_script( 'plugin-install' ); add_thickbox(); - - function fs_addons_body_class( $classes ) { - $classes .= ' plugins-php'; - - return $classes; - } - - add_filter( 'admin_body_class', 'fs_addons_body_class' ); + add_filter( 'admin_body_class', array( $this, 'fs_addons_body_class' ) ); } if ( $this->has_paid_plan() && @@ -23422,14 +23431,7 @@ function _addons_page_load() { wp_enqueue_script( 'plugin-install' ); add_thickbox(); - - function fs_addons_body_class( $classes ) { - $classes .= ' plugins-php'; - - return $classes; - } - - add_filter( 'admin_body_class', 'fs_addons_body_class' ); + add_filter( 'admin_body_class', array( $this, 'fs_addons_body_class' ) ); if ( ! $this->is_registered() && $this->is_org_repo_compliant() ) { $this->_admin_notices->add( diff --git a/includes/debug/class-fs-debug-bar-panel.php b/includes/debug/class-fs-debug-bar-panel.php index 0b7969d08..c3255612a 100644 --- a/includes/debug/class-fs-debug-bar-panel.php +++ b/includes/debug/class-fs-debug-bar-panel.php @@ -10,55 +10,59 @@ exit; } - /** - * Extends Debug Bar plugin by adding a panel to show all Freemius API requests. - * - * @author Vova Feldman (@svovaf) - * @since 1.1.7.3 - * - * Class Freemius_Debug_Bar_Panel - */ - class Freemius_Debug_Bar_Panel extends Debug_Bar_Panel { - function init() { - $this->title( 'Freemius' ); - } + if ( class_exists( 'Debug_Bar_Panel' ) ) { - static function requests_count() { - if ( class_exists( 'Freemius_Api_WordPress' ) ) { - $logger = Freemius_Api_WordPress::GetLogger(); - } else { - $logger = array(); + /** + * Extends Debug Bar plugin by adding a panel to show all Freemius API requests. + * + * @author Vova Feldman (@svovaf) + * @since 1.1.7.3 + * + * Class Freemius_Debug_Bar_Panel + */ + class Freemius_Debug_Bar_Panel extends Debug_Bar_Panel { + + public function init() { + $this->title( 'Freemius' ); // @phpstan-ignore-line } - return number_format( count( $logger ) ); - } + public static function requests_count() { + if ( class_exists( 'Freemius_Api_WordPress' ) ) { + $logger = Freemius_Api_WordPress::GetLogger(); + } else { + $logger = array(); + } - static function total_time() { - if ( class_exists( 'Freemius_Api_WordPress' ) ) { - $logger = Freemius_Api_WordPress::GetLogger(); - } else { - $logger = array(); + return number_format( count( $logger ) ); } - $total_time = .0; - foreach ( $logger as $l ) { - $total_time += $l['total']; - } + public static function total_time() { + if ( class_exists( 'Freemius_Api_WordPress' ) ) { + $logger = Freemius_Api_WordPress::GetLogger(); + } else { + $logger = array(); + } - return number_format( 100 * $total_time, 2 ) . ' ' . fs_text_x_inline( 'ms', 'milliseconds' ); - } + $total_time = .0; + foreach ( $logger as $l ) { + $total_time += $l['total']; + } + + return number_format( 100 * $total_time, 2 ) . ' ' . fs_text_x_inline( 'ms', 'milliseconds' ); + } - function render() { - ?> -