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?
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.
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[].
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.
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)
{
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With