3 * Extracts define statements and their documentation from php code.
\r
5 * @version $Id: PhpdocConstantParser.php,v 1.4 2000/12/03 22:37:37 uw Exp $
\r
7 class PhpdocConstantParser extends PhpdocUseParser {
\r
10 * Internal structure use to save a constant.
\r
14 var $emptyConstant = array(
\r
21 * Doc Tags allowed with const[ant].
\r
25 var $constantTags = array(
\r
34 "copyright" => true,
\r
42 * Scans the given constant doc comment.
\r
46 function analyseConstant($para) {
\r
48 $constant = $this->emptyConstant;
\r
49 $constant["name"] = $para["name"];
\r
50 $constant["value"] = $para["value"];
\r
52 if ("" != $para["doc"]) {
\r
54 $constant = $this->analyseTags( $this->getTags($para["doc"]), $constant, $this->constantTags);
\r
56 list($msg, $constant) = $this->checkParserErrors($constant, "constant (define() keyword)");
\r
58 $this->warn->addDocWarning($this->currentFile, "constant", $constant["name"], $msg, "mismatch");
\r
60 list($constant["sdesc"], $constant["desc"]) = $this->getDescription($para["doc"]);
\r
62 $constant["undoc"] = false;
\r
65 $constant = $this->checkConstantDoc($constant);
\r
67 if (isset($para["case"]))
\r
68 $constant["case"] = $para["case"];
\r
71 } // end func analyseConstant
\r
74 * Compares the data from the parser with the optional const[ant] tags
\r
75 * @param array Hash with the data of the current constant paragraph
\r
76 * @return array $constant
\r
78 function checkConstantDoc($constant) {
\r
80 if (!isset($constant["const"])) {
\r
82 $msg = "The @const[ant] tag is missing. Add '@const " . $constant["name"] . " [description]' to the tag list at the end of the doc comment.";
\r
83 $this->warn->addDocWarning($this->currentFile, "constant", $constant["name"], $msg, "missing");
\r
87 if ($constant["name"] != $constant["const"]["name"]) {
\r
89 $msg = sprintf("The name of the constant '%s' does not match the documented name '%s', update the tag to '@const %s %s'.",
\r
91 $constant["const"]["name"],
\r
93 $constant["const"]["desc"]
\r
95 $this->warn->addDocWarning($this->currentFile, "constant", $constant["name"], $msg, "mismatch");
\r
99 if ("" != $constant["const"]["desc"])
\r
100 $constant["const"] = $constant["const"]["desc"];
\r
102 unset($constant["const"]);
\r
106 } // end func checkConstantDoc
\r
108 } // end class PhpdocConstantParser
\r