File: PhpdocModuleParser.php

package info (click to toggle)
php4 4.0.3pl1-0potato3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 15,168 kB
  • ctags: 20,556
  • sloc: ansic: 155,237; php: 10,827; sh: 9,608; yacc: 1,874; lex: 1,742; makefile: 788; java: 424; awk: 359; cpp: 335; perl: 181; xml: 57
file content (141 lines) | stat: -rw-r--r-- 3,947 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* Extracts modules and their documentation from php code.
* @author	Ulf Wendel <ulf.wendel@redsys.de>
* @version 0.1alpha
*/
class PhpdocModuleParser extends PhpdocConstantParser {

	/**
	* Empty hash that shows the structure of a module.
	* @var	array
	*/
	var $emptyModule = array(
	
														"name"				=> "",
														"group"				=> "",
														"undoc"				=> true,
														
														"functions"		=> array(),
														"consts"			=> array(),
														"uses"				=> array()
												);

	/**
	* List of tags allowed within a module doc comment.
	* @var	array	tagname => true
	*/													
	var $moduleTags = array(
														"module"			=> true,
														"modulegroup"	=> true,
														
														"access"			=> true,
														
														"see"					=> true,
														"link"				=> true,
														
														"author"			=> true,
														"copyright"		=> true,
														
														"version"			=> true,
														"since"				=> true,
														
														"deprecated"	=> true,
														"deprec"			=> true,
														
														"brother"			=> true,
														"sister"			=> true,
														
														"exclude"		=> true,
														
														"package"			=> true,
														
														"magic"				=> true,
														"todo"				=> true
												);

	/**
	* Hash of all module groups
	* @var	array
	*/
	var $moduleGroups = array();
	
	/**
	* Central module parsing function.
	*
	* @param	array		Array of parsing data
	* @return	array		
	* @see	analyseModuleDoc()
	*/
	function analyseModule($para) {
		
		$module = $this->analyseModuleDoc($para["modules"]);			
		unset($para["modules"]);

		$this->moduleGroups[$module["group"]][] = $module["name"];

		reset($para["functions"]);
		while (list($k, $data)=each($para["functions"]))
			$module["functions"][strtolower($data["name"])] = $this->analyseFunction($data);
		unset($para["functions"]);
			
		reset($para["consts"]);
		while (list($k, $data)=each($para["consts"]))
			$module["consts"][strtolower($data["name"])] = $this->analyseConstant($data);
		unset($para["const"]);
		
		reset($para["uses"]);
		while (list($k, $data)=each($para["uses"]))
			$module["uses"][strtolower($data["file"])] = $this->analyseUse($data);
		
		return $module;
	} // end func analyseModule
	
	/**
	* Extracts the allowed documentation tags out of a module doc comment.
	* 
	* @param	array	Module paragraph
	* @return	array		
	*/
	function analyseModuleDoc($para) {
	
		$module = $this->emptyModule;
		$module["name"] = (""!=$para["name"]) ? $para["name"] : $this->currentFile;
		$module["group"] = (""!=$para["group"]) ? $para["group"] : $this->currentFile;
		
		if ("missing" == $para["status"]) {
			
			$msg = "The file '$this->currentFile' does not contain any classes and seems to lack a module doc comment.";
			$this->warn->addDocWarning($this->currentFile, "module", $module["name"], $msg, "missing");
			
		} else if ("tags missing" == $para["status"]) {
		
			$msg = "The module doc comment does not contain a @module or @modulegroup tag, the module gets names: '$this->currentFile'";
			$this->warn->addDocWarning($this->currentFile, "module", $module["name"], $msg, "missing");
		
		}
		
		if (""!=$para["doc"]) {		
			
			$tags 	= $this->getTags($para["doc"]);
			$module = $this->analyseTags($tags, $module, $this->moduleTags);
			
			list($msg, $module) = $this->checkParserErrors($module, "module");
			if (""!=$msg) 
				$this->warn->addDocWarning($this->currentFile, "module", $module["name"], $msg, "mismatch");
			
			list($shortdesc, $fulldesc) = $this->getDescription($para["doc"]);			
			$module["sdesc"] = $shortdesc;
			$module["desc"]  = $fulldesc;
		
			$module["undoc"] = false;
		}

		unset($module["module"]);
		unset($module["modulegroup"]);
		
		return $module;		
	} // end analyseModuleDoc
	
} // end class PhpdocModuleParser
?>