From 4dc84ac6e4cc2db8b738f6e663f23f645e9937ab Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 5 Dec 2024 16:01:51 +0800 Subject: [PATCH 1/2] Run PHPStan 2.0 --- composer.json | 6 +++--- phpstan.neon.dist | 7 +++++++ phpstan.neon.example | 24 ++++++++++++------------ 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 0c9e490..2119290 100644 --- a/composer.json +++ b/composer.json @@ -17,9 +17,9 @@ "codeception/util-universalframework": "^1.0", "php-webdriver/webdriver": "^1.0", "wp-coding-standards/wpcs": "^3.0.0", - "phpstan/phpstan": "^1.7", - "szepeviktor/phpstan-wordpress": "^1.0", - "wp-cli/wp-cli": "2.8.1", + "phpstan/phpstan": "^1.0 || ^2.0", + "szepeviktor/phpstan-wordpress": "^1.0 || ^2.0", + "wp-cli/wp-cli": "2.11", "gumlet/php-image-resize": "^1.6" }, "minimum-stability": "dev", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index f9ffe68..d5e2022 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -21,6 +21,13 @@ parameters: scanDirectories: - /home/runner/work/convertkit-membermouse/convertkit-membermouse/wordpress/wp-content/plugins + # Location of constants for PHPStan to scan, building symbols. + scanFiles: + - /home/runner/work/convertkit-membermouse/convertkit-membermouse/wordpress/wp-config.php + + # Don't report unmatched ignored errors on older PHP versions (7.2, 7.3) + reportUnmatchedIgnoredErrors: false + # Should not need to edit anything below here # Rule Level: https://phpstan.org/user-guide/rule-levels level: 5 \ No newline at end of file diff --git a/phpstan.neon.example b/phpstan.neon.example index 656a8fc..d5e2022 100644 --- a/phpstan.neon.example +++ b/phpstan.neon.example @@ -1,4 +1,4 @@ -# PHPStan configuration for local static analysis. +# PHPStan configuration for GitHub Actions. # Include PHPStan for WordPress configuration. includes: @@ -9,25 +9,25 @@ parameters: # Paths to scan # This should comprise of the base Plugin PHP file, plus directories that contain Plugin PHP files paths: - - wp-convertkit.php + - convertkit-membermouse.php - admin/ - includes/ # Files that include Plugin-specific PHP constants bootstrapFiles: - - wp-convertkit.php + - convertkit-membermouse.php # Location of WordPress Plugins for PHPStan to scan, building symbols. scanDirectories: - - /Users/tim/Local Sites/convertkit-github/app/public/wp-content/plugins + - /home/runner/work/convertkit-membermouse/convertkit-membermouse/wordpress/wp-content/plugins + + # Location of constants for PHPStan to scan, building symbols. + scanFiles: + - /home/runner/work/convertkit-membermouse/convertkit-membermouse/wordpress/wp-config.php + + # Don't report unmatched ignored errors on older PHP versions (7.2, 7.3) + reportUnmatchedIgnoredErrors: false # Should not need to edit anything below here # Rule Level: https://phpstan.org/user-guide/rule-levels - level: 5 - - # Ignore the following errors, as PHPStan and PHPStan for WordPress haven't registered symbols for them yet, - # so they're false positives. - ignoreErrors: - - '#Access to an undefined property WP_Theme::#' - - '#Constant WP_MEMORY_LIMIT not found.#' - - '#Function apply_filters invoked with#' # apply_filters() accepted a variable number of parameters, which PHPStan fails to detect \ No newline at end of file + level: 5 \ No newline at end of file From 315c27591d7f831be48b13f9ed13bb02b0a87ef7 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 5 Dec 2024 16:12:31 +0800 Subject: [PATCH 2/2] Remove `reportUnmatchedIgnoredErrors` --- phpstan.neon.dist | 3 --- phpstan.neon.example | 3 --- 2 files changed, 6 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index d5e2022..092b4f0 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -25,9 +25,6 @@ parameters: scanFiles: - /home/runner/work/convertkit-membermouse/convertkit-membermouse/wordpress/wp-config.php - # Don't report unmatched ignored errors on older PHP versions (7.2, 7.3) - reportUnmatchedIgnoredErrors: false - # Should not need to edit anything below here # Rule Level: https://phpstan.org/user-guide/rule-levels level: 5 \ No newline at end of file diff --git a/phpstan.neon.example b/phpstan.neon.example index d5e2022..092b4f0 100644 --- a/phpstan.neon.example +++ b/phpstan.neon.example @@ -25,9 +25,6 @@ parameters: scanFiles: - /home/runner/work/convertkit-membermouse/convertkit-membermouse/wordpress/wp-config.php - # Don't report unmatched ignored errors on older PHP versions (7.2, 7.3) - reportUnmatchedIgnoredErrors: false - # Should not need to edit anything below here # Rule Level: https://phpstan.org/user-guide/rule-levels level: 5 \ No newline at end of file