13
例:オプションパラメータのデフォルト値を設定するためのphpdoc標準?
/**
* This function will determine whether or not one string starts with another string.
* @param string $haystack <p>The string that needs to be checked.</p>
* @param string $needle <p>The string that is being checked for.</p>
* @param boolean $case[optional] <p>Set to false to ignore case(capital or normal characters)</p>
* @return boolean <p>If the $haystack string does start with the $needle string, the return will be true. False if not.</p>
*/
function endsWith($haystack,$needle,$case=true) {
if($case){return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0);}
return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0);
}
オプションのパラメータは、デフォルトでtrue
に設定されています。ドキュメントのデフォルト設定が何であるかを示したいと思います。これを行うための標準的な方法はありますか、またはその記述でそれを言及しなければなりませんか?
ありがとうございました。そしてそれは私に幾分良い、はいを感じさせます:) – KdgDev
これは、オプションのパラメータが関数シグネチャに含まれている場合の答えです。しかし、もしそうでなければどうしますか?オプションのパラメータを文書化するには?ドキュメントからは唯一の方法は説明でそれを伝えることです。ですから、例えば '[$ case = true]'と書くことはできません。 jsdocでもそれがあります。 – FreeLightman