Improve intersecting constant array with general array#1429
Improve intersecting constant array with general array#1429ondrejmirtes merged 1 commit intophpstan:1.7.xfrom
Conversation
src/Type/TypeCombinator.php
Outdated
There was a problem hiding this comment.
the comment above the sort callback might need adjustments
4cf40e2 to
f93c4da
Compare
|
The first failure in question is about this PHPDoc: PHPStan says about it: I don't see why - there's no |
|
The second failure: It's about this piece of code: And the value assigned into the property: I'm not sure who's wrong here - whether the type inference near the Link to the file in question: https://github.com/sebastianbergmann/phpunit/blob/9.5.12/src/Util/Annotation/DocBlock.php |
|
I think that is mostly due to differences in how Psalm and PHPStan interpret these array shape intersections. Notably, I believe in the context of how PHPStan handles it this PR is consistent, but it might make moving to (or at least borrowing ideas from) Psalm's model harder in the future. |
|
The root issue about these types is that "array shape" from PHPDoc and a "literal array in code" should be two different Type implementations. There are certain differences about them and right now ConstantArrayType tries to be both of them and is bad at it. Some examples:
Of course introducing new type implementation isn't trivial because we have to think and implement all the interactions with all the other types... |
|
Anyway, this PR is fine, thank you :) |
No description provided.