如何在phpDoc/javaDoc中记录访问器/变异器方法?

如何在phpDoc/javaDoc中记录访问器/变异器方法?,php,documentation,phpdoc,Php,Documentation,Phpdoc,给定一个函数,根据传递给它的参数,该函数的行为可以是一个变元函数或访问函数,如下所示: // 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.

给定一个函数,根据传递给它的参数,该函数的行为可以是一个变元函数或访问函数,如下所示:

// 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
/**
 *  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或类似的自动文档创建者中对此进行文档记录?我最初是这样写的:

// 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
/**
 *  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个返回标记,第一个
@param$cacheName
描述被第二个覆盖


有办法解决这个问题吗?

正如您所发现的,您不能记录单个函数的两个不同签名。但是,如果您使用-,您可以做的是记录和:

为了清楚起见,我还将包括用法示例