Phan\AST\UnionTypeVisitor::visitConst PHP Method

visitConst() public method

Visit a node with kind \ast\AST_CONST
public visitConst ( 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.
return Phan\Language\UnionType The set of types that are possibly produced by the given node
    public function visitConst(Node $node) : UnionType
    {
        if ($node->children['name']->kind == \ast\AST_NAME) {
            if (defined($node->children['name']->children['name'])) {
                return Type::fromObject(constant($node->children['name']->children['name']))->asUnionType();
            } else {
                // Figure out the name of the constant if its
                // a string.
                $constant_name = isset($node->children['name']->children['name']) ? $node->children['name']->children['name'] : '';
                // If the constant is referring to the current
                // class, return that as a type
                if (Type::isSelfTypeString($constant_name)) {
                    return $this->visitClassNode($node);
                }
                $constant = (new ContextNode($this->code_base, $this->context, $node))->getConst();
                return $constant->getUnionType();
            }
        }
        return new UnionType();
    }