3 * Looks for documented and undocumented functions within a block of php code.
\r
5 * @version $Id: PhpdocFunctionParser.php,v 1.2 2000/12/03 22:37:37 uw Exp $
\r
7 class PhpdocFunctionParser extends PhpdocVariableParser {
\r
10 * Internal structur of a function.
\r
12 * @var array $emptyFunction
\r
14 var $emptyFunction = array(
\r
22 * Array of tags that are allowed in front of the function keyword
\r
23 * @var array $functionTags
\r
24 * @see analyseFunctionParagraph()
\r
26 var $functionTags = array(
\r
27 "parameter" => true,
\r
46 "deprecated" => true,
\r
56 "copyright" => true,
\r
62 * Analyses a function doc comment.
\r
66 function analyseFunction($para) {
\r
68 $function = $this->emptyFunction;
\r
69 $function["name"] = $para["name"];
\r
71 if (""!=$para["doc"]) {
\r
73 $function = $this->analyseTags($this->getTags($para["doc"]), $function, $this->functionTags);
\r
75 list($msg, $function) = $this->checkParserErrors($function, "function");
\r
77 $this->warn->addDocWarning($this->currentFile, "function", $function["name"], $msg, "mismatch");
\r
79 list($function["sdesc"], $function["desc"]) = $this->getDescription($para["doc"]);
\r
81 $function["undoc"] = false;
\r
85 $function["args"] = $this->getFunctionArgs($para["head"]);
\r
87 } // end func analyseFunction
\r
90 * Analyses a function head and returns an array of arguments.
\r
91 * @param string PHP code to examine.
\r
92 * @return array Array of arguments: $args[] = array( optional, default, type, name ).
\r
93 * @see getVariableTypeAndValue()
\r
95 function getFunctionArgs($code) {
\r
98 while (preg_match($this->PHP_COMPLEX["argument"], $code, $regs)) {
\r
104 if (!isset($regs[3])) {
\r
106 $len_of_value = strlen($regs[1]);
\r
108 } else if ("=" == $regs[3]) {
\r
110 $find = $regs[1].$regs[2];
\r
111 $code = substr($code, strpos($code, $find)+strlen($find) );
\r
113 list ($type, $value, $raw_value) = $this->getVariableTypeAndValue($code);
\r
114 $len_of_value = strlen($raw_value);
\r
119 $len_of_value = strlen($regs[1].$regs[2]);
\r
123 $code = substr($code, $len_of_value);
\r
125 "optional" => $optional,
\r
126 "default" => $value,
\r
134 } // end func getFunctionArgs
\r
136 } // end class PhpdocFunctionParser
\r