You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * @return ($b is A ? ANode : ($b is B ? BNode : CNode)) */publicfunctionb(A|B|C$b): ANode|BNode|CNode {
return match(true) {
$b instanceof A => newANode(),
$b instanceof B => newBNode(),
default => newCNode(),
};
}
PHPStan will resolve the return type of b() as b(A) => ANode, b(B) => BNode which are expected. But for b(A|B) it will report that the return type is ANode|BNode|CNode. This is not true, the type should be ANode|BNode.
Bug report
If we have something like
PHPStan will resolve the return type of
b()
asb(A) => ANode
,b(B) => BNode
which are expected. But forb(A|B)
it will report that the return type isANode|BNode|CNode
. This is not true, the type should beANode|BNode
.Code snippet that reproduces the problem
https://phpstan.org/r/9d568b79-afd0-48b3-a379-50127980fbb5
Expected output
ANode|BNode
Did PHPStan help you today? Did it make you happy in any way?
Yep 😋
The text was updated successfully, but these errors were encountered: