3 * Base of the class and module accessor.
5 class PhpdocDocumentAccessor extends PhpdocAccessor {
8 * Kind of top-level container in the xml document.
10 * Must be set by all derived classes.
17 * Returns an array with all functions.
19 * @return array $functions
21 * @see getFunctionsByAccess()
23 function getFunctions() {
24 return $this->getElements("functions", "functionsaccess");
25 } // end func getFunctions
28 * Returns an array with all functions with a certain access (public, private) attribute.
30 * @param string Requested access attribute.
31 * @return array $functions
35 function getFunctionsByAccess($access) {
36 return $this->getElementsByAccess($access, "functions", "functionsaccess");
37 } // end func getFunctionByAccess
40 * Returns an array with all variables.
42 * @return array $variables
44 * @see getVariablesByAccess()
46 function getVariables() {
47 return $this->getElements("variables", "variablesaccess");
48 } // end func getVariables
51 * Returns an array with all variables with a certain access (public, private) attribute.
53 * @param string Requested access attribute.
54 * @return array $variables
58 function getVariablesByAccess($access) {
59 return $this->getElementsByAccess($access, "variables", "variablesaccess");
60 } // end func getVariablesByAccess
63 * Returns an array of all constants.
65 * @return array $constants
67 * @see getConstantsByAccess()
69 function getConstants() {
70 return $this->getElements("constants", "constantsaccess");
71 } // end func getConstants
74 * Returns an array of all constants with a certain access (public, private) attribute.
76 * @param string Requested access attribute.
77 * @return array $constants
81 function getConstantsByAccess($access) {
82 return $this->getElementsByAccess($access, "constants", "constantsaccess");
83 } // end func getConstantsByAccess
86 * Returns an array of all included files.
89 * @see getUsesByType()
93 return $this->getElements("uses", "usestype");
97 * Returns an array of all included files with a certain type (include, require...) attribute.
99 * @param string Requested type: include, include_once, require, require_once
100 * @return array $uses
103 function getUsesByType($type) {
107 if (!isset($this->data["usestype"][$type]))
110 reset($this->data["usestype"][$type]);
111 while (list($k, $file)=each($this->data["usestype"][$type])) {
113 $data[$file] = $this->data["uses"][$file];
114 if ($this->freeOnGet)
115 unset($this->data["uses"][$file]);
119 if ($this->freeOnGet)
120 unset($this->data["usestype"][$type]);
123 } // end func getUsesByType
126 * Returns elements from the internal $data array.
128 * The object uses this function to extract functions, variables, uses and
129 * constants from an internal array. Note that this is not a public function,
130 * future version might access internal data structures different.
132 * @param string Name of the element you need: functions, variables,...
133 * @param string Name of internal element access table
136 function getElements($element, $elementaccess) {
138 if ($this->freeOnGet) {
140 $data = $this->data[$element];
141 unset($this->data[$element]);
142 unset($this->data[$elementaccess]);
147 $this->data[$element];
151 } // end func getElements
154 * Returns elements with a certain access type from the internal data.
155 * @param string Accesstype
156 * @param string element name
157 * @param string access type
158 * @brother getElements()
160 function getElementsByAccess($access, $element, $elementaccess) {
164 if (!isset($this->data[$elementaccess][$access]))
167 reset($this->data[$elementaccess][$access]);
168 while (list($k, $name)=each($this->data[$elementaccess][$access])) {
170 $data[$name] = $this->data[$element][$name];
171 if ($this->freeOnGet)
172 unset($this->data[$element][$name]);
176 if ($this->freeOnGet)
177 unset($this->data[$elementaccess][$access]);
180 } // end func getElementsByAccess
183 * Adds a list of included files to the internal data array.
185 function buildUseslist() {
187 $this->data["uses"] = array();
188 $this->data["usestype"] = array();
190 if (isset($this->xml[$this->xmlkey]["uses"])) {
192 if (isset($this->xml[$this->xmlkey]["uses"][0])) {
194 reset($this->xml[$this->xmlkey]["uses"]);
195 while (list($k, $data)=each($this->xml[$this->xmlkey]["uses"])) {
196 $this->data["uses"][$data["file"]] = $data;
197 $this->data["usestype"][$data["type"]][] = $data["file"];
202 $data = $this->xml[$this->xmlkey]["uses"];
203 $this->data["uses"][$data["file"]] = $data;
204 $this->data["usestype"][$data["type"]][] = $data["file"];
208 unset($this->xml[$this->xmlkey]["uses"]);
211 } // end func buildUseslist
214 * Adds a list of a certain element to the internal data array.
216 * @param string name of the element to add: function, variable, constant.
218 function getElementlist($element) {
221 $elementaccess = array();
223 if (isset($this->xml[$this->xmlkey][$element])) {
225 if (isset($this->xml[$this->xmlkey][$element][0])) {
227 reset($this->xml[$this->xmlkey][$element]);
228 while (list($k, $data)=each($this->xml[$this->xmlkey][$element])) {
229 $elements[$data["name"]] = $data;
230 $elementaccess[$data["access"]][] = $data["name"];
235 $data = $this->xml[$this->xmlkey][$element];
236 $elements[$data["name"]] = $data;
237 $elementaccess[$data["access"]][] = $data["name"];
241 unset($this->xml[$this->xmlkey][$element]);
245 return array($elements, $elementaccess);
246 } // end func getElementlist
248 } // end class PhpdocDocumentAccessor