2010-08-28 8 views
5

Wie kann ich eine variable Anzahl von Parametern dokumentieren? Ich schreibe eine Anwendung in PHP und JavaScript. Zur Zeit habe ich (in JavaScript):Wie wird eine variable Anzahl von Parametern beschrieben?

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

Also, wie ich doc n-Anzahl von String-params?

+2

Nicht sicher, ob „doctype“ verwendet, ist die richtige Wahl des Wortes hier. –

+0

Meinst du, wie diese Parameter in der Jsdoc schreiben? – 2ndkauboy

+1

Fragen Sie nach Javascript oder PHP? Ihr Code ist JS, aber Sie haben eine PHP-Antwort akzeptiert. Wenn es PHP ist, ändern Sie bitte (oder entfernen Sie) das Beispiel und entfernen Sie auch die Javascript- und jsdoc-Umbauten. Für JS gibt es bereits eine Antwort in der verknüpften Frage (http://stackoverflow.com/questions/4729516/correct-way-to-document-open-ended-argument-functions-in-jsdoc). – studgeek

Antwort

12

z. PhpDocumentor schlägt eine Auslassungs

/** 
* 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

Beat mich dazu. Referenz: http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.param.pkg.html –

+0

Dies scheint nicht mehr zu funktionieren, wenn phpDocumentor2 verwendet wird – ChrisF

+1

Was ist, wenn es varargs wie 'function foo() { $ args = func_get_args(); ...} '? – SeldomNeedy