Skip to content

Conversation

@BrianHenryIE
Copy link
Member

@BrianHenryIE BrianHenryIE commented Feb 1, 2026

composer require szepeviktor/phpstan-wordpress:^v1.3.5 || ^v2.0.3 where v1.3.5 was the existing requirement and v2.0.3 is the latest release.

Currently requiring wp-cli/wp-cli-tests in a project that requires szepeviktor/phpstan-wordpress:^2 is not possible (except maybe with an ignore flag).

szepeviktor/phpstan-wordpress:v2 adds support for phpstan/phpstan:v2 which is already allowed in this project's Composer.json.

⚠️ I just realised that the szepeviktor/phpstan-wordpress:^v1.3.5 requirement's Composer.json would have been preventing this project ever installing PhpStan v2 from the phpstan/phpstan:^1.12.26 || ^2.0 requirement, so I'll open this as draft and investigate a bit more.

WordPress Extensions for PHPStan is not used directly in the project but is auto-loaded via phpstan/extension-installer, as configured in this project's Composer.json.

Conveniently, szepeviktor/phpstan-wordpress:v2.0.3 has some nice WP_CLI related changes.

Two PHPUnit tests fail for me, but they also fail on main and on 5.08:

TestBehatTags::test_behat_tags_php_version()

Failed asserting that two strings are identical.
Expected :'--tags=~@require-php-8.0&&~@less-than-php-7.3&&~@less-than-php-7.4&&~@github-api&&~@broken&&~@require-mariadb&&~@require-sqlite'
Actual   :'--tags=~@less-than-php-7.3&&~@less-than-php-7.4&&~@less-than-php-8.0&&~@github-api&&~@broken&&~@require-mariadb&&~@require-sqlite'

TestBehatTags::test_behat_tags_extension()

Failed asserting that two strings are identical.
Expected :'--tags=~@github-api&&~@broken&&~@require-mariadb&&~@require-sqlite&&~@require-extension-imagick'
Actual   :'--tags=~@github-api&&~@broken&&~@require-mariadb&&~@require-sqlite'

I was trying to upgrade to address a Behat issue in a project so I'm hoping this is a local issue and CI will still pass.

@github-actions

This comment was marked as resolved.

@gemini-code-assist

This comment was marked as resolved.

@codecov

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

@BrianHenryIE
Copy link
Member Author

BrianHenryIE commented Feb 1, 2026

PhpStan run failed: https://github.com/wp-cli/wp-cli-tests/actions/runs/21570736116/job/62149380938

Note: Using configuration file /home/runner/work/wp-cli-tests/wp-cli-tests/phpstan.neon.dist.
Invalid configuration:
Unexpected item 'parameters › strictRules › booleansInLoopConditions', did you mean 'booleansInConditions'?
Invalid configuration:
Unexpected item 'parameters › strictRules › disallowedBacktick'.
Invalid configuration:
Unexpected item 'parameters › strictRules › disallowedEmpty'.
Invalid configuration:
Unexpected item 'parameters › strictRules › disallowedImplicitArrayCreation'.
Invalid configuration:
Unexpected item 'parameters › strictRules › disallowedShortTernary'.
Invalid configuration:
Unexpected item 'parameters › strictRules › strictFunctionCalls'.
Invalid configuration:
Unexpected item 'parameters › strictRules › dynamicCallOnStaticMethod'.
Invalid configuration:
Unexpected item 'parameters › strictRules › illegalConstructorMethodCall'.

Fixed in b2add61 by copying the full rule-set from phpstan-strict-rules/rules.neon@2.0.8.

Allowing PhpStan 2 to be installed also allowed the newer version of Extra strict and opinionated rules for PHPStan to install, which then caused that issue.

This PHPStan upgrade has caused its normal run to now fail: https://github.com/wp-cli/wp-cli-tests/actions/runs/21572281797/job/62153276858

