From 2e03189db2d515d05ebcaff32da1a372dbc82068 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 26 Aug 2026 06:21:29 +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 ability-command.php that aborts every `wp ability` command below WordPress 6.9, so all 37 errors it reports are false positives. Ignore them by error identifier and message, naming both the Abilities API symbols and that version, so a call to anything introduced after WordPress 6.9 keeps being reported rather than swallowed by a file-wide ignore. Co-authored-by: Pascal Birchler --- phpstan.neon.dist | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 1bdd3b0..4e95158 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -27,3 +27,26 @@ parameters: - message: '#Cannot access offset string on mixed#' reportUnmatched: false + + # 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 + # ability-command.php that aborts every `wp ability` command below WordPress 6.9. + # + # The entries below match on the message as well as the identifier, naming both the + # symbols and that version, so a call to anything introduced after 6.9 still gets + # reported rather than swallowed by a file-wide ignore. + - + identifier: WPCompat.functionNotAvailable + message: '#^(wp_get_abilities|wp_get_ability|wp_get_ability_categories|wp_get_ability_category|wp_has_ability|wp_has_ability_category)\(\) is only available since WordPress version 6\.9\.0\.$#' + paths: + - src/Ability_Command.php + - src/Ability_Category_Command.php + - + identifier: WPCompat.methodNotAvailable + message: '#^WP_Ability::(check_permissions|execute|get_category|get_description|get_input_schema|get_label|get_meta|get_meta_item|get_name|get_output_schema|normalize_input|validate_input)\(\) is only available since WordPress version 6\.9\.0\.$#' + path: src/Ability_Command.php + - + identifier: WPCompat.methodNotAvailable + message: '#^WP_Ability_Category::(get_description|get_label|get_meta|get_slug)\(\) is only available since WordPress version 6\.9\.0\.$#' + path: src/Ability_Category_Command.php