3 * Provides functions to access phpdoc xml documents that contain classes.
\r
5 * @author Ulf Wendel <ulf.wendel@phpdoc.de>
\r
9 class PhpdocClassAccessor extends PhpdocDocumentAccessor {
\r
11 var $xmlkey = "class";
\r
14 * Array of inherited elements
\r
15 * @var array $inherited
\r
17 var $inherited = array();
\r
20 * Returns an array with the data of a class (no functions etc, just the class docs).
\r
21 * @return array $class
\r
24 function getClassdata() {
\r
26 $class = $this->xml["class"];
\r
28 unset($class["variable"]);
\r
29 unset($class["function"]);
\r
30 unset($class["uses"]);
\r
31 unset($class["constant"]);
\r
32 unset($class["inherited"]);
\r
33 unset($class["overriden"]);
\r
34 unset($class["path"]);
\r
37 } // end func getClassdata
\r
40 * Returns an array of inherited functions.
\r
43 * @see getInheritedVariables(), getInheritedUses(), getInheritedConstants()
\r
45 function getInheritedFunctions() {
\r
46 return $this->inherited["functions"];
\r
47 } // end func getInheritedFunctions
\r
50 * Returns an array of inherited variables.
\r
53 * @see getInheritedFunctions(), getInheritedUses(), getInheritedConstants()
\r
55 function getInheritedVariables() {
\r
56 return $this->inherited["variables"];
\r
57 } // end func getInheritedVariables
\r
60 * Returns an array of inherited included files.
\r
63 * @see getInheritedFunctions(), getInheritedUses(), getInheritedConstants()
\r
65 function getInheritedUses() {
\r
66 return $this->inherited["uses"];
\r
67 } // end func getInheritedUses()
\r
70 * Returns an array of inherited constants.
\r
73 * @see getInheritedFunctions(), getInheritedVariables(), getInheritedUses()
\r
75 function getInheritedConstants() {
\r
76 return $this->inherited["constants"];
\r
77 } // end func getInheritedConstants
\r
80 * Returns an array with the "path" of a class.
\r
81 * @return array $path
\r
83 * @see getSubclasses()
\r
85 function getClasstree() {
\r
87 if (isset($this->xml["class"]["path"]))
\r
88 return $this->convertPath($this->xml["class"]["path"]);
\r
92 } // end func getClasstree
\r
95 * Returns an array with all subclasses of a class.
\r
98 * @see getClasstree()
\r
100 function getSubclasses() {
\r
101 return $this->data["subclasses"];
\r
102 } // end func getSubclasses
\r
106 * Converts a xml path array to a path that can be passed to the user.
\r
108 * The path is an array like path[0..n] = classname where path[0] is the
\r
109 * directs parent (extends path[0]) and path[n] is the baseclass.
\r
111 * @param array $xmlpath
\r
112 * @return array $path
\r
114 function convertPath($xmlpath) {
\r
118 if (!isset($xmlpath["parent"][0])) {
\r
120 $path[0] = $xmlpath["parent"]["value"];
\r
124 reset($xmlpath["parent"]);
\r
125 while (list($k, $parent)=each($xmlpath["parent"]))
\r
126 $path[] = $parent["value"];
\r
131 } // end func convertPath
\r
134 * Builds a list of inherited elements.
\r
137 function buildInheritedlist() {
\r
139 $this->inherited = array(
\r
140 "functions" => array(),
\r
141 "variables" => array(),
\r
142 "constants" => array(),
\r
146 if (isset($this->xml["class"]["inherited"])) {
\r
148 if (isset($this->xml["class"]["inherited"][0])) {
\r
150 reset($this->xml["class"]["inherited"]);
\r
151 while (list($k, $inherited)=each($this->xml["class"]["inherited"])) {
\r
153 $type = $inherited["type"];
\r
154 $src = $inherited["src"];
\r
156 if (isset($inherited["element"][0])) {
\r
158 reset($inherited["element"]);
\r
159 while (list($k2, $element)=each($inherited["element"]))
\r
160 $this->inherited[$type][$src][] = $element["value"];
\r
164 $this->inherited[$type][$src][] = $inherited["element"]["value"];
\r
172 $inherited = $this->xml["class"]["inherited"];
\r
173 $type = $inherited["type"];
\r
174 $src = $inherited["src"];
\r
176 if (isset($inherited["element"][0])) {
\r
178 reset($inherited["element"]);
\r
179 while (list($k, $element)=each($inherited["element"]))
\r
180 $this->inherited[$type][$src][] = $element["value"];
\r
184 $this->inherited[$type][$src][] = $inherited["element"]["value"];
\r
190 unset($this->xml["class"]["inherited"]);
\r
194 } // end func buildInheritedlist
\r
197 * Builds a list of subclasses
\r
199 function buildSubclasslist() {
\r
201 $this->data["subclasses"] = array();
\r
203 if (isset($this->xml["class"]["subclasses"])) {
\r
205 if (isset($this->xml["class"]["subclasses"]["subclass"][0])) {
\r
207 reset($this->xml["class"]["subclasses"]["subclass"]);
\r
208 while (list($k, $subclass)=each($this->xml["class"]["subclasses"]["subclass"]))
\r
209 $this->data["subclasses"][] = $subclass["value"];
\r
213 $this->data["subclasses"][] = $this->xml["class"]["subclasses"]["subclass"]["value"];
\r
219 } // end func buildSubclasslist
\r
223 #$this->introspection("xml", $this->xml);
\r
225 $this->buildInheritedlist();
\r
226 $this->buildSubclasslist();
\r
228 list($this->data["functions"], $this->data["functionsaccess"]) = $this->getElementlist("function");
\r
229 list($this->data["variables"], $this->data["variablesaccess"]) = $this->getElementlist("variable");
\r
230 list($this->data["constants"], $this->data["constantsaccess"]) = $this->getElementlist("constant");
\r
232 $this->buildUseslist();
\r
234 #$this->introspection("data", $this->data);
\r
238 } // end class PhpdocClassAccessor
\r