2012-03-22 57 views
4

我想寫以下的phpDocumentor的塊: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和結束日期$是強制性的參數,而$假期的所有實例都是可選的...有可能是沒有,定義一個或多個$假期日期。上述定義的phpDocumentor給我

參數$假期,...不能在daysBetween()

找到我相信我也許可以避開這個問題通過修改方法定義

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

但這感覺非常糟糕,我不認爲我應該改變我的函數定義以便記錄它。有人有其他建議嗎?

P.S.我使用的

* @param DateTime $holidays,... Optional series of dates that will be excluded 

PHPDocumentor2

回答

4

您當前的語法看起來正確按照該手冊的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