de96e0ce36901cec87c4e68a30222dc50bca9996
[atutor.git] / mods / phpdoc / PHPDoc / parser / PhpdocUseParser.php
1 <?php\r
2 /**\r
3 * Extracts use statements (include and friends) an thheir documentation from php code.\r
4 * @author       Ulf Wendel <ulf.wendel@redsys.de>\r
5 * @version 0.1alpha\r
6 */\r
7 class PhpdocUseParser extends PhpdocParserCore {\r
8 \r
9         /**\r
10         * Structure of an empty use entry.\r
11         * @var  array\r
12         */\r
13         var $emptyUse = array(\r
14                                                                                                         "type"  => "",\r
15                                                                                                         "file"  => "",\r
16                                                                                                         "undoc" => true\r
17                                                                                         );\r
18                                                                                         \r
19 \r
20         /**\r
21         * List of allowed tags in use doc comments.\r
22         * @var  array\r
23         */                                                                                              \r
24         var $useTags = array(\r
25                                                                                                 "return"                        => true,\r
26                                                                                                 \r
27                                                                                                 "see"                                   => true,\r
28                                                                                                 "link"                          => true,\r
29                                                                                                 \r
30                                                                                                 "authhor"                       => true,\r
31                                                                                                 "copyright"             => true,\r
32                                                                                                 \r
33                                                                                                 "version"                       => true,\r
34                                                                                                 "since"                         => true,\r
35                                                                                                 \r
36                                                                                                 "deprecated"    => true,\r
37                                                                                                 "deprec"                        => true,\r
38                                                                                                 \r
39                                                                                                 "include"                       => true,\r
40 \r
41                                                                                                 "exclude"                       => true,                                                                                                \r
42                                                                                                 "magic"                         => true,\r
43                                                                                                 "todo"                          => true\r
44                                                                                         );\r
45 \r
46         /**\r
47         * Takes the result from getPhpdocParagraphs() and interprets it.\r
48         * @param        array\r
49         */                                                                                      \r
50         function analyseUse($para) {\r
51                 \r
52                 $use = $this->emptyUse;\r
53                 $use["file"] = $para["file"];\r
54                 \r
55                 if (""!=$para["doc"]) {\r
56                 \r
57                         $use = $this->analyseTags($this->getTags($para["doc"]), $use, $this->useTags);\r
58                         \r
59                         list($msg, $use) = $this->checkParserErrors($use, "use (include and friends)");\r
60                         if (""!=$msg)\r
61                                 $this->warn->addDocWarning($this->currentFile, "use", $use["file"], $msg, "mismatch");\r
62                                 \r
63                         list($use["sdesc"], $use["desc"]) = $this->getDescription($para["doc"]);\r
64                         \r
65                         $use["undoc"] = false;\r
66                 }\r
67                 \r
68                 $use["type"] = $para["type"];\r
69 \r
70                 return $use;\r
71         } // end func analyseUse\r
72         \r
73 } // end class PhpdocUseParser\r
74 ?>