3 * Parser Elements, all classes representing documentable elements
\r
5 * phpDocumentor :: automatic documentation generator
\r
7 * PHP versions 4 and 5
\r
9 * Copyright (c) 2002-2006 Gregory Beaver
\r
13 * This library is free software; you can redistribute it
\r
14 * and/or modify it under the terms of the GNU Lesser General
\r
15 * Public License as published by the Free Software Foundation;
\r
16 * either version 2.1 of the License, or (at your option) any
\r
19 * This library is distributed in the hope that it will be useful,
\r
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
22 * Lesser General Public License for more details.
\r
24 * You should have received a copy of the GNU Lesser General Public
\r
25 * License along with this library; if not, write to the Free Software
\r
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
28 * @package phpDocumentor
\r
29 * @subpackage ParserElements
\r
30 * @author Gregory Beaver <cellog@php.net>
\r
31 * @copyright 2002-2006 Gregory Beaver
\r
32 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
33 * @version CVS: $Id: ParserElements.inc,v 1.19 2007/04/24 21:30:50 ashnazg Exp $
\r
34 * @link http://www.phpdoc.org
\r
35 * @link http://pear.php.net/PhpDocumentor
\r
36 * @see Parser, WordParser
\r
41 * all elements except {@link parserPackagePage} descend from this abstract class
\r
43 * @package phpDocumentor
\r
44 * @subpackage ParserElements
\r
45 * @author Greg Beaver <cellog@php.net>
\r
47 * @version $Id: ParserElements.inc,v 1.19 2007/04/24 21:30:50 ashnazg Exp $
\r
49 class parserElement extends parserBase
\r
52 * @var mixed either false or a {@link parserDocBlock}
\r
54 var $docblock = false;
\r
56 * name of this element, or include type if element is a {@link parserInclude}
\r
61 * @var mixed either false or an array of paths to files with conflicts
\r
63 var $conflicts = false;
\r
66 * location of this element (filename)
\r
72 * full path location of this element (filename)
\r
78 * line number on file where this element stops
\r
80 * @var false|integer
\r
82 var $endlinenumber = 0;
\r
85 * Line number in the source on which this element appears
\r
87 * @var false|integer
\r
89 var $linenumber = false;
\r
92 * @param parserDocBlock
\r
94 function setDocBlock($docblock)
\r
96 $this->docblock = $docblock;
\r
102 function setName($name)
\r
104 $this->name = trim($name);
\r
108 * Set starting line number
\r
111 function setLineNumber($number)
\r
113 $this->linenumber = $number;
\r
117 * Sets the ending line number of elements
\r
120 function setEndLineNumber($l)
\r
122 $this->endlinenumber = $l;
\r
128 function getLineNumber()
\r
130 return $this->linenumber;
\r
136 function getEndLineNumber()
\r
138 return $this->endlinenumber;
\r
141 /** @return string package containing this element */
\r
142 function getPackage()
\r
144 if ($this->docblock)
\r
146 return $this->docblock->package;
\r
147 } else return $GLOBALS['phpDocumentor_DefaultPackageName'];
\r
150 /** @param string */
\r
151 function setFile($file)
\r
153 $this->file = $file;
\r
156 /** @param string */
\r
157 function setPath($file)
\r
159 // look for special windows case
\r
160 if(SMART_PATH_DELIMITER === '\\')
\r
161 $this->path = strtr($file,'/','\\');
\r
163 $this->path = $file;
\r
164 $this->path = $file;
\r
172 if (!isset($this->name)) return false;
\r
173 return $this->name;
\r
181 if (!isset($this->file)) return false;
\r
182 return $this->file;
\r
190 if (!isset($this->path)) return false;
\r
191 return $this->path;
\r
196 * @package phpDocumentor
\r
197 * @subpackage ParserElements
\r
198 * @author Greg Beaver <cellog@php.net>
\r
200 * @version $Id: ParserElements.inc,v 1.19 2007/04/24 21:30:50 ashnazg Exp $
\r
202 class parserInclude extends parserElement
\r
205 * Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
\r
206 * @var string always 'include'
\r
208 var $type = 'include';
\r
212 * @package phpDocumentor
\r
213 * @subpackage ParserElements
\r
214 * @author Greg Beaver <cellog@php.net>
\r
216 * @version $Id: ParserElements.inc,v 1.19 2007/04/24 21:30:50 ashnazg Exp $
\r
218 class parserGlobal extends parserElement
\r
221 * Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
\r
222 * @var string always 'global'
\r
224 var $type = 'global';
\r
227 * Name of the global's data type
\r
230 var $datatype = 'mixed';
\r
233 * quick way to link to this element
\r
234 * @return mixed converter-specific link to this global variable
\r
236 * @param string text to display for the link or false for default text
\r
238 function getLink(&$c, $text = false, $returnobj = false)
\r
242 return $c->getLink('global ' . $this->name, $this->docblock->package);
\r
244 return $c->getGlobalLink($this->name, $this->docblock->package, $this->path, $text);
\r
248 * Returns all global variables in other packages that have the same name as this global variable
\r
249 * @return mixed false or an array Format: (package => {@link parserGlobal} of conflicting global variable)
\r
252 function getConflicts(&$c)
\r
254 $a = $c->proceduralpages->getGlobalConflicts($this->name);
\r
255 unset($a[$this->docblock->package]);
\r
260 * Sets the name of the global variable's type
\r
263 function setDataType($type)
\r
265 $this->datatype = $type;
\r
269 * Retrieve converter-specific representation of the data type
\r
271 * If the data type is a documented class name, then this function will
\r
272 * return a Converter-specific link to that class's documentation, so users
\r
273 * can click/browse to the documentation directly from the global variable
\r
278 function getDataType(&$converter)
\r
280 $converted_datatype = $this->datatype;
\r
281 if (strpos($this->datatype,'|'))
\r
284 $types = explode('|',$this->datatype);
\r
285 foreach($types as $returntype)
\r
287 $a = $converter->getLink($returntype);
\r
288 if (is_object($a) && phpDocumentor_get_class($a) == 'classlink')
\r
290 if (!empty($my_types)) $my_types .= '|';
\r
291 $my_types .= $converter->returnSee($a,$converter->type_adjust($returntype));
\r
294 if (!empty($my_types)) $my_types .= '|';
\r
295 $my_types .= $converter->type_adjust($returntype);
\r
298 $converted_datatype = $my_types;
\r
301 $a = $converter->getLink($this->datatype);
\r
302 if (is_object($a) && phpDocumentor_get_class($a) == 'classlink')
\r
304 $converted_datatype = $converter->returnSee($a,$converter->type_adjust($this->datatype));
\r
307 $converted_dataype = $converter->type_adjust($this->datatype);
\r
310 return $converted_datatype;
\r
316 * @package phpDocumentor
\r
317 * @subpackage ParserElements
\r
318 * @author Greg Beaver <cellog@php.net>
\r
320 * @version $Id: ParserElements.inc,v 1.19 2007/04/24 21:30:50 ashnazg Exp $
\r
322 class parserFunction extends parserElement
\r
325 * Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
\r
326 * @var string always 'function'
\r
328 var $type = 'function';
\r
330 * parameters parsed from function definition.
\r
332 * param name may be null, in which case, updateParams() must be called from the Converter
\r
333 * @var array Format: array(param name => default value parsed from function definition)
\r
334 * @see updateParams()
\r
336 var $params = false;
\r
338 * Function returns a reference to an element, instead of a value
\r
340 * set to true if function is declared as:
\r
342 * function &func(...
\r
346 var $returnsreference = false;
\r
348 * global declarations parsed from function definition
\r
350 * @var array Format: array(globalname1, globalname2,....)
\r
352 var $globals = false;
\r
354 * static variable declarations parsed from function definition
\r
355 * @var array Format: array(array('name' => staticvar1,'val' => '' or default val of staticvar1),...)
\r
357 var $statics = false;
\r
363 * @param string default value parsed from function definition
\r
364 * @param boolean indicates whether this parameter has a default value
\r
365 * @param null|string class type hint
\r
367 function addParam($name, $value, $has_default = true, $typehint = null)
\r
369 $this->params[$name] = array($value, $has_default);
\r
370 if (isset($typehint))
\r
372 $this->params[$name][2] = $typehint;
\r
377 * Set the source code. Always array in PHP 4.3.0+
\r
378 * @param string|array
\r
380 function addSource($source)
\r
382 $this->source = $source;
\r
386 * Determine whether the source code has been requested via {@}source}
\r
389 function hasSource()
\r
391 if (is_array($this->source)) return true;
\r
392 return strlen($this->source);
\r
396 * @return string|array source code ready for highlighting
\r
398 function getSource()
\r
400 return $this->source;
\r
404 * quick way to link to this element
\r
405 * @return mixed converter-specific link to this function
\r
407 * @param string text to display for the link or false for default text
\r
409 function getLink($c, $text = false, $returnobj = false)
\r
413 return $c->getLink('function ' . $this->name, $this->docblock->package);
\r
415 return $c->getFunctionLink($this->name, $this->docblock->package, $this->path, $text);
\r
419 * Returns all functions in other packages that have the same name as this function
\r
420 * @return mixed false or an array Format: (package => {@link parserFunction} of conflicting functions)
\r
423 function getConflicts(&$c)
\r
425 $a = $c->proceduralpages->getFuncConflicts($this->name);
\r
426 unset($a[$this->docblock->package]);
\r
431 * Add all "global $var, $var2" declarations to this function
\r
432 * @param array $globals Format: array(globalname1, globalname2,....)
\r
434 function addGlobals($globals)
\r
436 $this->globals = $globals;
\r
440 * Add all "static $var, $var2 = 6" declarations to this function
\r
441 * @param array Format: array(varname1, varname2,...)
\r
442 * @param array Format: array(default val of var 1, default val of var 2,...) if var 1 has no default, array(default val of var 2,...)
\r
444 function addStatics($static,$vals)
\r
446 if (count($static))
\r
448 $this->statics = array();
\r
449 for($i=0;$i<count($static);$i++)
\r
451 if (isset($static[$i]))
\r
454 if (isset($vals[$i])) $a = $vals[$i];
\r
455 $this->statics[] = array('name' => $static[$i],'val' => $a);
\r
462 * @return string default value of param $name
\r
465 function getParam ($name)
\r
467 if (!isset($this->params[$name])) return false;
\r
468 $test = $this->params[$name];
\r
471 return $this->params[$name];
\r
479 * @return array format: array(array(paramname, default value),...)
\r
481 function listParams ()
\r
483 if (isset($this->params))
\r
487 foreach($this->params as $key => $val)
\r
491 $arr = array($key,$val[0]);
\r
492 if (isset($val[2]))
\r
499 $arr = array($key,false);
\r
500 if (isset($val[2]))
\r
514 * @return array format: array(array(index, globalname),...)
\r
516 function listGlobals ()
\r
518 if (isset($this->globals))
\r
521 if ($this->globals)
\r
522 foreach($this->globals as $key => $val)
\r
524 $ret[] = array($key,$val);
\r
533 * @return array format: array(array(static var name, static var default value),...)
\r
535 function listStatics ()
\r
537 if (isset($this->statics))
\r
540 if ($this->statics)
\r
541 foreach($this->statics as $key => $val)
\r
543 $ret[] = array($val['name'],$val['val']);
\r
552 * sets {@link $returnsreference} to true
\r
554 function setReturnsReference()
\r
556 $this->returnsreference = true;
\r
560 * @return boolean returns value of {@link $returnsreference}
\r
562 function getReturnsReference()
\r
564 return $this->returnsreference;
\r
568 * Get a human-friendly description of the function call
\r
570 * takes declaration like:
\r
572 * /** @returns string ... {rest of docblock}
\r
573 * function &func($param1, $param2 = 6,
\r
574 * $param3 = array('20',9 => "heroo"))
\r
578 * string &func( $param1, [$param2 = 6], [$param3 = array('20',9 => "heroo")] )
\r
579 * @return string stylized function declaration
\r
581 function getFunctionCall()
\r
584 if ($this->getReturnsReference()) $a = '&';
\r
585 $function_call = $a.$this->getName() . " ( ";
\r
587 foreach($this->listParams() as $param)
\r
593 $function_call .= ", ";
\r
595 if ($param[1] !== false)
\r
597 $function_call .= "[$param[0] = $param[1]]";
\r
599 $function_call .= $param[0];
\r
601 $update_params[] = $param[0];
\r
603 $function_call .= " )";
\r
604 return $function_call;
\r
608 * Like getFunctionCall(), but has no English or pre-determined formatting.
\r
610 * Much more flexible.
\r
611 * @return array Format:
\r
613 * array('name' => function name,
\r
614 * 'returnsref' => boolean if declared as "function &name()"
\r
615 * 'params' => array('type' => data type of parameter,
\r
616 * 'description' => from @param tag,
\r
617 * 'name' => variable name,
\r
618 * 'default' => default value if any))
\r
620 * @see getFunctionCall()
\r
622 function getIntricateFunctionCall($converter,$paramtags)
\r
625 if ($this->getReturnsReference()) $a['returnsref'] = true;
\r
626 $a['name'] = $converter->type_adjust($this->getName());
\r
627 $c = $this->listParams();
\r
628 foreach($c as $param)
\r
631 $b['type'] = 'mixed';
\r
632 if (isset($paramtags[$param[0]]))
\r
634 $b['type'] = $paramtags[$param[0]]['datatype'];
\r
635 $b['description'] = $paramtags[$param[0]]['data'];
\r
636 unset($paramtags[$param[0]]);
\r
637 } elseif(isset($paramtags[substr($param[0],1)]))
\r
639 $b['type'] = $paramtags[substr($param[0],1)]['datatype'];
\r
640 $b['description'] = $paramtags[substr($param[0],1)]['data'];
\r
641 unset($paramtags[substr($param[0],1)]);
\r
643 if (isset($param[2]))
\r
645 $link = $converter->getLink('object ' . $param[2]);
\r
647 $link = $converter->returnSee($link, $param[2], true);
\r
648 $b['type'] = $link;
\r
650 $b['type'] = $param[2];
\r
653 $b['name'] = $param[0];
\r
654 $b['default'] = $converter->postProcess($param[1]);
\r
655 $b['hasdefault'] = ($param[1] !== false);
\r
656 $a['params'][] = $b;
\r
658 // @param tags that don't correspond to actual parameters (like extra function values)
\r
659 if (count($paramtags))
\r
661 foreach($paramtags as $param)
\r
664 $b['type'] = $param['datatype'];
\r
665 $b['description'] = $param['data'];
\r
666 $b['name'] = $param['var'];
\r
667 $b['default'] = '';
\r
668 $b['hasdefault'] = false;
\r
669 $a['params'][] = $b;
\r
677 * @package phpDocumentor
\r
678 * @subpackage ParserElements
\r
679 * @author Greg Beaver <cellog@php.net>
\r
681 * @version $Id: ParserElements.inc,v 1.19 2007/04/24 21:30:50 ashnazg Exp $
\r
683 class parserClass extends parserElement
\r
686 * Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
\r
687 * @var string always 'class'
\r
689 var $type = 'class';
\r
691 * @see parserPage::$sourceLocation */
\r
692 var $sourceLocation = '';
\r
694 * @var mixed false or contents of extends clause in class declaration
\r
696 var $extends = false;
\r
698 * @var array a list of interfaces this class implements
\r
700 var $_implements = array();
\r
702 * @var array a list of interfaces this class implements
\r
705 var $_modifiers = false;
\r
707 * @var boolean determines whether a class is considered to be an interface
\r
710 var $_isInterface = false;
\r
712 * Format: array(file, parent) where parent class is found or false if no parent
\r
715 var $parent = false;
\r
717 * Used to determine whether a class should be ignored or not. Helps maintain integrity of parsing
\r
719 * @see Classes::getParentClass()
\r
721 var $ignore = false;
\r
724 * @var string same as {@link parserElement::$path}
\r
726 var $curfile = false;
\r
728 * @var tutorialLink|false either a link to the tutorial associated with this class, or false
\r
730 var $tutorial = false;
\r
733 * Get the PHP5+ modifiers for this class
\r
734 * (abstract/final/static/private/protected/public)
\r
735 * @return array|false
\r
737 function getModifiers()
\r
739 return $this->_modifiers;
\r
743 * Set the PHP5+ modifiers for this class
\r
744 * (abstract/final/static/private/protected/public)
\r
747 function setModifiers($m)
\r
749 $this->_modifiers = $m;
\r
753 * @param parserTutorial
\r
756 function addTutorial($t,&$c)
\r
758 $this->tutorial = new tutorialLink;
\r
759 $this->tutorial->addLink('',$t->path,$t->name,$t->package,$t->subpackage,$t->getTitle($c));
\r
763 * Get the associated tutorial for this class, if any
\r
764 * @tutorial tutorials.pkg
\r
765 * @return parserTutorial
\r
767 function getTutorial()
\r
769 return $this->tutorial;
\r
773 * Returns all classes in other packages that have the same name as this class
\r
774 * @return mixed false or an array Format: (package => {@link parserClass} of conflicting classes)
\r
777 function getConflicts(&$c)
\r
779 $a = $c->classes->getConflicts($this->name);
\r
780 unset($a[$this->docblock->package]);
\r
785 * quick way to link to this element
\r
786 * @return mixed converter-specific link to this class
\r
788 * @param string text to display for the link or false for default text
\r
790 function getLink($c, $text = false, $returnobj = false)
\r
794 return $c->getLink('object ' . $this->name, $this->docblock->package);
\r
796 return $c->getClassLink($this->name, $this->docblock->package, $this->curfile, $text);
\r
800 * @param string parent class name
\r
801 * @param string parent class file
\r
802 * @param Classes {@link Classes} object currently calling setParent
\r
803 * @see Classes::setClassParent()
\r
806 function setParent($p,$f, &$c)
\r
808 $this->parent = array($f, $p);
\r
809 $p = $c->getClass($p, $f);
\r
810 // inherit package if no @package tag is in the docblock, fixes 591396
\r
811 if (!$this->docblock->getExplicitPackage())
\r
813 $this->docblock->package = $p->docblock->package;
\r
815 if ($this->docblock->package == $p->docblock->package)
\r
817 if ($this->docblock->subpackage == '')
\r
818 $this->docblock->subpackage = $p->docblock->subpackage;
\r
820 $author = $p->docblock->getKeyword('author');
\r
821 $version = $p->docblock->getKeyword('version');
\r
822 $copyright = $p->docblock->getKeyword('copyright');
\r
824 if (!$this->docblock->getKeyword('author'))
\r
826 if ($author && !is_array($author)) $author = array($author);
\r
827 if ($author) $this->docblock->tags['author'] = $author;
\r
829 if (!$this->docblock->getKeyword('version'))
\r
831 if ($version && !is_array($version)) $version = array($version);
\r
832 if ($version) $this->docblock->tags['version'] = $version;
\r
834 if (!$this->docblock->getKeyword('copyright'))
\r
836 if ($copyright && !is_array($copyright)) $copyright = array($copyright);
\r
837 if ($copyright) $this->docblock->tags['copyright'] = $copyright;
\r
839 if (!$this->docblock->sdesc)
\r
841 $this->docblock->setShortDesc($p->docblock);
\r
842 $this->docblock->setDesc($p->docblock);
\r
845 if ($this->docblock->hasInheritDoc())
\r
847 $this->docblock->replaceInheritDoc($p->docblock);
\r
853 * @param string $par parent class name (used by {@link Classes::setClassParent()} if parent class not found
\r
855 function setParentNoClass($par)
\r
857 $this->parent = $par;
\r
861 * Use this method to set the type of class to be an interface
\r
863 function setInterface()
\r
865 $this->_isInterface = true;
\r
869 * @return boolean true if this is an interface class
\r
871 function isInterface()
\r
873 return $this->_isInterface;
\r
877 * Use this method to set access modifiers for a class
\r
880 function setAccessModifiers($modifiers)
\r
882 $this->_modifiers = $modifiers;
\r
886 * retrieve object that represents the parent class
\r
887 * @param Converter this function will not work before the Conversion stage of parsing
\r
888 * @return mixed returns the {@link parserClass} representation of the parent class, or false if no parent class
\r
890 function &getParent(&$c)
\r
893 if (!$this->parent) return $a;
\r
894 if (is_array($this->parent))
\r
896 return $c->classes->getClass($this->parent[1],$this->parent[0]);
\r
897 } else return $this->parent;
\r
901 * @param Converter this function will not work before the Conversion stage of parsing
\r
902 * @return array returns a simple array of method objects
\r
904 function getMethods(&$c)
\r
906 return $c->classes->getMethods($this->name,$this->curfile);
\r
910 * @return mixed {@link parserMethod} or false if not found
\r
911 * @param Converter this function will not work before the Conversion stage of parsing
\r
912 * @param string method name in this class
\r
913 * @param boolean determines whether to search inherited methods as well
\r
915 function getMethod(&$c, $name, $inherited = false)
\r
917 $ret = $c->classes->getMethod($this->name, $this->curfile, $name);
\r
918 if ($ret) return $ret;
\r
921 while ($x->parent && is_array($x->parent)) {
\r
922 $par = $x->getParent($c);
\r
924 if ($meth = $x->getMethod($c, $name)) return $meth;
\r
931 * @return mixed {@link parserVar} or false if not found
\r
932 * @param Converter this function will not work before the Conversion stage of parsing
\r
933 * @param string var name in this class
\r
935 function getVar(&$c, $name)
\r
937 return $c->classes->getVar($this->name,$this->curfile,$name);
\r
941 * @param Converter this function will not work before the Conversion stage of parsing
\r
942 * @return array returns a simple array of method name strings
\r
944 function getMethodNames(&$c)
\r
946 if (!$c->classes->hasMethods($this->curfile, $this->name)) return array();
\r
948 $arr1 = $this->getMethods($c);
\r
949 for($i=0; $i < count($arr1); $i++)
\r
951 $arr[] = $arr1[$i]->name;
\r
957 * @param Converter this function will not work before the Conversion stage of parsing
\r
958 * @param string method name
\r
959 * @param boolean determines whether to search inherited methods as well
\r
960 * @return boolean whether this class has a method of name $name
\r
962 function hasMethod(&$c, $name, $inherited = false)
\r
964 $ret = $c->classes->hasMethod($this->name, $this->curfile, $name);
\r
965 if ($ret) return $ret;
\r
968 while ($x->parent && is_array($x->parent)) {
\r
969 $par = $x->getParent($c);
\r
971 if ($x->hasMethod($c, $name)) return true;
\r
978 * @param Converter this function will not work before the Conversion stage of parsing
\r
979 * @param string var name
\r
980 * @return boolean whether this class has a var of name $name
\r
982 function hasVar(&$c,$name)
\r
984 return $c->classes->hasVar($this->name, $this->curfile, $name);
\r
988 * @param Converter this function will not work before the Conversion stage of parsing
\r
989 * @param string class constant name
\r
990 * @return boolean whether this class has a constant of name $name
\r
992 function hasConst(&$c,$name)
\r
994 return $c->classes->hasConst($this->name, $this->curfile, $name);
\r
998 * @param Converter this function will not work before the Conversion stage of parsing
\r
999 * @return array returns a simple array of var objects
\r
1001 function getVars(&$c)
\r
1003 return $c->classes->getVars($this->name,$this->curfile);
\r
1007 * @param Converter this function will not work before the Conversion stage of parsing
\r
1008 * @return array returns a simple array of const objects
\r
1010 function getConsts(&$c)
\r
1012 return $c->classes->getConsts($this->name,$this->curfile);
\r
1016 * @param Converter this function will not work before the Conversion stage of parsing
\r
1017 * @return array returns a simple array of var name strings
\r
1019 function getVarNames(&$c)
\r
1021 if (!$c->classes->hasVars($this->curfile, $this->name)) return array();
\r
1023 $arr1 = $this->getVars($c);
\r
1024 for($i=0; $i < count($arr1); $i++)
\r
1026 $arr[] = $arr1[$i]->name;
\r
1032 * @param Converter this function will not work before the Conversion stage of parsing
\r
1033 * @return array returns a simple array of const name strings
\r
1035 function getConstNames(&$c)
\r
1037 if (!$c->classes->hasConsts($this->curfile, $this->name)) return array();
\r
1039 $arr1 = $this->getConsts($c);
\r
1040 for($i=0; $i < count($arr1); $i++)
\r
1042 $arr[] = $arr1[$i]->name;
\r
1048 * @param Converter this function will not work before the Conversion stage of parsing
\r
1049 * @param boolean determines whether overriden methods should be included in the list of inherited methods
\r
1050 * @return array returns an array of methods by parent classname array(name => array(method1,method2..),name2 => array(method1....))
\r
1052 function getInheritedMethods(&$c,$override = false)
\r
1054 $x = $oldx = $this;
\r
1055 $methods = array();
\r
1057 while ($x->parent && is_array($x->parent))
\r
1059 $methods = array_merge($methods,$x->getMethodNames($c));
\r
1060 $par = $x->getParent($c);
\r
1061 $parmethodnames = $par->getMethodNames($c);
\r
1062 $parmethods = $par->getMethods($c);
\r
1063 for($i=0; $i<count($parmethodnames); $i++)
\r
1067 if (!in_array($parmethodnames[$i],$methods))
\r
1069 // fix for bug 587733
\r
1070 if ($parmethods[$i]->docblock && $parmethods[$i]->docblock->hasaccess && !$c->parseprivate && $parmethods[$i]->docblock->tags['access'][0]->value == 'private')
\r
1074 $methods[] = $parmethodnames[$i];
\r
1075 $arr[$par->getName()]['methods'][] = $parmethods[$i];
\r
1076 $arr[$par->getName()]['file'] = $par->curfile;
\r
1080 // fix for bug 587733
\r
1081 if ($parmethods[$i]->docblock && $parmethods[$i]->docblock->hasaccess && !$c->parseprivate && $parmethods[$i]->docblock->tags['access'][0]->value == 'private')
\r
1085 $arr[$par->getName()]['methods'][] = $parmethods[$i];
\r
1086 $arr[$par->getName()]['file'] = $par->curfile;
\r
1092 if (is_a($oldx, 'parserClass') && is_a($oldx->getExtends(true), 'ReflectionClass')) {
\r
1093 $extends = $oldx->getExtends(true);
\r
1094 foreach ($extends->getMethods() as $method) {
\r
1095 $var = new parserMethod($oldx->getExtends());
\r
1096 if ($method->returnsReference()) {
\r
1097 $var->setReturnsReference();
\r
1099 $doc = new parserDocBlock;
\r
1100 foreach ($method->getParameters() as $param) {
\r
1101 $value = $param->isDefaultValueAvailable() ? var_export($param->getDefaultValue(), true) : null;
\r
1102 if ($param->isPassedByReference()) {
\r
1103 $var->addParam('&$' . $param->getName(), $value, $param->isOptional(),
\r
1104 $param->getClass());
\r
1106 $var->addParam('$' . $param->getName(), $value, $param->isOptional(),
\r
1107 $param->getClass());
\r
1110 $var->setName($method->getName());
\r
1111 $doc->addPackage('package', $oldx->getPackage());
\r
1112 $var->setDocBlock($doc);
\r
1113 $par = $method->getDeclaringClass();
\r
1114 $var->setLineNumber($par->getStartLine());
\r
1115 $modifiers = array();
\r
1116 if ($method->isPrivate()) {
\r
1117 $modifiers[] = 'private';
\r
1119 if ($method->isAbstract()) {
\r
1120 $modifiers[] = 'abstract';
\r
1122 if ($method->isFinal()) {
\r
1123 $modifiers[] = 'final';
\r
1125 if ($method->isProtected()) {
\r
1126 $modifiers[] = 'protected';
\r
1128 if ($method->isPublic()) {
\r
1129 $modifiers[] = 'public';
\r
1131 if ($method->isStatic()) {
\r
1132 $modifiers[] = 'static';
\r
1134 if ($method->isConstructor()) {
\r
1135 $var->setConstructor();
\r
1137 $var->setModifiers($modifiers);
\r
1138 $arr[$oldx->getExtends()]['methods'][] = $var;
\r
1139 $arr[$oldx->getExtends()]['file'] = '(internal)';
\r
1146 * @param Converter this function will not work before the Conversion stage of parsing
\r
1147 * @param boolean determines whether overriden vars should be included in the list of inherited vars
\r
1148 * @return array returns an array of vars by parent classname array(name => array(var1,var1..),name2 => array(var1....))
\r
1150 function getInheritedVars(&$c,$override = true, $vars = false)
\r
1152 $x = $oldx = $this;
\r
1155 while ($x->parent && is_array($x->parent))
\r
1157 $vars = array_merge($vars,$x->getVarNames($c));
\r
1158 $par = $x->getParent($c);
\r
1159 $parvarnames = $par->getVarNames($c);
\r
1160 $parvars = $par->getVars($c);
\r
1161 for($i=0; $i<count($parvarnames); $i++)
\r
1165 if (!in_array($parvarnames[$i],$vars))
\r
1167 // fix for bug 587733
\r
1168 if ($parvars[$i]->docblock && $parvars[$i]->docblock->hasaccess && !$c->parseprivate && $parvars[$i]->docblock->tags['access'][0]->value == 'private')
\r
1172 $vars[] = $parvarnames[$i];
\r
1173 $arr[$par->getName()]['vars'][] = $parvars[$i];
\r
1174 $arr[$par->getName()]['file'] = $par->curfile;
\r
1178 // fix for bug 587733
\r
1179 if ($parvars[$i]->docblock && $parvars[$i]->docblock->hasaccess && !$c->parseprivate && $parvars[$i]->docblock->tags['access'][0]->value == 'private')
\r
1183 $arr[$par->getName()]['vars'][] = $parvars[$i];
\r
1184 $arr[$par->getName()]['file'] = $par->curfile;
\r
1190 if (is_a($oldx, 'parserClass') && is_a($oldx->getExtends(true), 'ReflectionClass')) {
\r
1191 $extends = $oldx->getExtends(true);
\r
1192 foreach ($extends->getProperties() as $property) {
\r
1193 $var = new parserVar($oldx->getExtends());
\r
1194 $doc = new parserDocBlock;
\r
1195 $var->setName('$' . $property->getName());
\r
1196 $doc->addPackage('package', $oldx->getPackage());
\r
1197 $par = $property->getDeclaringClass();
\r
1198 $var->setLineNumber($par->getStartLine());
\r
1199 $modifiers = array();
\r
1200 if ($property->isPrivate()) {
\r
1201 $modifiers[] = 'private';
\r
1202 $doc->addAccess('private');
\r
1204 if ($property->isProtected()) {
\r
1205 $modifiers[] = 'protected';
\r
1206 $doc->addAccess('protected');
\r
1208 if ($property->isPublic()) {
\r
1209 $modifiers[] = 'public';
\r
1210 $doc->addAccess('public');
\r
1212 $var->setDocBlock($doc);
\r
1213 $var->setModifiers($modifiers);
\r
1214 $arr[$oldx->getExtends()]['vars'][] = $var;
\r
1215 $arr[$oldx->getExtends()]['file'] = '(internal)';
\r
1222 * @param Converter this function will not work before the Conversion stage of parsing
\r
1223 * @param boolean determines whether overriden vars should be included in the list of inherited vars
\r
1224 * @return array returns an array of consts by parent classname array(name => array(const1,const2..),name2 => array(const1....))
\r
1226 function getInheritedConsts(&$c,$override = false, $consts = false)
\r
1228 $x = $oldx = $this;
\r
1229 $consts = array();
\r
1231 while ($x->parent && is_array($x->parent))
\r
1233 $consts = array_merge($consts,$x->getConstNames($c));
\r
1234 $par = $x->getParent($c);
\r
1235 $parvarnames = $par->getConstNames($c);
\r
1236 $parvars = $par->getConsts($c);
\r
1237 for($i=0; $i<count($parvarnames); $i++)
\r
1241 if (!in_array($parvarnames[$i],$consts))
\r
1243 // fix for bug 587733
\r
1244 if ($parvars[$i]->docblock && $parvars[$i]->docblock->hasaccess && !$c->parseprivate && $parvars[$i]->docblock->tags['access'][0]->value == 'private')
\r
1248 $consts[] = $parvarnames[$i];
\r
1249 $arr[$par->getName()]['consts'][] = $parvars[$i];
\r
1250 $arr[$par->getName()]['file'] = $par->curfile;
\r
1254 // fix for bug 587733
\r
1255 if ($parvars[$i]->docblock && $parvars[$i]->docblock->hasaccess && !$c->parseprivate && $parvars[$i]->docblock->tags['access'][0]->value == 'private')
\r
1259 $arr[$par->getName()]['consts'][] = $parvars[$i];
\r
1260 $arr[$par->getName()]['file'] = $par->curfile;
\r
1266 if (is_a($oldx, 'parserClass') && is_a($oldx->getExtends(true), 'ReflectionClass')) {
\r
1267 $extends = $oldx->getExtends(true);
\r
1268 if (!$extends->getConstants()) {
\r
1271 foreach ($extends->getConstants() as $property => $value) {
\r
1272 $var = new parserConst($oldx->getExtends());
\r
1273 $doc = new parserDocBlock;
\r
1274 $var->setName($property);
\r
1275 $var->setValue(var_export($value, true));
\r
1276 $doc->addPackage('package', $oldx->getPackage());
\r
1277 $var->setLineNumber($extends->getStartLine());
\r
1278 $var->setDocBlock($doc);
\r
1279 $arr[$oldx->getExtends()]['consts'][] = $var;
\r
1280 $arr[$oldx->getExtends()]['file'] = '(internal)';
\r
1287 * @param Converter this function will not work before the Conversion stage of parsing
\r
1288 * @return array Format: array(parentclassname => parserClass/false if no parent, parentclassname2 => ...)
\r
1290 function getParentClassTree(&$c)
\r
1292 $result = array();
\r
1293 $result[$this->name] = $arr = $this->getParent($c);
\r
1294 if (is_string($arr)) $result[$arr] = false;
\r
1295 while ($arr && is_object($arr))
\r
1297 $result[$arr->name] = $arr->getParent($c);
\r
1298 $arr = $arr->getParent($c);
\r
1299 if (is_string($arr)) $result[$arr] = false;
\r
1305 * returns a list of all child classes of this class
\r
1306 * @param Converter this function will not work before the Conversion stage of parsing
\r
1307 * @return array Format: array(parserClass child1,parserClass child2,...)
\r
1309 function getChildClassList(&$c)
\r
1312 $kids = $c->classes->getDefiniteChildren($this->name,$this->curfile);
\r
1315 foreach($kids as $chile => $file)
\r
1317 $list[] = $c->classes->getClass($chile,$file);
\r
1325 * @see $sourceLocation
\r
1327 function setSourceLocation($sl)
\r
1329 $this->sourceLocation = $sl;
\r
1333 * @param Converter
\r
1336 * @see $sourceLocation
\r
1338 function getSourceLocation($c,$pearize = false)
\r
1340 global $_phpDocumentor_options;
\r
1341 if (!isset($this->sourceLocation))
\r
1347 $sl = $this->sourceLocation;
\r
1350 if (strpos($sl,'pear/'))
\r
1352 $sl = substr($sl,strpos($sl,'pear/') + 5);
\r
1363 function setExtends($extends)
\r
1365 $this->extends = $extends;
\r
1366 if (!class_exists('ReflectionClass') || !class_exists($extends)) {
\r
1369 // this may throw an exception. Hopefully it won't if the class exists
\r
1370 $parent = new ReflectionClass($extends);
\r
1371 if (!$parent->isInternal()) {
\r
1374 $this->extends = $parent;
\r
1380 function addImplements($implements)
\r
1382 $this->_implements[] = $implements;
\r
1388 function getImplements()
\r
1390 return $this->_implements;
\r
1397 function getExtends($raw = false)
\r
1399 if (!isset($this->extends)) return false;
\r
1401 if (is_a($this->extends, 'ReflectionClass')) {
\r
1402 return $this->extends->getName();
\r
1405 return $this->extends;
\r
1410 * @package phpDocumentor
\r
1411 * @subpackage ParserElements
\r
1412 * @author Greg Beaver <cellog@php.net>
\r
1414 * @version $Id: ParserElements.inc,v 1.19 2007/04/24 21:30:50 ashnazg Exp $
\r
1416 class parserVar extends parserElement
\r
1419 * Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
\r
1420 * @var string always 'var'
\r
1422 var $type = 'var';
\r
1423 /** @var string class that contains this var */
\r
1431 function parserVar($class)
\r
1433 $this->class = $class;
\r
1437 * Retrieve the class name
\r
1438 * @return string Class name that this var belongs to
\r
1440 function getClass()
\r
1442 return $this->class;
\r
1446 * Return a list of access modifiers (static/private/etc.)
\r
1449 function getModifiers()
\r
1451 return $this->_modifiers;
\r
1455 * Return name of the class that contains this method
\r
1458 function setModifiers($m)
\r
1460 $this->_modifiers = $m;
\r
1464 * quick way to link to this element
\r
1465 * @return mixed converter-specific link to this var
\r
1466 * @param Converter $c
\r
1467 * @param string $text text to display for the link or false for default text
\r
1469 function getLink($c, $text = false, $returnobj = false)
\r
1473 return $c->getLink($this->class . '::' . $this->name, $this->docblock->package);
\r
1475 return $c->getVarLink($this->name, $this->class, $this->docblock->package, false, $text);
\r
1479 * @param Converter
\r
1480 * @return mixed {@link parserVar} representing var this var overrides from the parent class, or false if none
\r
1482 function getOverrides(&$c)
\r
1484 $class = $c->classes->getClass($this->class,$this->path);
\r
1485 $par = $class->getParent($c);
\r
1487 if (!is_object($par)) {
\r
1488 if (is_a($class->getExtends(true), 'ReflectionClass')) {
\r
1489 $pare = $class->getExtends(true);
\r
1490 if (method_exists($pare, 'hasProperty') &&
\r
1491 $pare->hasProperty(substr($this->name, 1))) {
\r
1493 $property = $par->getProperty(substr($this->name, 1));
\r
1494 $ret = new parserVar($par->getName());
\r
1495 $doc = new parserDocBlock;
\r
1496 $ret->setName('$' . $property->getName());
\r
1497 $doc->addPackage('package', $class->getPackage());
\r
1498 $ret->setLineNumber($par->getStartLine());
\r
1499 $modifiers = array();
\r
1500 if ($property->isPrivate()) {
\r
1501 if ($c->parseprivate) {
\r
1504 $modifiers[] = 'private';
\r
1505 $doc->addAccess('private');
\r
1507 if ($property->isProtected()) {
\r
1508 $modifiers[] = 'protected';
\r
1509 $doc->addAccess('protected');
\r
1511 if ($property->isPublic()) {
\r
1512 $modifiers[] = 'public';
\r
1513 $doc->addAccess('public');
\r
1515 $ret->setDocBlock($doc);
\r
1516 $ret->setModifiers($modifiers);
\r
1521 while (is_object($par))
\r
1523 if ($par->hasVar($c,$this->name))
\r
1525 $var = $par->getVar($c,$this->name);
\r
1526 if (!($var->docblock && $var->docblock->hasaccess &&
\r
1527 !$c->parseprivate && $var->docblock->tags['access'][0]->value == 'private')) {
\r
1531 $par = $par->getParent($c);
\r
1538 * @param Converter
\r
1539 * @return array an array of parserVars from ALL child classes that override this var
\r
1541 function getOverridingVars(&$c)
\r
1543 $class = $c->classes->getClass($this->class,$this->path);
\r
1545 return $this->getOverridingVarsForClass($c, $class);
\r
1549 * @param Converter
\r
1550 * @param parserClass
\r
1551 * @return array an array of parserVars from ALL child classes that override this var in the given class
\r
1553 function getOverridingVarsForClass(&$c, &$class)
\r
1556 if (!$class) return $meths;
\r
1557 $kids = $class->getChildClassList($c);
\r
1558 for($i=0; $i<count($kids); $i++)
\r
1560 if ($kids[$i]->hasVar($c, $this->name))
\r
1562 $var = $kids[$i]->getVar($c,$this->name);
\r
1563 if (!($var->docblock && $var->docblock->hasaccess && !$c->parseprivate && $var->docblock->tags['access'][0]->value == 'private'))
\r
1567 $vars = array_merge($vars, $this->getOverridingVarsForClass($c, $kids[$i]));
\r
1574 * @package phpDocumentor
\r
1575 * @subpackage ParserElements
\r
1576 * @author Greg Beaver <cellog@php.net>
\r
1579 class parserConst extends parserElement
\r
1582 * Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
\r
1583 * @var string always 'const'
\r
1585 var $type = 'const';
\r
1586 /** @var string class that contains this var */
\r
1592 function parserConst($class)
\r
1594 $this->class = $class;
\r
1598 * Retrieve the class name
\r
1599 * @return string Class name that this var belongs to
\r
1601 function getClass()
\r
1603 return $this->class;
\r
1607 * quick way to link to this element
\r
1608 * @return mixed converter-specific link to this var
\r
1609 * @param Converter $c
\r
1610 * @param string $text text to display for the link or false for default text
\r
1612 function getLink($c, $text = false, $returnobj = false)
\r
1616 return $c->getLink($this->class . '::'. $this->name, $this->docblock->package);
\r
1618 return $c->getConstLink($this->name, $this->class, $this->docblock->package, false, $text);
\r
1623 * @package phpDocumentor
\r
1624 * @subpackage ParserElements
\r
1625 * @author Greg Beaver <cellog@php.net>
\r
1627 * @version $Id: ParserElements.inc,v 1.19 2007/04/24 21:30:50 ashnazg Exp $
\r
1629 class parserMethod extends parserFunction
\r
1632 * Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
\r
1633 * @var string always 'method'
\r
1635 var $type = 'method';
\r
1636 /** @var boolean whether this method is a constructor */
\r
1637 var $isConstructor = false;
\r
1638 /** @var boolean whether this method is a destructor by PEAR standards */
\r
1639 var $isDestructor = false;
\r
1640 /** @var string class that contains this method */
\r
1642 var $_modifiers = array();
\r
1647 function parserMethod($class)
\r
1649 $this->class = $class;
\r
1654 * @param string default value parsed from function definition
\r
1655 * @param boolean indicates whether this parameter has a default value
\r
1656 * @param null|string class type hint
\r
1658 function addParam($name, $value, $has_default = true, $typehint = null)
\r
1660 $this->params[$name] = array($value, $has_default);
\r
1661 if (isset($typehint))
\r
1663 $this->params[$name][2] = $typehint;
\r
1668 * adds "constructor " to start of function call if {@link $isConstructor} is true
\r
1670 * @see parent::getFunctionCall()
\r
1672 function getFunctionCall()
\r
1674 $a = parserFunction::getFunctionCall();
\r
1675 if ($this->isConstructor) $a = "constructor $a";
\r
1679 function getIntricateFunctionCall($converter,$paramtags)
\r
1681 $a = parserFunction::getIntricateFunctionCall($converter,$paramtags);
\r
1682 if ($this->isConstructor) $a['constructor'] = true;
\r
1683 if ($this->isDestructor) $a['destructor'] = true;
\r
1688 * Return name of the class that contains this method
\r
1691 function getClass()
\r
1693 return $this->class;
\r
1697 * Return name of the class that contains this method
\r
1700 function getModifiers()
\r
1702 return $this->_modifiers;
\r
1706 * Return name of the class that contains this method
\r
1709 function setModifiers($m)
\r
1711 $this->_modifiers = $m;
\r
1715 * @param Converter
\r
1716 * @return mixed {@link parserMethod} representing method this method
\r
1717 * overrides from the parent class, or false if none
\r
1719 function getOverrides(&$c)
\r
1721 $class = $c->classes->getClass($this->class,$this->path);
\r
1723 $par = $class->getParent($c);
\r
1724 if (!is_object($par)) {
\r
1725 if (is_a($class->getExtends(true), 'ReflectionClass')) {
\r
1726 $pare = $class->getExtends(true);
\r
1727 if (method_exists($pare, 'hasMethod') && $pare->hasMethod($this->name)) {
\r
1729 $method = $par->getMethod($this->name);
\r
1730 $var = new parserMethod($par->getName());
\r
1731 if ($method->returnsReference()) {
\r
1732 $var->setReturnsReference();
\r
1734 $doc = new parserDocBlock;
\r
1735 foreach ($method->getParameters() as $param) {
\r
1736 $value = ($param->isOptional() && !$method->isInternal()) ? var_export($param->getDefaultValue(), true) : null;
\r
1737 if ($param->isPassedByReference()) {
\r
1738 $var->addParam('&$' . $param->getName(), $value, $param->isOptional(),
\r
1739 $param->getClass());
\r
1741 $var->addParam('$' . $param->getName(), $value, $param->isOptional(),
\r
1742 $param->getClass());
\r
1745 $var->setName($method->getName());
\r
1746 $doc->addPackage('package', $this->getPackage());
\r
1747 $par = $method->getDeclaringClass();
\r
1748 $var->setLineNumber($par->getStartLine());
\r
1749 $modifiers = array();
\r
1750 if ($method->isPrivate()) {
\r
1751 $modifiers[] = 'private';
\r
1752 $doc->addAccess('private');
\r
1754 $blank = new parserStringWithInlineTags;
\r
1755 if ($method->isAbstract()) {
\r
1756 $modifiers[] = 'abstract';
\r
1757 $doc->addKeyword('abstract', $blank);
\r
1759 if ($method->isFinal()) {
\r
1760 $modifiers[] = 'final';
\r
1761 $doc->addKeyword('final', $blank);
\r
1763 if ($method->isProtected()) {
\r
1764 $modifiers[] = 'protected';
\r
1765 $doc->addAccess('protected');
\r
1767 if ($method->isPublic()) {
\r
1768 $modifiers[] = 'public';
\r
1769 $doc->addAccess('public');
\r
1771 if ($method->isStatic()) {
\r
1772 $modifiers[] = 'static';
\r
1773 $doc->addKeyword('static', $blank);
\r
1775 if ($method->isConstructor()) {
\r
1776 $var->setConstructor();
\r
1778 $var->setDocBlock($doc);
\r
1779 $var->setModifiers($modifiers);
\r
1785 while (is_object($par))
\r
1787 if ($par->hasMethod($c,$this->name))
\r
1789 $meth = $par->getMethod($c,$this->name);
\r
1790 if (!($meth->docblock && $meth->docblock->hasaccess &&
\r
1791 !$c->parseprivate && $meth->docblock->tags['access'][0]->value == 'private')) {
\r
1796 $par = $par->getParent($c);
\r
1802 * @param Converter
\r
1803 * @return mixed {@link parserMethod} representing method this method implements
\r
1804 * from an interface, or false if none
\r
1806 function getImplements(&$c)
\r
1808 $class = $c->classes->getClass($this->class,$this->path);
\r
1810 $implements = $class->getImplements();
\r
1811 if (!count($implements)) {
\r
1815 $haveAlready = array();
\r
1816 foreach ($implements as $interface) {
\r
1817 $interface_link = $c->getLink('object ' . $interface);
\r
1818 if (is_a($interface_link, 'classlink')) {
\r
1819 $par = $c->classes->getClass($interface_link->name,
\r
1820 $interface_link->path);
\r
1821 if (is_object($par)) {
\r
1822 if ($par->hasMethod($c, $this->name, true))
\r
1824 $meth = $par->getMethod($c, $this->name);
\r
1826 $meth = $par->getMethod($c, $this->name, true);
\r
1828 if (!($meth->docblock && $meth->docblock->hasaccess &&
\r
1829 !$c->parseprivate && $meth->docblock->tags['access'][0]->value == 'private')) {
\r
1830 if (isset($haveAlready[$meth->getClass()])) {
\r
1831 // this ensures extended interfaces don't cause
\r
1832 // 2 links to the same method
\r
1833 if ($haveAlready[$meth->getClass()] == $this->name) {
\r
1838 $haveAlready = array($meth->getClass() => $this->name);
\r
1844 if (class_exists('ReflectionClass')) {
\r
1845 if (interface_exists($interface)) {
\r
1846 $info = new ReflectionClass($interface);
\r
1847 if (method_exists($info, 'hasMethod') && $info->hasMethod($this->name)) {
\r
1849 $method = $par->getMethod($this->name);
\r
1850 $var = new parserMethod($par->getName());
\r
1851 if ($method->returnsReference()) {
\r
1852 $var->setReturnsReference();
\r
1854 $doc = new parserDocBlock;
\r
1855 foreach ($method->getParameters() as $param) {
\r
1856 $value = $param->isOptional() ? var_export($param->getDefaultValue(), true) : null;
\r
1857 if ($param->isPassedByReference()) {
\r
1858 $var->addParam('&$' . $param->getName(), $value, $param->isOptional(),
\r
1859 $param->getClass());
\r
1861 $var->addParam('$' . $param->getName(), $value, $param->isOptional(),
\r
1862 $param->getClass());
\r
1865 $var->setName($method->getName());
\r
1866 $doc->addPackage('package', $this->getPackage());
\r
1867 $par = $method->getDeclaringClass();
\r
1868 $var->setLineNumber($par->getStartLine());
\r
1869 $modifiers = array();
\r
1870 if ($method->isPrivate()) {
\r
1871 $modifiers[] = 'private';
\r
1872 $doc->addAccess('private');
\r
1874 $blank = new parserStringWithInlineTags;
\r
1875 if ($method->isAbstract()) {
\r
1876 $modifiers[] = 'abstract';
\r
1877 $doc->addKeyword('abstract', $blank);
\r
1879 if ($method->isFinal()) {
\r
1880 $modifiers[] = 'final';
\r
1881 $doc->addKeyword('final', $blank);
\r
1883 if ($method->isProtected()) {
\r
1884 $modifiers[] = 'protected';
\r
1885 $doc->addAccess('protected');
\r
1887 if ($method->isPublic()) {
\r
1888 $modifiers[] = 'public';
\r
1889 $doc->addAccess('public');
\r
1891 if ($method->isStatic()) {
\r
1892 $modifiers[] = 'static';
\r
1893 $doc->addKeyword('static', $blank);
\r
1895 if ($method->isConstructor()) {
\r
1896 $var->setConstructor();
\r
1898 $var->setDocBlock($doc);
\r
1899 $var->setModifiers($modifiers);
\r
1911 * quick way to link to this element
\r
1912 * @return mixed converter-specific link to this method
\r
1913 * @param Converter $c
\r
1914 * @param string $text text to display for the link or false for default text
\r
1916 function getLink($c, $text = false, $returnobj = false)
\r
1920 return $c->getLink($this->class . '::' . $this->name . '()', $this->docblock->package);
\r
1922 return $c->getMethodLink($this->name, $this->class, $this->docblock->package, false, $text);
\r
1926 * Use this method to tell the parser that this method is the class constructor
\r
1928 function setConstructor()
\r
1930 $this->isConstructor = true;
\r
1934 * Use this method to tell the parser that this method is the class constructor
\r
1936 function setDestructor()
\r
1938 $this->isDestructor = true;
\r
1942 * @param Converter
\r
1943 * @return array an array of parserMethods from child classes that override this method
\r
1945 function getOverridingMethods(&$c)
\r
1947 $class = $c->classes->getClass($this->class,$this->path);
\r
1949 return $this->getOverridingMethodsForClass($c, $class);
\r
1953 * @param Converter
\r
1954 * @param parserClass
\r
1955 * @return array an array of parserMethods from ALL child classes that override this method in the given class
\r
1957 function getOverridingMethodsForClass(&$c, &$class)
\r
1960 if (!$class) return $meths;
\r
1961 $kids = $class->getChildClassList($c);
\r
1962 for($i=0; $i<count($kids); $i++)
\r
1964 if ($kids[$i]->hasMethod($c, $this->name))
\r
1966 $meth = $kids[$i]->getMethod($c,$this->name);
\r
1967 if (!($meth->docblock && $meth->docblock->hasaccess && !$c->parseprivate && $meth->docblock->tags['access'][0]->value == 'private'))
\r
1971 $meths = array_merge($meths, $this->getOverridingMethodsForClass($c, $kids[$i]));
\r
1978 * @package phpDocumentor
\r
1979 * @subpackage ParserElements
\r
1980 * @author Greg Beaver <cellog@php.net>
\r
1982 * @version $Id: ParserElements.inc,v 1.19 2007/04/24 21:30:50 ashnazg Exp $
\r
1984 class parserDefine extends parserElement
\r
1987 * Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
\r
1988 * @var string always 'define'
\r
1990 var $type = 'define';
\r
1993 * quick way to link to this element
\r
1994 * @return mixed converter-specific link to this define
\r
1995 * @param Converter $c
\r
1996 * @param string $text text to display for the link or false for default text
\r
1998 function getLink($c, $text = false, $returnobj = false)
\r
2002 return $c->getLink('constant ' . $this->name, $this->docblock->package);
\r
2004 return $c->getDefineLink($this->name, $this->docblock->package, false, $text);
\r
2008 * Returns all defines in other packages that have the same name as this define
\r
2009 * @return mixed false or an array Format: (package => {@link parserDefine} of conflicting defines)
\r
2010 * @param Converter
\r
2012 function getConflicts(&$c)
\r
2014 $a = $c->proceduralpages->getDefineConflicts($this->name);
\r
2015 unset($a[$this->docblock->package]);
\r
2022 * @package phpDocumentor
\r
2023 * @subpackage ParserElements
\r
2024 * @author Greg Beaver <cellog@php.net>
\r
2026 * @version $Id: ParserElements.inc,v 1.19 2007/04/24 21:30:50 ashnazg Exp $
\r
2028 class parserPackagePage extends parserStringWithInlineTags
\r
2031 * Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
\r
2032 * @var string always 'packagepage'
\r
2034 var $type = 'packagepage';
\r
2035 /** @var string */
\r
2036 var $package = 'default';
\r
2041 function parserPackagePage($package)
\r
2043 $this->package = $package;
\r
2047 * @param Converter
\r
2049 function Convert(&$c)
\r
2051 return parent::Convert($c,false);
\r
2056 * @package phpDocumentor
\r
2057 * @subpackage ParserElements
\r
2060 class parserTutorial extends parserPackagePage
\r
2063 * Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
\r
2064 * @var string always 'tutorial'
\r
2066 var $type = 'tutorial';
\r
2067 /** @var string */
\r
2068 var $package = 'default';
\r
2070 * Either cls, pkg, or proc
\r
2073 var $tutorial_type;
\r
2075 * The documentable element this tutorial is linked to
\r
2077 * Can be a parserData, parserClass, or nothing for package/subpackage docs
\r
2079 var $linked_element;
\r
2081 * path to the tutorial page
\r
2086 * filename minus extension of this tutorial (used for @tutorial tag)
\r
2090 /** @var boolean */
\r
2093 * output from tutorialname.ext.ini
\r
2095 * an array generated by {@link phpDocumentor_parse_ini_file()} containing
\r
2096 * an index 'Linked Tutorials' with an array of tutorial names in the order
\r
2097 * they should appear. This is used to generate a linked list of tutorials like
\r
2098 * {@tutorial phpDocumentor/tags.pkg}
\r
2103 * link to the next tutorial in a document series, or false if none
\r
2104 * @var tutorialLink
\r
2106 var $next = false;
\r
2108 * link to the previous tutorial in a document series, or false if none
\r
2109 * @var tutorialLink
\r
2111 var $prev = false;
\r
2113 * link to the parent tutorial in a document series, or false if none
\r
2115 * This is used to generate an "Up" or "Home" link like the php manual.
\r
2116 * The parent is defined as a tutorial that has a parenttutorialname.ext.ini
\r
2117 * file and is not contained by any other tutorial's tutorialname.ext.ini
\r
2118 * @var tutorialLink
\r
2120 var $parent = false;
\r
2122 * links to the child tutorials, or false if none
\r
2125 var $children = false;
\r
2128 * @param parserXMLDocBookTag top-level tag (<refentry> for 1.2.0)
\r
2129 * @param information about the tutorial file. Format:
\r
2132 * array('tutename' => tutorial name,
\r
2133 * 'path' => relative path of tutorial to tutorials/ directory
\r
2134 * 'ini' => contents of the tutorial .ini file, if any)
\r
2137 function parserTutorial($data, $info)
\r
2139 $this->value = $data;
\r
2140 $this->package = $info['package'];
\r
2141 $this->subpackage = $info['subpackage'];
\r
2142 $this->tutorial_type = $info['tutetype'];
\r
2143 $this->name = $info['tutename'];
\r
2144 $this->path = $info['path'];
\r
2145 $this->ini = $info['ini'];
\r
2149 * Retrieve the title of the tutorial, or of any subsection
\r
2150 * @param Converter
\r
2151 * @param string which subsection to retrieve the title from, if any
\r
2152 * @uses parserXMLDocBookTag::getSubSection() retrieve the subsection to
\r
2153 * to get a title from
\r
2155 function getTitle(&$c,$subsection = '')
\r
2157 if (!empty($subsection))
\r
2159 $z = $this->value->getSubSection($c,$subsection);
\r
2162 addWarning(PDERROR_TUTORIAL_SUBSECTION_NOT_FOUND,$this->name,$subsection);
\r
2163 return $subsection;
\r
2165 return $z->getTitle($c);
\r
2167 return $this->value->getTitle($c);
\r
2171 * @param Converter
\r
2172 * @param boolean determines whether character data is postprocessed to be
\r
2173 * Converter-friendly or not.
\r
2175 function Convert(&$c, $postprocess = true)
\r
2177 return $this->value->Convert($c, $postprocess);
\r
2181 * @uses $parent creates a link to the documentation for the parent tutorial
\r
2182 * @param parserTutorial
\r
2183 * @param Converter
\r
2185 function setParent($parent,&$c)
\r
2187 $this->parent = new tutorialLink;
\r
2188 $this->parent->addLink('', $parent->path, $parent->name, $parent->package, $parent->subpackage, $parent->getTitle($c));
\r
2192 * Determine if this parserTutorial object is a child of another
\r
2194 * WARNING: This method can enter an infinite loop when run on PHP v5.2.1...
\r
2195 * see {@link http://bugs.php.net/bug.php?id=40608 PHP Bug #40608}
\r
2196 * and {@link http://pear.php.net/bugs/bug.php?id=10289 PEAR Bug #10289}
\r
2197 * @param array $parents array of parserTutorials that have child tutorials
\r
2198 * @return boolean whether or not this tutorial is a child of the any of the parents
\r
2200 function isChildOf($parents)
\r
2202 // avoid infinite loop PHP bug #40608 in PHP v5.2.1, see PEAR #10289
\r
2203 checkForBugCondition('5.2.1', '40608', '10289');
\r
2205 foreach($parents as $i => $parent)
\r
2207 if ($parent->path == $this->path) continue;
\r
2208 if ($parent->ini && ($parent->package == $this->package) && ($parent->subpackage == $this->subpackage) && ($parent->tutorial_type == $this->tutorial_type))
\r
2210 foreach($parent->ini['Linked Tutorials'] as $child)
\r
2212 if ($child . '.' . $this->tutorial_type == $this->name) return true;
\r
2219 * Retrieve converter-specific link to the parent tutorial's documentation
\r
2220 * @param Converter
\r
2222 function getParent(&$c)
\r
2224 if (!$this->parent) return false;
\r
2225 return $c->returnSee($this->parent);
\r
2229 * @uses $next creates a link to the documentation for the next tutorial
\r
2230 * @param parserTutorial
\r
2231 * @param Converter
\r
2233 function setNext($next,&$c)
\r
2235 if (phpDocumentor_get_class($next) == 'tutoriallink') return $this->next = $next;
\r
2236 $this->next = new tutorialLink;
\r
2237 $this->next->addLink('', $next->path, $next->name, $next->package, $next->subpackage, $next->getTitle($c));
\r
2241 * Retrieve converter-specific link to the next tutorial's documentation
\r
2242 * @param Converter
\r
2244 function getNext(&$c)
\r
2246 if (!$this->next) return false;
\r
2247 return $c->returnSee($this->next);
\r
2251 * @uses $prev creates a link to the documentation for the previous tutorial
\r
2252 * @param parserTutorial
\r
2253 * @param Converter
\r
2255 function setPrev($prev,&$c)
\r
2257 if (phpDocumentor_get_class($prev) == 'tutoriallink') return $this->prev = $prev;
\r
2258 $this->prev = new tutorialLink;
\r
2259 $this->prev->addLink('', $prev->path, $prev->name, $prev->package, $prev->subpackage, $prev->getTitle($c));
\r
2263 * Retrieve converter-specific link to the previous tutorial's documentation
\r
2264 * @param Converter
\r
2266 function getPrev(&$c)
\r
2268 if (!$this->prev) return false;
\r
2269 return $c->returnSee($this->prev);
\r
2273 * Get a link to this tutorial, or to any subsection of this tutorial
\r
2274 * @param Converter
\r
2275 * @param boolean if true, returns a {@link tutorialLink} instead of a string
\r
2276 * @param string section name to link to
\r
2277 * @return string|tutorialLink
\r
2279 function getLink(&$c,$pure = false,$section = '')
\r
2281 $link = new tutorialLink;
\r
2282 $link->addLink($section, $this->path, $this->name, $this->package, $this->subpackage, $this->getTitle($c), $this->category);
\r
2283 if ($pure) return $link;
\r
2284 return $c->returnSee($link);
\r