2010-08-28 23 views
5

¿Cómo doc un número variable de parámetros? Estoy escribiendo una aplicación en PHP y JavaScript. Actualmente tengo (en JavaScript):Cómo hacer un número variable de parámetros

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

Entonces, ¿cómo doc n-number of string params?

+2

No estoy seguro de si "doctype" es la palabra correcta aquí. –

+0

¿Quiere decir cómo escribir esos parámetros en el jsdoc? – 2ndkauboy

+1

¿Está pidiendo Javascript o PHP? Su código es JS, pero aceptó una respuesta PHP. Si es PHP, cambie (o elimine) el ejemplo y también elimine las etiquetas javascript y jsdoc. Para JS ya hay una respuesta a esto en la pregunta vinculada (http://stackoverflow.com/questions/4729516/correct-way-to-document-open-ended-argument-functions-in-jsdoc). – studgeek

Respuesta

12

E.g. PhpDocumentor sugiere utilizar una elipsis

/** 
* 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) 
{
+3

Pásame a ello. Referencia: http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.param.pkg.html –

+0

Esto no parece funcionar más cuando se utiliza phpDocumentor2 – ChrisF

+1

¿Qué pasa cuando es totalmente varargs como 'function foo() { $ args = func_get_args(); ...} '? – SeldomNeedy

Cuestiones relacionadas