public function visitName(Node $node) : UnionType
{
if ($node->flags & \ast\flags\NAME_NOT_FQ) {
if ('parent' === $node->children['name']) {
$class = $this->context->getClassInScope($this->code_base);
if ($class->hasParentType()) {
return Type::fromFullyQualifiedString((string) $class->getParentClassFQSEN())->asUnionType();
} else {
if (!$class->isTrait()) {
$this->emitIssue(Issue::ParentlessClass, $node->lineno ?? 0, (string) $class->getFQSEN());
}
return new UnionType();
}
}
if ('self' === $node->children['name'] && $this->context->getClassInScope($this->code_base)->isTrait()) {
return new UnionType();
}
return Type::fromStringInContext($node->children['name'], $this->context)->asUnionType();
}
return Type::fromFullyQualifiedString('\\' . $node->children['name'])->asUnionType();
}