public function visitProp(Node $node) : UnionType
{
try {
$property = (new ContextNode($this->code_base, $this->context, $node))->getProperty($node->children['prop']);
// Map template types to concrete types
if ($property->getUnionType()->hasTemplateType()) {
// Get the type of the object calling the property
$expression_type = UnionType::fromNode($this->context, $this->code_base, $node->children['expr']);
$union_type = $property->getUnionType()->withTemplateParameterTypeMap($expression_type->getTemplateParameterTypeMap($this->code_base));
return $union_type;
}
return $property->getUnionType();
} catch (IssueException $exception) {
Issue::maybeEmitInstance($this->code_base, $this->context, $exception->getIssueInstance());
} catch (CodeBaseException $exception) {
$property_name = $node->children['prop'];
$this->emitIssue(Issue::UndeclaredProperty, $node->lineno ?? 0, "{$exception->getFQSEN()}->{$property_name}");
} catch (UnanalyzableException $exception) {
// Swallow it. There are some constructs that we
// just can't figure out.
} catch (NodeException $exception) {
// Swallow it. There are some constructs that we
// just can't figure out.
}
return new UnionType();
}