【发布时间】:2012-04-07 13:14:57
【问题描述】:
我正在尝试为以下内容编写 phpdocumentor 块:
/**
* daysBetween
*
* Returns the number of whole working days between start_date and end_date. Working
* days exclude weekends and any dates identified in holidays.
* Use NETWORKDAYS to calculate employee benefits that accrue based on the number of
* days worked during a specific term.
*
* @param DateTime $startDate Start date
* @param DateTime $endDate End date
* @param DateTime $holidays,... Optional series of dates that will be excluded
* @return integer Interval between the dates
*/
public function daysBetween($startDate,$endDate) {
// Shift the mandatory start and end date that are referenced
// in the function definition, to get any optional days
$holidays = func_get_args();
array_shift($holidays);
array_shift($holidays);
$startDate 和 $endDate 是强制参数,而 $holidays 的所有实例都是可选的……可能没有定义一个或多个 $holiday 日期。上面的 PHPDocumentor 定义给了我
在 daysBetween() 中找不到参数 $holidays,...
我相信我可以通过将方法定义修改为来解决这个问题
public function daysBetween($startDate,$endDate,$holidays=NULL) {
但这感觉很笨拙,我认为我不应该为了记录它而必须更改我的函数定义。有人有其他建议吗?
附:我正在使用 PHPDocumentor2
【问题讨论】: