Fix check generic mixed type based on config v2#2885
Fix check generic mixed type based on config v2#2885ondrejmirtes merged 2 commits intophpstan:1.10.xfrom
Conversation
src/Rules/RuleLevelHelper.php
Outdated
There was a problem hiding this comment.
TemplateMixedType extends explicit MixedType, so I made its behavior consistent with that.
I wonder whether @template T and @template T of mixed should be implicit/explicit respectively. But I assume that the implicit mixed exists mainly for untyped legacy code. So in that sense it seems right to me for both of them to be considered explicit, even though it feels slightly inconsistent with how it works for non-generic parameters. Especially, considering that checkImplicitMixed is off even with level 9.
There was a problem hiding this comment.
Unfortunately, I wasn't able to figure out how to make a callable with implicit mixed parameter. But if it's impossible to make one, then it doesn't matter how it behaves and so there's no need to test it.
cece3bf to
4321f19
Compare
ondrejmirtes
left a comment
There was a problem hiding this comment.
Hi, I mostly like this, but I'd prefer the new behaviour only for bleeding edge, because this leads to more errors being eeported.
Please lead to the new behaviour only when newRuleLevelHelper is enabled, otherwise use the old behaviour. You don't need to test it, it should be obvious from the diff (that you're adding new branches to the code and otherwise not changing anything else).
b58c879 to
c4f1d74
Compare
|
If the build passes I'm gonna merge this :) |
c4f1d74 to
f4b1b48
Compare
|
Thank you! |


This is an alternative to #2809 . This time I was able to limit the changes to
RuleLevelHelper(it kind of makes me wonder how I missed this option in the first place).The goal is to handle
TemplateMixedTypesimilarly to explicitMixedTypewith respect tocheckExplicitMixed. Here is an example of the issues in as many cases as I can think of https://phpstan.org/r/0b58afa8-fd01-4991-922e-d46037106135 . As you can see, even the regular mixed type is not covered completely, but that's a matter for another PR(s).These are the results for the linked playground code in this branch: