File: PhpdocClassAccessor.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 (239 lines) | stat: -rw-r--r-- 5,723 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<?php
/**
* Provides functions to access phpdoc xml documents that contain classes.
*
* @author		Ulf Wendel <ulf.wendel@phpdoc.de>
* @version 	1.0	
* @package	PHPDoc
*/
class PhpdocClassAccessor extends PhpdocDocumentAccessor {

	var $xmlkey = "class";
	
	/**
	* Array of inherited elements
	* @var	array	$inherited
	*/	
	var $inherited = array();
	
	/**
	* Returns an array with the data of a class (no functions etc, just the class docs).
	* @return	array	$class
	* @access	public
	*/
	function getClassdata() {
		
		$class = $this->xml["class"];

		unset($class["variable"]);
		unset($class["function"]);
		unset($class["uses"]);
		unset($class["constant"]);
		unset($class["inherited"]);
		unset($class["overriden"]);
		unset($class["path"]);
		
		return $class;
	} // end func getClassdata
	
	/**
	* Returns an array of inherited functions.
	* @return	array	
	* @access	public
	* @see	getInheritedVariables(), getInheritedUses(), getInheritedConstants()
	*/
	function getInheritedFunctions() {
		return $this->inherited["functions"];
	} // end func getInheritedFunctions

	/**
	* Returns an array of inherited variables.
	* @return	array
	* @access	public
	* @see	getInheritedFunctions(), getInheritedUses(), getInheritedConstants()
	*/	
	function getInheritedVariables() {
		return $this->inherited["variables"];
	} // end func getInheritedVariables
	
	/**
	* Returns an array of inherited included files.
	* @return	array
	* @access	public
	* @see		getInheritedFunctions(), getInheritedUses(), getInheritedConstants()
	*/
	function getInheritedUses() {
		return $this->inherited["uses"];
	} // end func getInheritedUses()
	
	/**
	* Returns an array of inherited constants.
	* @return	array
	* @access	public
	* @see		getInheritedFunctions(), getInheritedVariables(), getInheritedUses()
	*/
	function getInheritedConstants() {
		return $this->inherited["constants"];
	} // end func getInheritedConstants
	
	/**
	* Returns an array with the "path" of a class.
	* @return array $path
	* @access	public
	* @see		getSubclasses()
	*/	
	function getClasstree() {
		
		if (isset($this->xml["class"]["path"]))
			return $this->convertPath($this->xml["class"]["path"]);
		else 
			return array();
			
	} // end func getClasstree
	
	/**
	* Returns an array with all subclasses of a class.
	* @return	array
	* @access	public
	* @see		getClasstree()
	*/
	function getSubclasses() {
		return $this->data["subclasses"];
	} // end func getSubclasses
	

	/**
	* Converts a xml path array to a path that can be passed to the user.
	* 
	* The path is an array like path[0..n] = classname where path[0] is the 
	* directs parent (extends path[0]) and path[n] is the baseclass.
	*
	* @param	array	$xmlpath
	* @return	array	$path
	*/
	function convertPath($xmlpath) {

		$path = array();
		
		if (!isset($xmlpath["parent"][0])) {
			
			$path[0] = $xmlpath["parent"]["value"];		
				
		} else {
		
			reset($xmlpath["parent"]);
			while (list($k, $parent)=each($xmlpath["parent"]))
				$path[] = $parent["value"];
				
		}

		return $path;
	} // end func convertPath
	
	/**
	* Builds a list of inherited elements.
	* @see	$inherited
	*/
	function buildInheritedlist() {
		
		$this->inherited = array(
															"functions"	=> array(),
															"variables"	=> array(),
															"constants"	=> array(),
															"uses"			=> array()
														);
			
		if (isset($this->xml["class"]["inherited"])) {

			if (isset($this->xml["class"]["inherited"][0])) {
			
				reset($this->xml["class"]["inherited"]);
				while (list($k, $inherited)=each($this->xml["class"]["inherited"])) {
						
					$type = $inherited["type"];
					$src	= $inherited["src"];
		
					if (isset($inherited["element"][0])) {
					
						reset($inherited["element"]);
						while (list($k2, $element)=each($inherited["element"])) 
							$this->inherited[$type][$src][] = $element["value"];
							
					}	else {
					
						$this->inherited[$type][$src][] = $inherited["element"]["value"];
						
					}
					
				}
			
			}	else {
				
				$inherited = $this->xml["class"]["inherited"];
				$type			 = $inherited["type"];
				$src			 = $inherited["src"];
				
				if (isset($inherited["element"][0])) {
					
					reset($inherited["element"]);
					while (list($k, $element)=each($inherited["element"])) 
						$this->inherited[$type][$src][] = $element["value"];
						
				} else {
				
					$this->inherited[$type][$src][] = $inherited["element"]["value"];
					
				}

			}
			
			unset($this->xml["class"]["inherited"]);
			
		}
			
	} // end func buildInheritedlist
	
	/**
	* Builds a list of subclasses
	*/
	function buildSubclasslist() {
		
		$this->data["subclasses"] = array();
		
		if (isset($this->xml["class"]["subclasses"])) {
		
			if (isset($this->xml["class"]["subclasses"]["subclass"][0])) {

				reset($this->xml["class"]["subclasses"]["subclass"]);
				while (list($k, $subclass)=each($this->xml["class"]["subclasses"]["subclass"]))
					$this->data["subclasses"][] = $subclass["value"];

			} else {

				$this->data["subclasses"][] = $this->xml["class"]["subclasses"]["subclass"]["value"];
				
			}

		}
		
	} // end func buildSubclasslist
	
	function init() {

		#$this->introspection("xml", $this->xml);
		
		$this->buildInheritedlist();
		$this->buildSubclasslist();
		
		list($this->data["functions"], $this->data["functionsaccess"]) = $this->getElementlist("function");		
		list($this->data["variables"], $this->data["variablesaccess"]) = $this->getElementlist("variable");
		list($this->data["constants"], $this->data["constantsaccess"]) = $this->getElementlist("constant");
		
		$this->buildUseslist();		
		
		#$this->introspection("data", $this->data);

	} // end func Init
	
} // end class PhpdocClassAccessor
?>