我正在尝试为以下内容编写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的所有实例都是可选的…可能没有定义一个、一个或多个$假日日期。上面的phpdocumentor定义给了我
参数$holidays,…在daysbetween()中找不到
我相信通过将方法定义修改为
public function daysBetween($startDate,$endDate,$holidays=NULL) {
但这让人觉得很不清楚,我不认为为了记录它,我必须更改函数定义。有人有其他建议吗?
P.S.我在用phpdocumentor2
最佳答案
您当前的语法
* @param DateTime $holidays,... Optional series of dates that will be excluded
根据phpdocumentor手册,param标记[1]看起来很合适。此页显示“$holidays,…”语法应该足以让phpdocumentor识别代码的方法签名中没有直接出现的可选参数。
这个“参数$holidays,…在daysbetween()中找不到“响应可能需要在github页[2]打开一个新问题。
〔1〕——http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.param.pkg.html
〔2〕——https://github.com/phpDocumentor/phpDocumentor2/issues/424