public static function unionTypeFromNode(CodeBase $code_base, Context $context, $node, bool $should_catch_issue_exception = true) : UnionType
{
if (!$node instanceof Node) {
if ($node === null || $node === 'null') {
return new UnionType();
}
return Type::fromObject($node)->asUnionType();
}
if ($should_catch_issue_exception) {
try {
return (new self($code_base, $context, $should_catch_issue_exception))($node);
} catch (IssueException $exception) {
Issue::maybeEmitInstance($code_base, $context, $exception->getIssueInstance());
return new UnionType();
}
}
return (new self($code_base, $context, $should_catch_issue_exception))($node);
}