Phan\AST\UnionTypeVisitor::visitProp PHP Метод

visitProp() публичный Метод

Visit a node with kind \ast\AST_PROP
public visitProp ( ast\Node $node ) : UnionType
$node ast\Node A node of the type indicated by the method name that we'd like to figure out the type that it produces.
Результат Phan\Language\UnionType The set of types that are possibly produced by the given node
    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();
    }