Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to doc a variable number of parameters

How do I doc a variable number of parameters? I am writing an application in PHP and JavaScript. Currently I have (in JavaScript):

/**
 * Description
 * @param {String} description
 */
function fn()
{
  // arguments holds all strings.
}

So, how do I doc n-number of string params?

like image 510
Tower Avatar asked Aug 28 '10 10:08

Tower


People also ask

How do you write a function with variable number of arguments?

To call a function with a variable number of arguments, simply specify any number of arguments in the function call. An example is the printf function from the C run-time library. The function call must include one argument for each type name declared in the parameter list or the list of argument types.

What is the syntax of variable number of parameters?

Syntax of VarargsA variable-length argument is specified by three periods or dots(…). This syntax tells the compiler that fun( ) can be called with zero or more arguments. As a result, here, a is implicitly declared as an array of type int[].

How can you declare variable length parameters?

Use va_list type variable in the function definition. Use int parameter and va_start macro to initialize the va_list variable to an argument list. The macro va_start is defined in stdarg. h header file.


1 Answers

E.g. PhpDocumentor suggests using an ellipsis

/**
 * Example of unlimited parameters.
 * Returns a formatted var_dump for debugging purposes
 * (since the recurrences of $v are not listed in the actual function signature in the code,
 * you may wish to highlight they are "optional" in their description)
 * @param string $s string to display
 * @param mixed $v variable to display with var_dump()
 * @param mixed $v,... unlimited OPTIONAL number of additional variables to display with var_dump()
 */
function fancy_debug($s,$v)
{
like image 159
VolkerK Avatar answered Sep 22 '22 00:09

VolkerK