3

In PHP you can have a function take an infinite number of arguments like

 /**
 * Do abc...
 *
 * @since 1.0
 * @param mixed $arg1 Arg description
 * @return string Results
 */
function abc($arg1 = null){
 $args = func_get_args();
 // do smth with $args
}

How should I illustrate this in my DocBlock ?

Craige
3,78123 silver badges30 bronze badges
asked Jul 19, 2012 at 19:41

1 Answer 1

4

phpdoc.org manual example:

/**
 * @param mixed $varname,... unlimited OPTIONAL number of additional variables [...]
 */

You may document parameters listed or any optional paramters that will be parsed by standard PHP functions func_num_args()/get_func_arg(). Recommended name format for parameters listed with func_get_arg() is:

  • $paramname if there is only one parameter
  • $paramname,... if the number of parameters is unlimited

phpDocumentor will display the optional description unmodified.

Note that the $paramname,... will be shown in the output docs in both the parameter listing AND the function signature. If you are not indicating in the actual code that the parameter is optional (via "$paramname = 'a default value'"), then you should mention in the parameter's description that the parameter is optional.

answered Jul 19, 2012 at 20:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.