İsteğe bağlı bir parametre varsayılan değeri ayarlama için phpdoc standart?

1 Cevap php

Örnek:

/**
 * 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);
}

İsteğe bağlı parametre varsayılan true ayarlanır. Ben varsayılan ayar belgelerinde ne olduğunu belirtmek istiyoruz. Bunu yapmanın standart bir yolu var mı yoksa ben açıklamasında bunu söz var mı?

1 Cevap

The doc says:

Note that the $paramname,... will be shown in the output docs in both the parameter listing AND the function signature. If you are not indicating in the actual code that the parameter is optional (via "$paramname = 'a default value'"), then you should mention in the parameter's description that the parameter is optional.

Eğer işlev imza varsayılan atama gösteren değilseniz Yani, açıklamasında dahil etmek iyi bir fikir olacaktır, ama sizin durumunuzda are imza içinde dahil. Bunu yaparken daha iyi hissediyorum yapacak sürece Yani, bir şeyi değiştirmek gerekmez.