I am writing a script in the procedural PHP style, but still want to document everything the best I can. Thats why I use DocBlock comments. Being new to them, I wonder how to use them in the following scenario (code written especially for this question):
/**
* Checks string length
*
* @param int $max_length an integer determining the string length to check against
* @param string $string the string to be checked
* @return bool a boolean value indicating if the string is shorter or longer
* than $max_length. True if shorter, false if longer
*/
function check_length( $max_length = 2, $string ) {
$i = 0;
if( strlen( $string ) > $max_length )
return false;
return true;
}
Lets assume $i
would be needed for that function. How should I document it? I can't put it inside the function DocBlock because its not an argument.
The example has two similar vars inside that class, but as I am not writing object oriented code, I can't put $i
outside the function (or just don't want to change my coding style to be able to use DocBlocks).
Another approach would be to not document these 'internal' variables because for using the function, they are not important.