The immediate call to `Utils\assoc_args_to_str()` handles `bool`, `array`, and anything `escapeshellarg()` can handle.
This is used for `send_to_shell` which is immediately unset if present.
@BrianHenryIE
Copy link
Member Author

BrianHenryIE commented Feb 1, 2026

I fixed six of the eight of the errors with two changes, explained in the commit messages.

The two remaining, I'm not sure about:

 -- ------------------------------------------------------------------------- 
     Error                                                                    
 -- ------------------------------------------------------------------------- 
     Ignored error pattern #Dynamic call to static method# in path            
     /home/runner/work/wp-cli-tests/wp-cli-tests/tests/tests was not matched  
     in reported errors.                                                      
 -- ------------------------------------------------------------------------- 

We can add reportUnmatchedIgnoredErrors or remove the ignoreErrors entry from phpstan.neon.dist:

Index: phpstan.neon.dist
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
--- a/phpstan.neon.dist	(revision 2c2100ea9b55edf5220a5bef6138edd9631dc7e0)
+++ b/phpstan.neon.dist	(date 1769989059654)
@@ -18,6 +18,7 @@
     - WP_DEBUG
     - WP_DEBUG_LOG
     - WP_DEBUG_DISPLAY
+  reportUnmatchedIgnoredErrors: false
   ignoreErrors:
     # Needs fixing in WP-CLI.
     - message: '#Parameter \#1 \$cmd of function WP_CLI\\Utils\\esc_cmd expects array<string>#'

or

Index: phpstan.neon.dist
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
--- a/phpstan.neon.dist	(revision 2c2100ea9b55edf5220a5bef6138edd9631dc7e0)
+++ b/phpstan.neon.dist	(date 1769989733706)
@@ -21,7 +21,6 @@
   ignoreErrors:
     # Needs fixing in WP-CLI.
     - message: '#Parameter \#1 \$cmd of function WP_CLI\\Utils\\esc_cmd expects array<string>#'
-    - message: '#Dynamic call to static method#'
       path: 'tests/tests'
   strictRules:
     strictCalls: true

and for

 ------ ----------------------------------------------------------------------- 
  Line   src/PHPStan/WPCliRuncommandDynamicReturnTypeExtension.php              
 ------ ----------------------------------------------------------------------- 
  43     PHPDoc tag @var with type                                              
         PHPStan\Type\Constant\ConstantBooleanType|PHPStan\Type\Constant\Const  
         antStringType is not subtype of native type                            
         PHPStan\Type\Constant\ConstantBooleanType.                             
         🪪  varTag.nativeType                                                  
  45     PHPDoc tag @var with type                                              
         PHPStan\Type\Constant\ConstantBooleanType|PHPStan\Type\Constant\Const  
         antStringType is not subtype of native type                            
         PHPStan\Type\Constant\ConstantBooleanType.                             
         🪪  varTag.nativeType                                                  
 ------ ----------------------------------------------------------------------- 

in
da3218d#diff-a5bbe350faae7b2f455b301cc8c306eb644e9d9a6ae7a132fdf0c33daaea2a02R42-R47

/** @var ConstantBooleanType|ConstantStringType $returnOption */
$returnOption = new ConstantBooleanType( true );
/** @var ConstantBooleanType|ConstantStringType $parseOption */
$parseOption = new ConstantBooleanType( false );
/** @var ConstantBooleanType $exitOnErrorOption */
$exitOnErrorOption = new ConstantBooleanType( true );

It looks intentional. Or could be fixed by removing the PhpDoc annotations altogether.

@BrianHenryIE BrianHenryIE marked this pull request as ready for review February 2, 2026 00:06
@BrianHenryIE BrianHenryIE requested a review from a team as a code owner February 2, 2026 00:06
swissspidy and others added 2 commits February 1, 2026 20:37
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Member

@swissspidy swissspidy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@swissspidy swissspidy added this to the 5.0.9 milestone Feb 2, 2026
@swissspidy swissspidy merged commit e4b8b0c into wp-cli:main Feb 2, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants