Question

According to wikipedia the format for @param docblock parameters is type [$varname] description where $varname is optional. This seems to be backed by the phpDocumentor project which states:

@param datatype $paramname description
@param datatype1|datatype2 $paramname description

NOTE: as of 0.4.1, @param can document phpdoc.de-style, with optional $paramname

So is it still proper form to include the $paramname or should it be left out?

/**
 * Have a foo!
 *
 * @param string $foo is a string
 * @param string This is another string
 * @return string
 */
function haveAFoo($foo, $bar) { ... }
Was it helpful?

Solution

More "proper form" would be to include $paramname. It ensures zero ambiguity in matching the @param line with its matching argument in the function signature. It is very likely listed as "optional" only as as old backwards-compatibility issue with "phpdoc.de style". I doubt that this optional handling remains available in phpDocumentor2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top