Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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 ?

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.