From 20fb6bcc98919f8e18011374619071f27e59c3db Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Sun, 1 Feb 2026 13:19:44 -0800 Subject: [PATCH 1/8] `composer require szepeviktor/phpstan-wordpress:^v1.3.5|^2.0.3` --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4695b5f5..f314673c 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "phpstan/phpstan-phpunit": "^1.4 || ^2.0", "phpstan/phpstan-strict-rules": "^1.6 || ^2.0", "swissspidy/phpstan-no-private": "^0.2.1 || ^1.0", - "szepeviktor/phpstan-wordpress": "^v1.3.5", + "szepeviktor/phpstan-wordpress": "^v1.3.5|^2.0.3", "wp-cli/config-command": "^1 || ^2", "wp-cli/core-command": "^1 || ^2", "wp-cli/eval-command": "^1 || ^2", From d87b19436df6ef4797b79e4418a570928cd44d39 Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Sun, 1 Feb 2026 13:39:40 -0800 Subject: [PATCH 2/8] Use conventional format for multiple versions and add `v` --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f314673c..eb7d23ea 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "phpstan/phpstan-phpunit": "^1.4 || ^2.0", "phpstan/phpstan-strict-rules": "^1.6 || ^2.0", "swissspidy/phpstan-no-private": "^0.2.1 || ^1.0", - "szepeviktor/phpstan-wordpress": "^v1.3.5|^2.0.3", + "szepeviktor/phpstan-wordpress": "^v1.3.5 || ^v2.0.3", "wp-cli/config-command": "^1 || ^2", "wp-cli/core-command": "^1 || ^2", "wp-cli/eval-command": "^1 || ^2", From b2add61522745bfa728720d16bbd5def9c44e640 Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Sun, 1 Feb 2026 15:23:10 -0800 Subject: [PATCH 3/8] Copy rules from `phpstan-strict-rules`'s `rules.neon` --- extension.neon | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/extension.neon b/extension.neon index c231d546..49426177 100644 --- a/extension.neon +++ b/extension.neon @@ -29,6 +29,14 @@ parameters: switchConditionsMatchingType: false noVariableVariables: false strictArrayFilter: false + booleansInLoopConditions: false + disallowedBacktick: false + disallowedEmpty: false + disallowedImplicitArrayCreation: false + disallowedShortTernary: false + strictFunctionCalls: false + dynamicCallOnStaticMethod: false + illegalConstructorMethodCall: false # Add the schema from phpstan-strict-rules so it's available without loading the extension # and the above configuration works. @@ -48,4 +56,12 @@ parametersSchema: switchConditionsMatchingType: anyOf(bool(), arrayOf(bool())) noVariableVariables: anyOf(bool(), arrayOf(bool())) strictArrayFilter: anyOf(bool(), arrayOf(bool())) + booleansInLoopConditions: anyOf(bool(), arrayOf(bool())) + disallowedBacktick: anyOf(bool(), arrayOf(bool())) + disallowedEmpty: anyOf(bool(), arrayOf(bool())) + disallowedImplicitArrayCreation: anyOf(bool(), arrayOf(bool())) + disallowedShortTernary: anyOf(bool(), arrayOf(bool())) + strictFunctionCalls: anyOf(bool(), arrayOf(bool())) + dynamicCallOnStaticMethod: anyOf(bool(), arrayOf(bool())) + illegalConstructorMethodCall: anyOf(bool(), arrayOf(bool())) ]) From a86560c309825c213003e4ecddcae00811c774c9 Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Sun, 1 Feb 2026 15:41:16 -0800 Subject: [PATCH 4/8] PHPStan: Accept `mixed` in array The immediate call to `Utils\assoc_args_to_str()` handles `bool`, `array`, and anything `escapeshellarg()` can handle. --- src/Context/FeatureContext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index 3c9dbb0e..cf30cdc7 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -1247,7 +1247,7 @@ public function drop_db(): void { /** * @param string $command - * @param array $assoc_args + * @param array $assoc_args * @param string $path * @return Process */ From 2c2100ea9b55edf5220a5bef6138edd9631dc7e0 Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Sun, 1 Feb 2026 15:42:08 -0800 Subject: [PATCH 5/8] PHPStan: accept `bool` in array This is used for `send_to_shell` which is immediately unset if present. --- src/Context/FeatureContext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index cf30cdc7..07936e13 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -1169,7 +1169,7 @@ private function set_cache_dir(): void { * Run a MySQL command with `$db_settings`. * * @param string $sql_cmd Command to run. - * @param array $assoc_args Optional. Associative array of options. Default empty. + * @param array $assoc_args Optional. Associative array of options. Default empty. * @param bool $add_database Optional. Whether to add dbname to the $sql_cmd. Default false. * @return array{stdout: string, stderr: string, exit_code: int} */ From ab0a4c638d9ac56b06387f195bcc0f32a6a3187e Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Sun, 1 Feb 2026 20:37:04 -0500 Subject: [PATCH 6/8] Update composer.json Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index eb7d23ea..57f53f15 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "phpstan/phpstan-phpunit": "^1.4 || ^2.0", "phpstan/phpstan-strict-rules": "^1.6 || ^2.0", "swissspidy/phpstan-no-private": "^0.2.1 || ^1.0", - "szepeviktor/phpstan-wordpress": "^v1.3.5 || ^v2.0.3", + "szepeviktor/phpstan-wordpress": "^1.3.5 || ^2.0.3", "wp-cli/config-command": "^1 || ^2", "wp-cli/core-command": "^1 || ^2", "wp-cli/eval-command": "^1 || ^2", From 56aa0ed6fe1b5ff29e12f82e2453987fdc1acf24 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Sun, 1 Feb 2026 20:37:38 -0500 Subject: [PATCH 7/8] Fix remaining reported issues --- phpstan.neon.dist | 2 -- src/PHPStan/WPCliRuncommandDynamicReturnTypeExtension.php | 3 --- 2 files changed, 5 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 3c2a0976..abe68abc 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -21,7 +21,5 @@ parameters: ignoreErrors: # Needs fixing in WP-CLI. - message: '#Parameter \#1 \$cmd of function WP_CLI\\Utils\\esc_cmd expects array#' - - message: '#Dynamic call to static method#' - path: 'tests/tests' strictRules: strictCalls: true diff --git a/src/PHPStan/WPCliRuncommandDynamicReturnTypeExtension.php b/src/PHPStan/WPCliRuncommandDynamicReturnTypeExtension.php index 379e03b5..4bbdf2a9 100644 --- a/src/PHPStan/WPCliRuncommandDynamicReturnTypeExtension.php +++ b/src/PHPStan/WPCliRuncommandDynamicReturnTypeExtension.php @@ -39,11 +39,8 @@ public function getTypeFromStaticMethodCall( ): Type { $args = $methodCall->getArgs(); - /** @var ConstantBooleanType|ConstantStringType $returnOption */ $returnOption = new ConstantBooleanType( true ); - /** @var ConstantBooleanType|ConstantStringType $parseOption */ $parseOption = new ConstantBooleanType( false ); - /** @var ConstantBooleanType $exitOnErrorOption */ $exitOnErrorOption = new ConstantBooleanType( true ); $optionsAreStaticallyKnown = true; From eee3c22b04e81d5932913a3136dea0a5b31cd208 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Sun, 1 Feb 2026 20:38:56 -0500 Subject: [PATCH 8/8] Fix alignment --- src/PHPStan/WPCliRuncommandDynamicReturnTypeExtension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PHPStan/WPCliRuncommandDynamicReturnTypeExtension.php b/src/PHPStan/WPCliRuncommandDynamicReturnTypeExtension.php index 4bbdf2a9..2635fecf 100644 --- a/src/PHPStan/WPCliRuncommandDynamicReturnTypeExtension.php +++ b/src/PHPStan/WPCliRuncommandDynamicReturnTypeExtension.php @@ -39,8 +39,8 @@ public function getTypeFromStaticMethodCall( ): Type { $args = $methodCall->getArgs(); - $returnOption = new ConstantBooleanType( true ); - $parseOption = new ConstantBooleanType( false ); + $returnOption = new ConstantBooleanType( true ); + $parseOption = new ConstantBooleanType( false ); $exitOnErrorOption = new ConstantBooleanType( true ); $optionsAreStaticallyKnown = true;