Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Oct 29, 2025

prevents phpstan-src errors we currently see on PHP 7.x:

------ ------------------------------------------------------------------ 
  Line   tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php  
 ------ ------------------------------------------------------------------ 
  44     Named arguments are supported only on PHP 8.0 and later.          
  57     Named arguments are supported only on PHP 8.0 and later.          
  76     Named arguments are supported only on PHP 8.0 and later.          
  95     Named arguments are supported only on PHP 8.0 and later.          
  124    Named arguments are supported only on PHP 8.0 and later.          
  144    Named arguments are supported only on PHP 8.0 and later.          
  180    Named arguments are supported only on PHP 8.0 and later.          
  199    Named arguments are supported only on PHP 8.0 and later.          
  220    Named arguments are supported only on PHP 8.0 and later.          
  241    Named arguments are supported only on PHP 8.0 and later.          
 ------ ------------------------------------------------------------------ 

refs phpstan/phpstan-src#4490 (comment)

yield [null]; // unknown phpunit version

if (PHP_VERSION_ID >= 80100) {
yield [10]; // PHPUnit 10.x requires PHP 8.1+
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm.. maybe we should even reflect this in PHPUnitVersion.

that way we could turn a maybe into a no depending on the php runtime version?

Copy link
Member

Choose a reason for hiding this comment

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

I thought about it but probably no.

The only PHPUnit versions that support named arguments (in the sense they do not do array_values() on ...$args also only support PHP 8+.

The only wrong thing that can happen I think is when we're not successfully detecting PHPUnit version, and the user is running PHPUnit 11.5+ - we will produce Arg without names so possibly the result is going to be wrong.

But I don't think a condition about PHP version belongs to the logic. Because it's unrelated - you can run PHPUnit 9.x on PHP 8 as well...

@staabm staabm marked this pull request as ready for review October 29, 2025 07:25
@ondrejmirtes ondrejmirtes merged commit 033f690 into phpstan:2.0.x Oct 29, 2025
70 checks passed
@ondrejmirtes
Copy link
Member

Thank you! Let's update the extension in the phpstan-src PR to see if it's going to be green :)

@staabm staabm deleted the rule-args3 branch October 29, 2025 08:38
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.

2 participants