次のように、渡された引数に応じてミューテーターまたはアクセサーとして動作する関数が与えられます。
// in PHP, you can pass any number of arguments to a function...
function cache($cacheName) {
$arguments = func_get_args();
if (count($arguments) >= 2) { // two arguments passed. MUTATOR.
$value = $arguments[1]; // use the second as the value
$this->cache[$cacheName] = $value; // *change* the stored value
} else { // 1 argument passed, ACCESSOR
return $this->cache[$cacheName]; // *get* the stored value
}
}
cache('foo', 'bar'); // nothing returned
cache('foo') // 'bar' returned
これをPHPDocまたは同様の自動ドキュメント作成者でどのように文書化しますか?私はもともと次のように書いていました:
/**
* Blah blah blah, you can use this as both a mutator and an accessor:
* As an accessor:
* @param $cacheName name of the variable to GET
* @return string the value...
*
* As a mutator:
* @param $cacheName name of the variable to SET
* @param $value the value to set
* @return void
*/
ただし、これをphpDocで実行すると、2つのreturnタグがあり、最初の@param $cacheName
説明が2番目の説明で上書きされるため、文句を言います。
これを回避する方法はありますか?