diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index ced0ea1..d2844f5 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -39,7 +39,7 @@ jobs: run: npm run build phpcs: - name: PHPCS + name: PHPCS and PHPStan runs-on: ubuntu-latest steps: @@ -69,3 +69,6 @@ jobs: - name: Run PHPCS run: composer phpcs + + - name: Run PHPStan + run: vendor/bin/phpstan analyse --error-format=github --memory-limit=1G diff --git a/composer.json b/composer.json index 3256ee2..4b8892d 100644 --- a/composer.json +++ b/composer.json @@ -12,8 +12,12 @@ "prefer-stable": true, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "php-stubs/woocommerce-stubs": "^3.0", + "php-stubs/wordpress-stubs": "^6.0", "phpcompatibility/phpcompatibility-wp": "^2.1", + "phpstan/phpstan": "^2.0", "squizlabs/php_codesniffer": "^3.7", + "szepeviktor/phpstan-wordpress": "^2.0", "wp-coding-standards/wpcs": "^3.0" }, "config": { @@ -30,6 +34,10 @@ "scripts": { "phpcs": "vendor/bin/phpcs", "phpcbf": "vendor/bin/phpcbf", - "lint": "@phpcs" + "phpstan": "php -d memory_limit=1G vendor/bin/phpstan analyse --memory-limit=1G", + "lint": [ + "@phpcs", + "@phpstan" + ] } } diff --git a/composer.lock b/composer.lock index f50f407..f2920c0 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": "38ca719cf177f1b476473798eccdc613", + "content-hash": "d4e246de27646b0d637e8ff3982d2952", "packages": [], "packages-dev": [ { @@ -103,6 +103,112 @@ ], "time": "2026-05-06T08:26:05+00:00" }, + { + "name": "php-stubs/woocommerce-stubs", + "version": "v3.8.0", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/woocommerce-stubs.git", + "reference": "74583d44d4510c431dd548190bfdbd7592aab57e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/woocommerce-stubs/zipball/74583d44d4510c431dd548190bfdbd7592aab57e", + "reference": "74583d44d4510c431dd548190bfdbd7592aab57e", + "shasum": "" + }, + "require-dev": { + "ext-gettext": "*", + "ext-hash": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "giacocorsiglia/stubs-generator": "^0.5.0", + "php": "~7.1", + "woocommerce/woocommerce": "3.8.0" + }, + "suggest": { + "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "extra": { + "installer-paths": { + "{$name}/": [ + "type:wordpress-plugin" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WooCommerce function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/woocommerce-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "woocommerce", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/woocommerce-stubs/issues", + "source": "https://github.com/php-stubs/woocommerce-stubs/tree/v3.8.0" + }, + "time": "2019-11-21T22:17:45+00:00" + }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v6.9.4", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "90a9412826b9944f93b10bf41d795b5fe68abcd5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/90a9412826b9944f93b10bf41d795b5fe68abcd5", + "reference": "90a9412826b9944f93b10bf41d795b5fe68abcd5", + "shasum": "" + }, + "conflict": { + "phpdocumentor/reflection-docblock": "5.6.1" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "nikic/php-parser": "^5.5", + "php": "^7.4 || ^8.0", + "php-stubs/generator": "^0.8.6", + "phpdocumentor/reflection-docblock": "^6.0", + "phpstan/phpstan": "^2.1", + "phpunit/phpunit": "^9.5", + "symfony/polyfill-php80": "*", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.1.1", + "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" + }, + "suggest": { + "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "symfony/polyfill-php80": "Symfony polyfill backporting some PHP 8.0+ 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.9.4" + }, + "time": "2026-05-01T20:36:01+00:00" + }, { "name": "phpcompatibility/php-compatibility", "version": "9.3.5", @@ -491,6 +597,70 @@ ], "time": "2026-07-27T10:28:41+00:00" }, + { + "name": "phpstan/phpstan", + "version": "2.2.14", + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9c672e7a8e791dfc3d30e55f683e73fc0b63a3ac", + "reference": "9c672e7a8e791dfc3d30e55f683e73fc0b63a3ac", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ondřej Mirtes" + }, + { + "name": "Markus Staab" + }, + { + "name": "Vincent Langlet" + } + ], + "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" + } + ], + "time": "2026-09-12T21:39:33+00:00" + }, { "name": "squizlabs/php_codesniffer", "version": "3.13.6", @@ -570,6 +740,69 @@ ], "time": "2026-08-06T00:17:32+00:00" }, + { + "name": "szepeviktor/phpstan-wordpress", + "version": "v2.0.4", + "source": { + "type": "git", + "url": "https://github.com/szepeviktor/phpstan-wordpress.git", + "reference": "84577e2ea1e4c2a95537fe5ea2ac8e18f4ceab1a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/84577e2ea1e4c2a95537fe5ea2ac8e18f4ceab1a", + "reference": "84577e2ea1e4c2a95537fe5ea2ac8e18f4ceab1a", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "php-stubs/wordpress-stubs": ">=6.6.2", + "phpstan/phpstan": "^2.0" + }, + "require-dev": { + "composer/composer": "^2.1.14", + "composer/semver": "^3.4", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.0", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.0", + "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" + }, + "suggest": { + "swissspidy/phpstan-no-private": "Detect usage of internal core functions, classes and methods" + }, + "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/v2.0.4" + }, + "time": "2026-05-22T16:22:09+00:00" + }, { "name": "wp-coding-standards/wpcs", "version": "3.4.1", diff --git a/includes/Admin/Admin_Settings.php b/includes/Admin/Admin_Settings.php index 22c0661..55509ed 100644 --- a/includes/Admin/Admin_Settings.php +++ b/includes/Admin/Admin_Settings.php @@ -24,7 +24,7 @@ class Admin_Settings { public function __construct() { // For the admin interface. add_action( 'admin_menu', array( $this, 'register_settings_menu' ) ); - add_action( 'plugin_action_links_' . Functions::get_plugin_path(), array( $this, 'plugin_settings_link' ) ); + add_filter( 'plugin_action_links_' . Functions::get_plugin_path(), array( $this, 'plugin_settings_link' ) ); // init tabs here. new Tabs\Settings(); @@ -93,7 +93,7 @@ public static function get_settings_tabs() { $tabs = apply_filters( 'sce_admin_tabs', $tabs ); $tab_html = '