加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHPDocumentor可选参数

发布时间:2020-12-13 17:11:20 所属栏目:PHP教程 来源:网络整理
导读:我正在尝试为以下内容编写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
我正在尝试为以下内容编写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定义给了我

Parameter $holidays,… could not be found in daysBetween()

我相信我可以通过修改方法定义来解决这个问题

public function daysBetween($startDate,$endDate,$holidays=NULL) {

但这感觉非常糟糕,我不相信我必须改变我的功能定义才能记录它.有人有任何其他建议吗?

附:我正在使用PHPDocumentor2

解决方法

你当前的语法

* @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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读