Exports the function signature.

@param \ReflectionFunctionAbstract $function         The function to export.
@param int                         $excludeModifiers An optional bitmask of modifiers to exclude.

@return string
347906
public function exportFunction(\ReflectionFunctionAbstract $function, int $excludeModifiers = 0) : string
    {
        $result = '';

        if ($function instanceof \ReflectionMethod) {
            $modifiers = $function->getModifiers();
            $modifiers &= ~ $excludeModifiers;

            foreach (\Reflection::getModifierNames($modifiers) as $modifier) {
                $result .= $modifier . ' ';
            }
        }

        $result .= 'function ' . $function->getShortName();
        $result .= '(' . $this->exportFunctionParameters($function) . ')';

        if (null !== $returnType = $function->getReturnType()) {
            $result .= ' : ';

            if ($returnType->allowsNull()) {
                $result .= '?';
            }

            if (! $returnType->isBuiltin()) {
                $result .= '\\';
            }

            $result .= $returnType->getName();
        }

        return $result;
    }
440442
private static function doFilter(ReflectionClass $class, array $excluded, bool $requireAbstract = false) : array
    {
        $ignored = array_flip(array_map('strtolower', $excluded));

        return array_filter(
            $class->getMethods(ReflectionMethod::IS_PUBLIC),
            static function (ReflectionMethod $method) use ($ignored, $requireAbstract) : bool {
                return (! $requireAbstract || $method->isAbstract()) && ! (
                    array_key_exists(strtolower($method->getName()), $ignored)
                    || self::methodCannotBeProxied($method)
                );
            }
        );
    }
689379
private function getFunctionArguments(\ReflectionFunctionAbstract $reflection, $values)
    {
        $arguments = [];
        if (!empty($reflection->getParameters())) {
            foreach ($values as $value) {
                $arguments[] = $value;
            }
        }
        return $arguments;
    }
667787
function buildFunctionSignature (paramTypes, returnTypes, isPayable, additionalMods) {
  return 'function (' + util.concatWithSeperator(paramTypes, ',') + ')' + ((isPayable) ? ' payable' : '') + ((additionalMods) ? ' ' + additionalMods : '') + ((returnTypes.length) ? ' returns (' + util.concatWithSeperator(returnTypes, ',') + ')' : '')
}
1140755
public function resolveArguments(ReflectionFunctionAbstract $function, array $explicitArguments = []): array
    {
        $arguments = $this->extractReflection($function);
        $arguments = $this->extractDocTags($arguments, $function);

        /* TODO: variadic parameters */
        /** @var Definition[] $result */
        $result = [];
        $i = 0;
        foreach ($arguments as $name => $arg) {
            $explicitArg = $explicitArguments[$i] ?? null;
            $result[] = $this->resolveArgument($function, $name, $arg, $explicitArg);

            $i++;
        }

        return $result;
    }
1218827
public function call($function, array $parameters = [])
    {
        $inspector = new ReflectionFunction($function);

        $dependencies = $inspector->getParameters();
        $dependencies = $this->process('', $parameters, $dependencies);

        return call_user_func_array($function, $dependencies);
    }
76038
private function deferCall(string $func, array $params)
    {
        $profileKey = $this->interface . '->' . $func;
        $fallback   = $this->getFallbackHandler($func);

        try {
            $connectPool    = $this->getPool();
            $circuitBreaker = $this->getBreaker();

            /* @var ConnectionInterface $connection */
            $connection = $connectPool->getConnection();

            $packer   = service_packer();
            $type     = $this->getPackerName();
            $data     = $packer->formatData($this->interface, $this->version, $func, $params);
            $packData = $packer->pack($data, $type);

            $result = $circuitBreaker->call([$connection, 'send'], [$packData], $fallback);

            if ($result === null || $result === false) {
                $connection->release(true);
                return null;
            }
        } catch (\Throwable $throwable) {
            if (empty($fallback)) {
                throw $throwable;
            }

            $connection = null;
            $result     = PhpHelper::call($fallback, $params);
        }

        return $this->getResult($connection, $profileKey, $result);
    }
