+++ /dev/null
-<?php\r
-/**\r
-* Looks for documented and undocumented functions within a block of php code.\r
-*\r
-* @version $Id: PhpdocFunctionParser.php,v 1.2 2000/12/03 22:37:37 uw Exp $\r
-*/\r
-class PhpdocFunctionParser extends PhpdocVariableParser {\r
-\r
- /**\r
- * Internal structur of a function.\r
- *\r
- * @var array $emptyFunction\r
- */\r
- var $emptyFunction = array(\r
- "name" => "",\r
- "undoc" => true,\r
- \r
- "args" => array()\r
- );\r
- \r
- /**\r
- * Array of tags that are allowed in front of the function keyword\r
- * @var array $functionTags\r
- * @see analyseFunctionParagraph()\r
- */\r
- var $functionTags = array(\r
- "parameter" => true,\r
- "param" => true,\r
- \r
- "return" => true,\r
- \r
- "access" => true,\r
- "abstract" => true,\r
- "static" => true,\r
- \r
- "throws" => true,\r
- \r
- "see" => true,\r
- "link" => true,\r
- \r
- "global" => true,\r
- \r
- "version" => true,\r
- "since" => true,\r
- \r
- "deprecated" => true,\r
- "deprec" => true,\r
- \r
- "brother" => true,\r
- "sister" => true,\r
- \r
- "exclude" => true,\r
- "magic" => true,\r
- \r
- "author" => true,\r
- "copyright" => true,\r
- \r
- "todo" => true\r
- );\r
- \r
- /**\r
- * Analyses a function doc comment.\r
- * @param array\r
- * @return array\r
- */\r
- function analyseFunction($para) {\r
- \r
- $function = $this->emptyFunction;\r
- $function["name"] = $para["name"]; \r
-\r
- if (""!=$para["doc"]) {\r
-\r
- $function = $this->analyseTags($this->getTags($para["doc"]), $function, $this->functionTags);\r
- \r
- list($msg, $function) = $this->checkParserErrors($function, "function");\r
- if (""!=$msg) \r
- $this->warn->addDocWarning($this->currentFile, "function", $function["name"], $msg, "mismatch");\r
- \r
- list($function["sdesc"], $function["desc"]) = $this->getDescription($para["doc"]);\r
- \r
- $function["undoc"] = false;\r
- \r
- } \r
-\r
- $function["args"] = $this->getFunctionArgs($para["head"]); \r
- return $function;\r
- } // end func analyseFunction\r
- \r
- /**\r
- * Analyses a function head and returns an array of arguments.\r
- * @param string PHP code to examine.\r
- * @return array Array of arguments: $args[] = array( optional, default, type, name ).\r
- * @see getVariableTypeAndValue()\r
- */ \r
- function getFunctionArgs($code) {\r
-\r
- $args = array();\r
- while (preg_match($this->PHP_COMPLEX["argument"], $code, $regs)) {\r
-\r
- $type = "";\r
- $value = "";\r
- $optional = false;\r
- \r
- if (!isset($regs[3])) {\r
- \r
- $len_of_value = strlen($regs[1]);\r
- \r
- } else if ("=" == $regs[3]) {\r
- \r
- $find = $regs[1].$regs[2];\r
- $code = substr($code, strpos($code, $find)+strlen($find) );\r
- \r
- list ($type, $value, $raw_value) = $this->getVariableTypeAndValue($code);\r
- $len_of_value = strlen($raw_value);\r
- $optional = true;\r
- \r
- } else {\r
- \r
- $len_of_value = strlen($regs[1].$regs[2]);\r
- \r
- }\r
- \r
- $code = substr($code, $len_of_value);\r
- $args[] = array(\r
- "optional" => $optional, \r
- "default" => $value,\r
- "type" => $type,\r
- "name" => $regs[1]\r
- );\r
- \r
- }\r
-\r
- return $args;\r
- } // end func getFunctionArgs\r
- \r
-} // end class PhpdocFunctionParser\r
-?>
\ No newline at end of file