Skip to content

Conversation

vojtech-dobes
Copy link
Contributor

@vojtech-dobes vojtech-dobes commented Jun 30, 2025

@ondrejmirtes ondrejmirtes merged commit 599ac2b into phpstan:2.1.x Jul 1, 2025
417 of 420 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@uuf6429
Copy link

uuf6429 commented Jul 5, 2025

Based on the example in the test, I don't quite get how this change makes sense.

interface Baz {}

function doBaz(Baz $baz): void {
     assertType('int<0, max>', count($baz));   // should be *ERROR* IMO
}

Even if $baz was an instance that implemented \Countable (and Baz), PHPStan should still complain at that point that it might not be countable. In this case, since there are no classes or interfaces implementing/extending Baz, it's also definitely not countable.

Am I missing something?

@ondrejmirtes
Copy link
Member

@uuf6429 PHPStan is still going to report Parameter #1 $value of function count expects array|Countable, Baz given.: https://phpstan.org/r/b9e378ae-02fc-4788-910e-51a081a8fe4c

No reason to make the return type ErrorType.

@uuf6429
Copy link

uuf6429 commented Jul 5, 2025

Hmm, I was confused on the basis of the test. If I understand it well such warnings are collected separately and in that case ignored?

I must admit that I tried the playground too, but assumed the change might not have been released (although I suppose that's what "bleeding edge" is for).

Anyway, all good, thanks for checking.

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