641097
def identical_signature_wrapper(original_function, wrapped_function):
    '''
    
    '''
    context = {'__wrapped__': wrapped_function}
    function_def = compile(
        'def {0}({1}):\n'
        '    return __wrapped__({2})'.format(
            # Keep the original function name
            original_function.__name__,
            # The function signature including defaults, i.e., 'timeout=1'
            inspect.formatargspec(
                *salt.utils.args.get_function_argspec(original_function)
            )[1:-1],
            # The function signature without the defaults
            inspect.formatargspec(
                formatvalue=lambda val: '',
                *salt.utils.args.get_function_argspec(original_function)
            )[1:-1]
        ),
        '<string>',
        'exec'
    )
    six.exec_(function_def, context)
    return wraps(original_function)(context[original_function.__name__])
1134290
protected function extractClosureCode(\ReflectionFunction $ref)
	{
		$file = $ref->getFileName();
		$lines = file($file, FILE_IGNORE_NEW_LINES);
		
		if(isset($this->namespaceContextCache[$file]))
		{
			$namespaceContext = $this->namespaceContextCache[$file];
		}
		else
		{
			$tokens = token_get_all(implode("\n", $lines));
			$namespaceContext = $this->namespaceContextCache[$file] = $this->generateNamespaceContext($tokens);
		}
		
		// Extract closure code from file source.
		$funcLines = array_slice($lines, $ref->getStartLine() - 1, $ref->getEndLine() - $ref->getStartLine() + 1);
		$snippet = implode("\n", array_map('trim', $funcLines));
		$snippet = preg_replace("'^.*\{'", '', $snippet);
		$snippet = preg_replace("'\}.*$'", '', $snippet);
		
		// Parse closure code snippet and expand unqualified names.
		$tokens = array_slice(token_get_all('<?php ' . $snippet), 1);
		$buffer = $this->expandNames($tokens, $namespaceContext);
		
		return str_replace("\n", "\n\t\t", "\n" . trim($buffer));
	}
901251
private function getMatchingFunctionNode(array $locatedFunctionNodes, IFunctionReflection $reflection)
    {
        $locationHash = $reflection->getLocation()->getHash();

        if (empty($locatedFunctionNodes[$locationHash])) {
            throw InvalidFunctionException::invalidFunctionMessage(
                    'Cannot parse function, the function could not be located',
                    $reflection->getInnerReflection()
            );
        }

        // If multiple functions defined on a single line we
        // perform all possible resolution to resolve the conflict.
        // Magic constants / scopes are resolved in parameter expressions
        // to allow matching of functions with these special constants in
        // default values.
        /** @var $matchedFunctionsByLocation LocatedFunctionNode[] */
        $matchedFunctionsByLocation = $locatedFunctionNodes[$locationHash];
        $functionSignature          = $reflection->getSignature();
        $fullyMatchedFunctions      = [];

        foreach ($matchedFunctionsByLocation as $matchedFunction) {
            $magicData                        = $reflection->resolveMagic($matchedFunction->getDeclaration());
            $resolvedMatchedFunctionSignature = $matchedFunction->getSignature()->resolveMagic($magicData);

            if ($functionSignature->getHash() === $resolvedMatchedFunctionSignature->getHash()) {
                $fullyMatchedFunctions[] = $matchedFunction;
            }
        }

        if (empty($fullyMatchedFunctions)) {
            throw InvalidFunctionException::invalidFunctionMessage(
                    'Cannot parse function, the function\'s signature could not be matched',
                    $reflection->getInnerReflection()
            );
        } elseif (count($fullyMatchedFunctions) > 1) {
            throw InvalidFunctionException::invalidFunctionMessage(
                    'Cannot parse function, %d ambiguous functions are defined on the same line '
                    . 'with identical signatures',
                    $reflection->getInnerReflection(),
                    count($locatedFunctionNodes[$locationHash])
            );
        }

        return $fullyMatchedFunctions[0];
    }
