From 5157bcf83cf8e1044587a464d9c87359ded21620 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 25 Aug 2026 20:56:04 +0000 Subject: [PATCH 1/2] 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. All eight errors it reported are false positives. WordPress 6.0 merely formalized the already documented `...$args` parameter of `apply_filters()`; the two `intermediate_image_sizes_advanced` calls are in fact already split across a `wp_version_compare()` check for exactly that reason. The WordPress 6.0 change to `wp_generate_attachment_metadata()` added the `$filesize` value to the returned array rather than touching the `$file` parameter, which has been there since WordPress 2.1. And `Media_Command::wp_get_registered_image_subsizes()` only calls its WordPress 5.3 namesake behind a `wp_version_compare()` check, reimplementing it otherwise. Ignore them per file and per error identifier, with the reason documented for each group. Co-authored-by: Pascal Birchler --- phpstan.neon.dist | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index e3f6baec..6d0d9d7a 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -10,3 +10,30 @@ parameters: treatPhpDocTypesAsCertain: false ignoreErrors: - identifier: missingType.iterableValue + + # 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 `wp_version_compare()` checks used + # throughout this command. + + # WordPress 6.0 only formalized the already documented `...$args` parameter of + # `apply_filters()` by adding it to the function signature. Additional arguments + # were collected through `func_get_args()` before that. The two + # `intermediate_image_sizes_advanced` calls are already split across a + # `wp_version_compare()` check for exactly this reason. + - + identifier: WPCompat.parameterNotAvailable.applyfilters.args + path: src/Media_Command.php + + # The WordPress 6.0 change to `wp_generate_attachment_metadata()` added the + # `$filesize` value to the *returned array*. The `$file` parameter itself has been + # there since WordPress 2.1. + - + identifier: WPCompat.parameterNotAvailable.wpgenerateattachmentmetadata.file + path: src/Media_Command.php + + # `Media_Command::wp_get_registered_image_subsizes()` only calls its WordPress 5.3 + # namesake behind a `wp_version_compare()` check, and reimplements it otherwise. + - + identifier: WPCompat.functionNotAvailable + path: src/Media_Command.php From 3ceb0a8c8e68c004caab11a47a8f176a6a43076c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 25 Aug 2026 21:14:10 +0000 Subject: [PATCH 2/2] Scope the function availability ignore to the intended function The `WPCompat.functionNotAvailable` entry matched every diagnostic of that kind in a 2300 line file while only one error needed ignoring, which would have hidden any future call to a function newer than the WordPress 4.9 baseline. Match on the message as well so only `wp_get_registered_image_subsizes()` is covered. Co-authored-by: Pascal Birchler --- phpstan.neon.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 6d0d9d7a..e32bc2f5 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -36,4 +36,5 @@ parameters: # namesake behind a `wp_version_compare()` check, and reimplements it otherwise. - identifier: WPCompat.functionNotAvailable + message: '#^wp_get_registered_image_subsizes\(\) is only available since WordPress version 5\.3\.0\.$#' path: src/Media_Command.php