From 528f23a05e19a9005a0c797428ac5807342d5c71 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 25 Aug 2026 08:00:05 +0000 Subject: [PATCH] Add and configure johnbillion/wp-compat Adds the wp-compat PHPStan extension, which reports usage of WordPress functions, classes, methods and constants that are not available in the oldest supported WordPress version. `requiresAtLeast` is set to 4.9 in `extension.neon` so that all packages using this testing framework inherit the check. `pluginFile` is set to its default of `null` because wp-compat otherwise tries to determine the minimum version from a plugin or theme header. The parameters schema is declared here as well, mirroring what is already done for phpstan-strict-rules, so that the configuration remains valid when the extension is not loaded through phpstan/extension-installer. Co-authored-by: Pascal Birchler Claude-Session: https://claude.ai/code/session_01NADf5amDBgJ4ZBbd2qgijy --- composer.json | 1 + extension.neon | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c32507878..57be4bae3 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "php": ">=7.2.24", "behat/behat": "^v3.15.0", "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || ^0.5 || ^0.6.2 || ^0.7.1 || ^1.0.0", + "johnbillion/wp-compat": "^2.0", "php-parallel-lint/php-console-highlighter": "^1.0", "php-parallel-lint/php-parallel-lint": "^1.3.1", "phpcompatibility/php-compatibility": "^10.0", diff --git a/extension.neon b/extension.neon index 10b46abcf..ae4275061 100644 --- a/extension.neon +++ b/extension.neon @@ -29,6 +29,10 @@ rules: parameters: dynamicConstantNames: - FOO + WPCompat: + pluginFile: null + # Oldest WordPress version supported by WP-CLI. + requiresAtLeast: '4.9' strictRules: allRules: false disallowedLooseComparison: false @@ -53,9 +57,13 @@ parameters: dynamicCallOnStaticMethod: false illegalConstructorMethodCall: false -# Add the schema from phpstan-strict-rules so it's available without loading the extension -# and the above configuration works. +# Add the schemas from phpstan-strict-rules and wp-compat so they're available without +# loading the extensions and the above configuration works. parametersSchema: + WPCompat: structure([ + pluginFile: schema(string(), nullable()) + requiresAtLeast: schema(string(), nullable()) + ]) strictRules: structure([ allRules: anyOf(bool(), arrayOf(bool())), disallowedLooseComparison: anyOf(bool(), arrayOf(bool())),