New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix makeOffsetRequired
with UnionType
offset
#1187
Conversation
Hi, this fix isn't right. When you have a union type, the value is one of the inner types. So checking In fact this is really hard to fix in typesystem alone. The closest thing we can get after the isset is something like:
But that still doesn't help us to get rid of the error when asking about What we can do to fix this is to let TypeSpecifier specify And the right rule needs to pick up this information and not report the error. You also need to write a regression test for the rule instead of NodeScopeResolverTest. |
Oh, you're right. Thank you for the pointers! I'll continue looking into it. |
Feel free to finish the other PR related to Coalesce/Isset_ first, that might have a bigger impact 😊 |
I’ll finish it today! |
I believe this is now an improvement for The problem (I think) is that type in isset scope should be phpstan-src/src/Analyser/TypeSpecifier.php Lines 785 to 790 in 036056b
should be an conditional type if $var->dim is a UnionType
|
I'll read this #1187 (comment) again and look for a fix if possible |
improving type to
|
I'd close this for now. I think it's not easy enough to solve cleanly, and there are other related issues to solve before this. |
fixes phpstan/phpstan#7000
$offsetType
withUnionType
should be handled separately like inhasOffsetValueType
phpstan-src/src/Type/Constant/ConstantArrayType.php
Lines 412 to 419 in 5066420