Phan\AST\UnionTypeVisitor::visitCall PHP Method

visitCall() public method

Visit a node with kind \ast\AST_CALL
public visitCall ( 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 visitCall(Node $node) : UnionType
    {
        // Things like `$func()`. We don't understand these.
        if ($node->children['expr']->kind !== \ast\AST_NAME) {
            return new UnionType();
        }
        $function_name = $node->children['expr']->children['name'];
        try {
            $function = (new ContextNode($this->code_base, $this->context, $node->children['expr']))->getFunction($function_name);
        } catch (CodeBaseException $exception) {
            // If the function wasn't declared, it'll be caught
            // and reported elsewhere
            return new UnionType();
        }
        $function_fqsen = $function->getFQSEN();
        // TODO: I don't believe we need this any more
        // If this is an internal function, see if we can get
        // its types from the static dataset.
        if ($function->isInternal() && $function->getUnionType()->isEmpty()) {
            $map = UnionType::internalFunctionSignatureMapForFQSEN($function->getFQSEN());
            return $map[$function_name] ?? new UnionType();
        }
        return $function->getUnionType();
    }