From 376b08ad650ddb15b4769b41d8e4c48c69c61400 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 26 Aug 2026 06:43:19 +0000 Subject: [PATCH] Exclude the wp-compat false positives from the PHPStan config The johnbillion/wp-compat extension that comes with wp-cli-tests checks every WordPress symbol against the WordPress 4.9 baseline that wp-cli-tests configures, and only recognizes function_exists() and method_exists() guards. It cannot see the `before_invoke` check in ai-command.php that aborts `wp ai` and `wp connectors` below WordPress 7.0, so all eight errors it reports are false positives. Ignore them by error identifier and message, naming both the functions and that version, so a call to anything introduced after WordPress 7.0 keeps being reported rather than swallowed by a file-wide ignore. Co-authored-by: Pascal Birchler --- phpstan.neon.dist | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a40edaf..ddab1b3 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -8,3 +8,20 @@ parameters: scanFiles: - vendor/php-stubs/wordpress-stubs/wordpress-stubs.php treatPhpDocTypesAsCertain: false + ignoreErrors: + # johnbillion/wp-compat checks every WordPress symbol against the WordPress 4.9 + # baseline that wp-cli-tests configures. It only recognizes function_exists() and + # method_exists() guards, so it cannot see the `before_invoke` check in + # ai-command.php that aborts `wp ai` and `wp connectors` below WordPress 7.0. + # + # The entries below match on the message as well as the identifier, naming both the + # functions and that version, so a call to anything introduced after 7.0 still gets + # reported rather than swallowed by a file-wide ignore. + - + identifier: WPCompat.functionNotAvailable + message: '#^(wp_ai_client_prompt|wp_supports_ai)\(\) is only available since WordPress version 7\.0\.0\.$#' + path: src/AI_Command.php + - + identifier: WPCompat.functionNotAvailable + message: '#^(wp_get_connector|wp_get_connectors)\(\) is only available since WordPress version 7\.0\.0\.$#' + path: src/Connectors_Command.php