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
Keep NeverType isExplicit-flag in TypeCombinator::intersect() #2112
Conversation
@@ -946,7 +946,7 @@ public static function intersect(Type ...$types): Type | |||
$valueType = $types[$j]->getValueType(); | |||
$newValueType = self::intersect($types[$i]->getOffsetValueType($offsetType), $valueType); | |||
if ($newValueType instanceof NeverType) { | |||
return new NeverType(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these lines dropped the explicitness flag before this PR
[ | ||
[ | ||
new NeverType(true), | ||
new IntegerType(), | ||
], | ||
NeverType::class, | ||
'*NEVER*=explicit', | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we have a test which now returns a explicit NeverType. all other tests where adjusted to compensate the additional implicit
information in the description. no changes regarding the typtes itself.
130cecc
to
9fa5af2
Compare
9fa5af2
to
6fff815
Compare
Thank you! |
inspired by #2110 where we addd logic based on NeverType explicitness, I figured it would be helpful if the TypeCombinator would keep the exlicitness, instead of create a new non-explicit NeverType every-time it combines NeverTypes'.
Before this PR there was no way to differentiate between NeverType explicit and implicit - I therefore added the same "hack" we use to differentiate explicit and implicit MixedType in tests.
this could be followed up by changes in e.g.
phpstan-src/src/Reflection/InitializerExprTypeResolver.php
Lines 500 to 502 in b76e7b1
InitializerExprTypeResolver
with this pattern)