bug in PHPDoc
| From: | Guillaume SMET | Date: | Sun, 11 Aug 2002 19:28:45 +0000 |
| Subject: | bug in PHPDoc | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-8301@lists.php.net to get a copy of this message | ||
Hi,
Here is a bug (or a lack of functionality) I found in PHPdoc.
When you document arguments of a function, you have to put them in the right order.
For example :
/**
[...]
* @param int $arg3 foo
* @param int $arg1 bar
*/
myFunction($arg1, $arg2, $arg3)
-> $arg1 is documented with foo
-> $arg2 is documented with bar
-> $arg3 is declared undocumented.
Since we put the names of the arguments in the @param tag, we can suppose that phpdoc will manage
this sort of problem.
I can't give you a patch because my PHPDoc version is really different from Pear one but here
are some elements to solve this
problem :
- in the PhpdocAnalyser class, consider the checkArgDocs method
- print_($args) :
Array ( [0] => Array ( [optional] => [default] => [type] => [name] => $name ) [1]
=> Array ( [optional] => [default] => [type] =>
[name] => $parameters ) )
- print_r($params) :
Array ( [0] => Array ( [type] => string [name] => $name [desc] => nom donné au bloc
(caractères alphanumériques) ) [1] => Array (
[type] => array [name] => $parameters [desc] => paramètres nécessaires au bloc ) )
- checkArgDocs checks that each key in $args is present in $params but keys are not significant. The
information which is
significant is the name of the parameter/argument.
- There are two solutions :
1. we use the name of the parameter as the key of $args and $params
2. we use something like that to find the correct parameter for the argument :
// start
$parameterKey = false;
foreach($params AS $key=>$param) {
if($param['name']==$argName) {
$parameterKey = $key;
}
}
if ($parameterKey===false) {
// end
instead of :
// start
if (isset($params[$k])) {
// end
The checkArgDocs method must be updated to take into account the $parameterKey variable but it seems
to work.
HTH
G.