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);
}