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
Logical OR leads to TypeDoesNotContainType #7079
Labels
Comments
I found these snippets: https://psalm.dev/r/2b0bbc6018<?php
interface X {
public function getStringOptional(): ?string;
}
/** @var X $x */
$url = $x->getStringOptional();
$email = $x->getStringOptional();
if (
(empty($url) && empty($email)) ||
(!empty($url) && !empty($email)) ||
(!empty($email) && strpos($email, '@') == false)
) {
throw new \Exception();
}
if (!empty($email)) {}
https://psalm.dev/r/c8564dd6d9<?php
interface X {
public function getStringOptional(): ?string;
}
/** @var X $x */
$url = $x->getStringOptional();
$email = $x->getStringOptional();
if (
(empty($url) && empty($email))
) {
throw new \Exception();
}
if (
(!empty($url) && !empty($email))
) {
throw new \Exception();
}
if (
(!empty($email) && strpos($email, '@') == false)
) {
throw new \Exception();
}
if (!empty($email)) {}
|
probably related or even a duplicate of #6683 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Yeah closing this in favour of #6683, since it has the same root cause. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/2b0bbc6018
But if I split it into several ifs, Psalm gets it without issues:
https://psalm.dev/r/c8564dd6d9
You can see this works:
https://3v4l.org/era8I
The text was updated successfully, but these errors were encountered: