-
Notifications
You must be signed in to change notification settings - Fork 439
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
More precise falsey isset() #2708
Conversation
This pull request has been marked as ready for review. |
src/Analyser/TypeSpecifier.php
Outdated
|
||
$type = $scope->getType($var); | ||
if ( | ||
!$type instanceof MixedType && !TypeCombinator::containsNull($type) |
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.
!$type instanceof MixedType &&
doesn't need to be there as TypeCombinator::containsNull
will never return true
for MixedType
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.
without this explicit MixedType
check the
function mixedIsset(mixed $m): void
{
if (isset($m)) {
assertType("mixed~null", $m);
} else {
assertType("null", $m);
}
}
case will not succeed. I turned the conditions arround, maybe its more readable now.
9823c83
to
001ad45
Compare
I knew deep down the condition really wasn't needed. |
Thank you. |
awesome, thanks! |
split off parts out from #2657 since it gets too complicated.
lets do it one step at a time instead