125821
def get_function_from_signature(self, function_signature):
        
        return next((f for f in self.functions if f.full_name == function_signature), None)
384839
public function GetProtoHeader(
        \Peg\Lib\Definitions\Element\FunctionElement $function
    )
    {
        $proto = "/* {{{ ";

        foreach($function->overloads as $overload)
        {
            $proto .= "proto ";

            $proto .= $this->symbols->GetPHPStandardType($overload->return_type);

            $proto .= " " . $overload->function->name . "(";

            foreach($overload->parameters as $parameter)
            {
                $proto .= $this->symbols->GetPHPStandardType($parameter);

                if(!$parameter->is_const && ($parameter->is_pointer || $parameter->is_reference))
                {
                    $proto .= " &" . $parameter->name;
                }
                else
                {
                    $proto .= " " . $parameter->name;
                }

                if($parameter->default_value)
                {
                    $proto .= " = " . $parameter->default_value;
                }

                $proto .= ", ";
            }

            $proto = rtrim($proto, ", ");

            $proto .= ")";

            if($overload->description)
                $proto .= "\n       " . $overload->description;

            $proto .= "\n       ";
        }

        $proto = rtrim($proto, " \n");

        $proto .= " */\n";

        return $proto;
    }
844242
def get_function_help(function: str, bel_spec: BELSpec):
    

    function_long = bel_spec["functions"]["to_long"].get(function)
    function_help = []

    if function_long:
        for signature in bel_spec["functions"]["signatures"][function_long]["signatures"]:
            function_help.append(
                {
                    "function_summary": signature["argument_summary"],
                    "argument_help": signature["argument_help_listing"],
                    "description": bel_spec["functions"]["info"][function_long]["description"],
                }
            )

    return function_help
1360435
def parse_signature(cls, function):
        '''
        '''
        annotations = function.__annotations__.copy()
        del annotations['return']
        result = []
        for param_name, (param_type, param_obj) in annotations.items():
            sig_param = function.signature.parameters[param_name]
            param_description = {
                'paramType': param_type,
                'name': param_name,
                'required': sig_param.default is inspect.Parameter.empty}
            param_description.update(param_obj.describe())
            result.append(param_description)
        return result
132940
private static function forkCallMapClass(\ReflectionFunction $function): \ReflectionClass
    {
        try {
            $compile = self::$compile;
            $compile(self::createProxyCode($function));
        } catch (\ParseError $pe) {
            throw new ProxyCreationFailure(
                    'Failure while creating callable CallMap instance of '
                    . $function->getName() . '(): ' . $pe->getMessage(),
                    $pe
            );
        }

        return new \ReflectionClass($function->getName() . 'CallMapProxy');
    }
1161345
def check_exports(mod, specs, renamings):
    '''
    
    '''
    functions = {renamings.get(k, k): v for k, v in specs.functions.items()}

    mod_functions = {node.name: node for node in mod.body
                     if isinstance(node, ast.FunctionDef)}

    for fname, signatures in functions.items():
        try:
            fnode = mod_functions[fname]
        except KeyError:
            raise PythranSyntaxError(
                "Invalid spec: exporting undefined function `{}`"
                .format(fname))
        for signature in signatures:
            args_count = len(fnode.args.args)
            if len(signature) > args_count:
                raise PythranSyntaxError(
                    "Too many arguments when exporting `{}`"
                    .format(fname))
            elif len(signature) < args_count - len(fnode.args.defaults):
                raise PythranSyntaxError(
                    "Not enough arguments when exporting `{}`"
                    .format(fname))
377934
def get_function_doc(function, config=default_config):
    """"""
    if config.exclude_function:
        for ex in config.exclude_function:
            if ex.match(function.__name__):
                return None

    return _doc_object(function, 'function', config=config)