PHP doc:表示您正在返回另一个函数调用的结果

时间:2017-06-20 16:44:49

标签: phpdoc

使用这样的函数:

function cancel($thing_id)
{
   $this->Thing->id = $thing_id;
   return $this->Thing->cancel();
}

如何格式化@return以反映我正在返回另一个函数调用的结果?

1 个答案:

答案 0 :(得分:1)

无法将返回类型链接到不同的函数返回类型。它不是phpDocumentor: Defining a 'Type'中的类型,最接近的是callable类型。

你可以做的最好的事情如下:

/**
 * As a example I have assumed that $this->Thing->cancel() returns either true or false
 *
 * @see Thing::cancel
 * @return bool Returns the result of Thing::cancel
 */

如您所见,我指定了$this->Thing->cancel()的返回类型,并解释了返回类型的来源。为了便于找到方法,我添加了@see标记,指向方法