Phan\AST\ContextNode::getFunction PHP Method

getFunction() public method

public getFunction ( string $function_name, boolean $is_function_declaration = false ) : Phan\Language\Element\FunctionInterface
$function_name string The name of the function we'd like to look up
$is_function_declaration boolean This must be set to true if we're getting a function that is being declared and false if we're getting a function being called.
return Phan\Language\Element\FunctionInterface A method with the given name in the given context
    public function getFunction(string $function_name, bool $is_function_declaration = false) : FunctionInterface
    {
        if ($is_function_declaration) {
            $function_fqsen = FullyQualifiedFunctionName::make($this->context->getNamespace(), $function_name);
        } else {
            $function_fqsen = FullyQualifiedFunctionName::make($this->context->getNamespace(), $function_name);
            // If it doesn't exist in the local namespace, try it
            // in the global namespace
            if (!$this->code_base->hasFunctionWithFQSEN($function_fqsen)) {
                $function_fqsen = FullyQualifiedFunctionName::fromStringInContext($function_name, $this->context);
            }
        }
        // Make sure the method we're calling actually exists
        if (!$this->code_base->hasFunctionWithFQSEN($function_fqsen)) {
            throw new IssueException(Issue::fromType(Issue::UndeclaredFunction)($this->context->getFile(), $this->node->lineno ?? 0, ["{$function_fqsen}()"]));
        }
        return $this->code_base->getFunctionByFQSEN($function_fqsen);
    }