Skip to content

Fix PHPParser ArgPlaceholder compat - #329

Merged
staabm merged 2 commits into
phpstan:2.0.xfrom
staabm:fix-nikic
Sep 19, 2026
Merged

staabm merged 2 commits into
phpstan:2.0.xfrom
staabm:fix-nikic

Conversation

@staabm

@staabm staabm commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

fixes

------ ----------------------------------------------------------------------- 
  Line   src/Rules/PHPUnit/AssertSameBooleanExpectedRule.php                    
 ------ ----------------------------------------------------------------------- 
  54     Parameter #1 $args of static method                                    
         PHPStan\Rules\PHPUnit\AssertSameBooleanExpectedRule::rewriteArgs()     
         expects array<PhpParser\Node\Arg|PhpParser\Node\VariadicPlaceholder>,  
          array<PhpParser\Node\Arg|PhpParser\Node\ArgPlaceholder|PhpParser\Nod  
         e\VariadicPlaceholder> given.                                          
         🪪  argument.type                                                       
  68     Parameter #1 $args of static method                                    
         PHPStan\Rules\PHPUnit\AssertSameBooleanExpectedRule::rewriteArgs()     
         expects array<PhpParser\Node\Arg|PhpParser\Node\VariadicPlaceholder>,  
          array<PhpParser\Node\Arg|PhpParser\Node\ArgPlaceholder|PhpParser\Nod  
         e\VariadicPlaceholder> given.                                          
         🪪  argument.type                                                       
 ------ ----------------------------------------------------------------------- 

 ------ ----------------------------------------------------------------------- 
  Line   src/Rules/PHPUnit/AssertSameNullExpectedRule.php                       
 ------ ----------------------------------------------------------------------- 
  54     Parameter #1 $args of static method                                    
         PHPStan\Rules\PHPUnit\AssertSameNullExpectedRule::rewriteArgs()        
         expects array<PhpParser\Node\Arg|PhpParser\Node\VariadicPlaceholder>,  
          array<PhpParser\Node\Arg|PhpParser\Node\ArgPlaceholder|PhpParser\Nod  
         e\VariadicPlaceholder> given.                                          
         🪪  argument.type                                                       
 ------ ----------------------------------------------------------------------- 

 [ERROR] Found 3 errors                                                         

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The annotations address the reported PHPStan compatibility errors.

Review effort: Lite
Findings: None

What changed in this PR

Updates PHPDoc annotations to support PHP-Parser ArgPlaceholder nodes and resolve PHPStan compatibility errors.

Changes:

  • Extends argument types in both assertion rules.
  • Preserves support for existing argument node types.
File Description
src/​Rules/​PHPUnit/​AssertSameNullExpectedRule.php Updates rewriteArgs() annotations.
src/​Rules/​PHPUnit/​AssertSameBooleanExpectedRule.php Updates rewriteArgs() annotations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

/**
* @param array<Node\Arg|Node\VariadicPlaceholder> $args
* @return list<Node\Arg|Node\VariadicPlaceholder>
* @template T of NodeAbstract

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

instead of using a fixed union of types (which depends on PHPParser version) use a more generic base class

PHPParser v5.9.0+: Node\Arg|Node\ArgPlaceholder|Node\VariadicPlaceholder
PHPParser <v5.9.0: Node\Arg|Node\VariadicPlaceholder

@staabm
staabm merged commit 4aed86d into phpstan:2.0.x Sep 19, 2026
96 of 97 checks passed
@staabm
staabm deleted the fix-nikic branch September 19, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants