首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHPDocumentor可选参数

PHPDocumentor可选参数
EN

Stack Overflow用户
提问于 2012-03-22 22:18:40
回答 1查看 4.5K关注 0票数 4

我试图为以下内容编写phpdocumentor块:

代码语言:javascript
复制
/**
 * 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定义给了我

参数$holidays .在daysBetween()中找不到

我相信我可以通过将方法定义修改为

代码语言:javascript
复制
public function daysBetween($startDate,$endDate,$holidays=NULL) {

但是这感觉很混乱,我不认为我应该改变我的函数定义来记录它。还有人有其他建议吗?

我用的是PHPDocumentor2

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-04-02 15:56:58

的当前语法

代码语言:javascript
复制
* @param   DateTime    $holidays,...  Optional series of dates that will be excluded

根据param标签1的phpDocumentor手册,这个页面显示了"$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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9831390

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档