+++ /dev/null
-<?php\r
-/**\r
-* Extracts define statements and their documentation from php code.\r
-*\r
-* @version $Id: PhpdocConstantParser.php,v 1.4 2000/12/03 22:37:37 uw Exp $\r
-*/\r
-class PhpdocConstantParser extends PhpdocUseParser {\r
-\r
- /**\r
- * Internal structure use to save a constant.\r
- * \r
- * @var array\r
- */\r
- var $emptyConstant = array( \r
- "name" => "",\r
- "value" => "",\r
- "undoc" => true\r
- );\r
- \r
- /**\r
- * Doc Tags allowed with const[ant].\r
- * \r
- * @var array\r
- */ \r
- var $constantTags = array(\r
- "access" => true,\r
- "see" => true,\r
- "link" => true,\r
- \r
- "constant" => true,\r
- "const" => true,\r
- \r
- "author" => true,\r
- "copyright" => true,\r
- \r
- "exclude" => true,\r
- "magic" => true,\r
- "todo" => true\r
- );\r
-\r
- /**\r
- * Scans the given constant doc comment.\r
- *\r
- * @param array\r
- */ \r
- function analyseConstant($para) {\r
- \r
- $constant = $this->emptyConstant;\r
- $constant["name"] = $para["name"];\r
- $constant["value"] = $para["value"];\r
- \r
- if ("" != $para["doc"]) {\r
- \r
- $constant = $this->analyseTags( $this->getTags($para["doc"]), $constant, $this->constantTags);\r
- \r
- list($msg, $constant) = $this->checkParserErrors($constant, "constant (define() keyword)");\r
- if ("" != $msg)\r
- $this->warn->addDocWarning($this->currentFile, "constant", $constant["name"], $msg, "mismatch");\r
- \r
- list($constant["sdesc"], $constant["desc"]) = $this->getDescription($para["doc"]);\r
-\r
- $constant["undoc"] = false; \r
- }\r
- \r
- $constant = $this->checkConstantDoc($constant);\r
- \r
- if (isset($para["case"]))\r
- $constant["case"] = $para["case"];\r
- \r
- return $constant;\r
- } // end func analyseConstant\r
- \r
- /**\r
- * Compares the data from the parser with the optional const[ant] tags\r
- * @param array Hash with the data of the current constant paragraph\r
- * @return array $constant\r
- */\r
- function checkConstantDoc($constant) {\r
- \r
- if (!isset($constant["const"])) {\r
- \r
- $msg = "The @const[ant] tag is missing. Add '@const " . $constant["name"] . " [description]' to the tag list at the end of the doc comment.";\r
- $this->warn->addDocWarning($this->currentFile, "constant", $constant["name"], $msg, "missing");\r
-\r
- } else {\r
- \r
- if ($constant["name"] != $constant["const"]["name"]) {\r
- \r
- $msg = sprintf("The name of the constant '%s' does not match the documented name '%s', update the tag to '@const %s %s'.",\r
- $constant["name"],\r
- $constant["const"]["name"],\r
- $constant["name"],\r
- $constant["const"]["desc"]\r
- );\r
- $this->warn->addDocWarning($this->currentFile, "constant", $constant["name"], $msg, "mismatch");\r
- \r
- }\r
-\r
- if ("" != $constant["const"]["desc"]) \r
- $constant["const"] = $constant["const"]["desc"];\r
- else \r
- unset($constant["const"]);\r
- }\r
- \r
- return $constant;\r
- } // end func checkConstantDoc\r
- \r
-} // end class PhpdocConstantParser\r
-?>
\ No newline at end of file