Source for file ParserElements.inc
Documentation is available at ParserElements.inc
* Parser Elements, all classes representing documentable elements
* phpDocumentor :: automatic documentation generator
* Copyright (c) 2002-2006 Gregory Beaver
* This library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* @subpackage ParserElements
* @copyright 2002-2006 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version CVS: $Id: ParserElements.inc,v 1.15 2006/08/17 02:36:50 cellog Exp $
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* @see Parser, WordParser
* all elements except {@link parserPackagePage} descend from this abstract class
* @subpackage ParserElements
* @version $Id: ParserElements.inc,v 1.15 2006/08/17 02:36:50 cellog Exp $
* @var mixed either false or a {@link parserDocBlock}
* name of this element, or include type if element is a {@link parserInclude}
* @var mixed either false or an array of paths to files with conflicts
* location of this element (filename)
* full path location of this element (filename)
* line number on file where this element stops
* Line number in the source on which this element appears
* Set starting line number
* Sets the ending line number of elements
/** @return string package containing this element */
} else return $GLOBALS['phpDocumentor_DefaultPackageName'];
// look for special windows case
if (!isset ($this->name)) return false;
if (!isset ($this->file)) return false;
if (!isset ($this->path)) return false;
* @subpackage ParserElements
* @version $Id: ParserElements.inc,v 1.15 2006/08/17 02:36:50 cellog Exp $
* Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
* @var string always 'include'
* @subpackage ParserElements
* @version $Id: ParserElements.inc,v 1.15 2006/08/17 02:36:50 cellog Exp $
* Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
* @var string always 'global'
* Name of the global's data type
* quick way to link to this element
* @return mixed converter-specific link to this global variable
* @param string text to display for the link or false for default text
function getLink(&$c, $text = false, $returnobj = false)
return $c->getLink('global ' . $this->name, $this->docblock->package);
return $c->getGlobalLink($this->name, $this->docblock->package, $this->path, $text);
* Returns all global variables in other packages that have the same name as this global variable
* @return mixed false or an array Format: (package => {@link parserGlobal} of conflicting global variable)
$a = $c->proceduralpages->getGlobalConflicts($this->name);
* Sets the name of the global variable's type
* Retrieve converter-specific representation of the data type
* If the data type is a documented class name, then this function will
* return a Converter-specific link to that class's documentation, so users
* can click/browse to the documentation directly from the global variable
foreach($types as $returntype)
$a = $converter->getLink($returntype);
if (!empty($my_types)) $my_types .= '|';
$my_types .= $converter->returnSee($a,$converter->type_adjust($returntype));
if (!empty($my_types)) $my_types .= '|';
$my_types .= $converter->type_adjust($returntype);
$converted_datatype = $my_types;
$a = $converter->getLink($this->datatype);
$converted_datatype = $converter->returnSee($a,$converter->type_adjust($this->datatype));
$converted_dataype = $converter->type_adjust($this->datatype);
return $converted_datatype;
* @subpackage ParserElements
* @version $Id: ParserElements.inc,v 1.15 2006/08/17 02:36:50 cellog Exp $
* Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
* @var string always 'function'
* parameters parsed from function definition.
* param name may be null, in which case, updateParams() must be called from the Converter
* @var array Format: array(param name => default value parsed from function definition)
* Function returns a reference to an element, instead of a value
* set to true if function is declared as:
* global declarations parsed from function definition
* @var array Format: array(globalname1, globalname2,....)
* static variable declarations parsed from function definition
* @var array Format: array(array('name' => staticvar1,'val' => '' or default val of staticvar1),...)
* @param string default value parsed from function definition
* @param boolean indicates whether this parameter has a default value
* @param null|stringclass type hint
function addParam($name, $value, $has_default = true, $typehint = null)
$this->params[$name] = array($value, $has_default);
$this->params[$name][2] = $typehint;
* Set the source code. Always array in PHP 4.3.0+
* Determine whether the source code has been requested via {@}source}
* @return string|arraysource code ready for highlighting
* quick way to link to this element
* @return mixed converter-specific link to this function
* @param string text to display for the link or false for default text
function getLink($c, $text = false, $returnobj = false)
return $c->getLink('function ' . $this->name, $this->docblock->package);
return $c->getFunctionLink($this->name, $this->docblock->package, $this->path, $text);
* Returns all functions in other packages that have the same name as this function
* @return mixed false or an array Format: (package => {@link parserFunction} of conflicting functions)
$a = $c->proceduralpages->getFuncConflicts($this->name);
* Add all "global $var, $var2" declarations to this function
* @param array $globals Format: array(globalname1, globalname2,....)
* Add all "static $var, $var2 = 6" declarations to this function
* @param array Format: array(varname1, varname2,...)
* @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,...)
for($i= 0;$i< count($static);$i++ )
if (isset ($vals[$i])) $a = $vals[$i];
$this->statics[] = array('name' => $static[$i],'val' => $a);
* @return string default value of param $name
if (!isset ($this->params[$name])) return false;
* @return array format: array(array(paramname, default value),...)
foreach($this->params as $key => $val)
$arr = array($key,$val[0]);
$arr = array($key,false);
* @return array format: array(array(index, globalname),...)
foreach($this->globals as $key => $val)
$ret[] = array($key,$val);
* @return array format: array(array(static var name, static var default value),...)
foreach($this->statics as $key => $val)
$ret[] = array($val['name'],$val['val']);
* sets {@link $returnsreference} to true
* @return boolean returns value of {@link $returnsreference}
* Get a human-friendly description of the function call
* takes declaration like:
* /** @returns string ... {rest of docblock}
* function &func($param1, $param2 = 6,
* $param3 = array('20',9 => "heroo"))
* string &func( $param1, [$param2 = 6], [$param3 = array('20',9 => "heroo")] )
* @return string stylized function declaration
$function_call = $a. $this->getName() . " ( ";
$function_call .= "[$param[0] = $param[1]]";
$function_call .= $param[0];
$update_params[] = $param[0];
* Like getFunctionCall(), but has no English or pre-determined formatting.
* array('name' => function name,
* 'returnsref' => boolean if declared as "function &name()"
* 'params' => array('type' => data type of parameter,
* 'description' => from @param tag,
* 'name' => variable name,
* 'default' => default value if any))
$a['name'] = $converter->type_adjust($this->getName());
if (isset ($paramtags[$param[0]]))
$b['type'] = $paramtags[$param[0]]['datatype'];
$b['description'] = $paramtags[$param[0]]['data'];
unset ($paramtags[$param[0]]);
} elseif(isset ($paramtags[substr($param[0],1)]))
$b['type'] = $paramtags[substr($param[0],1)]['datatype'];
$b['description'] = $paramtags[substr($param[0],1)]['data'];
unset ($paramtags[substr($param[0],1)]);
$link = $converter->getLink('object ' . $param[2]);
$link = $converter->returnSee($link, $param[2], true);
$b['default'] = $converter->postProcess($param[1]);
$b['hasdefault'] = ($param[1] !== false);
// @param tags that don't correspond to actual parameters (like extra function values)
foreach($paramtags as $param)
$b['type'] = $param['datatype'];
$b['description'] = $param['data'];
$b['name'] = $param['var'];
$b['hasdefault'] = false;
* @subpackage ParserElements
* @version $Id: ParserElements.inc,v 1.15 2006/08/17 02:36:50 cellog Exp $
* Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
* @var string always 'class'
* @see parserPage::$sourceLocation */
* @var mixed false or contents of extends clause in class declaration
* @var array a list of interfaces this class implements
* @var array a list of interfaces this class implements
* @var boolean determines whether a class is considered to be an interface
var $_isInterface = false;
* Format: array(file, parent) where parent class is found or false if no parent
* Used to determine whether a class should be ignored or not. Helps maintain integrity of parsing
* @see Classes::getParentClass()
* @var string same as {@link parserElement::$path}
* @var tutorialLink|falseeither a link to the tutorial associated with this class, or false
* Get the PHP5+ modifiers for this class
* (abstract/final/static/private/protected/public)
return $this->_modifiers;
* Set the PHP5+ modifiers for this class
* (abstract/final/static/private/protected/public)
$this->tutorial->addLink('',$t->path,$t->name,$t->package,$t->subpackage,$t->getTitle($c));
* Get the associated tutorial for this class, if any
* @tutorial tutorials.pkg
* Returns all classes in other packages that have the same name as this class
* @return mixed false or an array Format: (package => {@link parserClass} of conflicting classes)
$a = $c->classes->getConflicts($this->name);
* quick way to link to this element
* @return mixed converter-specific link to this class
* @param string text to display for the link or false for default text
function getLink($c, $text = false, $returnobj = false)
return $c->getLink('object ' . $this->name, $this->docblock->package);
* @param string parent class name
* @param string parent class file
* @param Classes {@link Classes} object currently calling setParent
* @see Classes::setClassParent()
$this->parent = array($f, $p);
$p = $c->getClass($p, $f);
// inherit package if no @package tag is in the docblock, fixes 591396
if (!$this->docblock->getExplicitPackage())
$this->docblock->package = $p->docblock->package;
if ($this->docblock->package == $p->docblock->package)
$this->docblock->subpackage = $p->docblock->subpackage;
$author = $p->docblock->getKeyword('author');
$version = $p->docblock->getKeyword('version');
$copyright = $p->docblock->getKeyword('copyright');
if (!$this->docblock->getKeyword('author'))
if ($author && !is_array($author)) $author = array($author);
if ($author) $this->docblock->tags['author'] = $author;
if (!$this->docblock->getKeyword('version'))
if ($version && !is_array($version)) $version = array($version);
if ($version) $this->docblock->tags['version'] = $version;
if (!$this->docblock->getKeyword('copyright'))
if ($copyright && !is_array($copyright)) $copyright = array($copyright);
if ($copyright) $this->docblock->tags['copyright'] = $copyright;
$this->docblock->setShortDesc($p->docblock);
$this->docblock->replaceInheritDoc($p->docblock);
* @param string $par parent class name (used by {@link Classes::setClassParent()} if parent class not found
* Use this method to set the type of class to be an interface
$this->_isInterface = true;
* @return boolean true if this is an interface class
return $this->_isInterface;
* Use this method to set access modifiers for a class
$this->_modifiers = $modifiers;
* retrieve object that represents the parent class
* @param Converter this function will not work before the Conversion stage of parsing
* @return mixed returns the {@link parserClass} representation of the parent class, or false if no parent class
if (!$this->parent) return $a;
return $c->classes->getClass($this->parent[1],$this->parent[0]);
* @param Converter this function will not work before the Conversion stage of parsing
* @return array returns a simple array of method objects
return $c->classes->getMethods($this->name,$this->curfile);
* @return mixed {@link parserMethod} or false if not found
* @param Converter this function will not work before the Conversion stage of parsing
* @param string method name in this class
* @param boolean determines whether to search inherited methods as well
function getMethod(&$c, $name, $inherited = false)
$ret = $c->classes->getMethod($this->name, $this->curfile, $name);
while ($x->parent && is_array($x->parent)) {
$par = $x->getParent($c);
if ($meth = $x->getMethod($c, $name)) return $meth;
* @return mixed {@link parserVar} or false if not found
* @param Converter this function will not work before the Conversion stage of parsing
* @param string var name in this class
return $c->classes->getVar($this->name,$this->curfile,$name);
* @param Converter this function will not work before the Conversion stage of parsing
* @return array returns a simple array of method name strings
if (!$c->classes->hasMethods($this->curfile, $this->name)) return array();
for($i= 0; $i < count($arr1); $i++ )
$arr[] = $arr1[$i]->name;
* @param Converter this function will not work before the Conversion stage of parsing
* @param string method name
* @param boolean determines whether to search inherited methods as well
* @return boolean whether this class has a method of name $name
function hasMethod(&$c, $name, $inherited = false)
$ret = $c->classes->hasMethod($this->name, $this->curfile, $name);
while ($x->parent && is_array($x->parent)) {
$par = $x->getParent($c);
if ($x->hasMethod($c, $name)) return true;
* @param Converter this function will not work before the Conversion stage of parsing
* @return boolean whether this class has a var of name $name
return $c->classes->hasVar($this->name, $this->curfile, $name);
* @param Converter this function will not work before the Conversion stage of parsing
* @param string class constant name
* @return boolean whether this class has a constant of name $name
return $c->classes->hasConst($this->name, $this->curfile, $name);
* @param Converter this function will not work before the Conversion stage of parsing
* @return array returns a simple array of var objects
return $c->classes->getVars($this->name,$this->curfile);
* @param Converter this function will not work before the Conversion stage of parsing
* @return array returns a simple array of const objects
return $c->classes->getConsts($this->name,$this->curfile);
* @param Converter this function will not work before the Conversion stage of parsing
* @return array returns a simple array of var name strings
if (!$c->classes->hasVars($this->curfile, $this->name)) return array();
for($i= 0; $i < count($arr1); $i++ )
$arr[] = $arr1[$i]->name;
* @param Converter this function will not work before the Conversion stage of parsing
* @return array returns a simple array of const name strings
if (!$c->classes->hasConsts($this->curfile, $this->name)) return array();
for($i= 0; $i < count($arr1); $i++ )
$arr[] = $arr1[$i]->name;
* @param Converter this function will not work before the Conversion stage of parsing
* @param boolean determines whether overriden methods should be included in the list of inherited methods
* @return array returns an array of methods by parent classname array(name => array(method1,method2..),name2 => array(method1....))
while ($x->parent && is_array($x->parent))
$methods = array_merge($methods,$x->getMethodNames($c));
$par = $x->getParent($c);
$parmethodnames = $par->getMethodNames($c);
$parmethods = $par->getMethods($c);
for($i= 0; $i< count($parmethodnames); $i++ )
if (!in_array($parmethodnames[$i],$methods))
if ($parmethods[$i]->docblock && $parmethods[$i]->docblock->hasaccess && !$c->parseprivate && $parmethods[$i]->docblock->tags['access'][0]->value == 'private')
$methods[] = $parmethodnames[$i];
$arr[$par->getName()]['methods'][] = $parmethods[$i];
$arr[$par->getName()]['file'] = $par->curfile;
if ($parmethods[$i]->docblock && $parmethods[$i]->docblock->hasaccess && !$c->parseprivate && $parmethods[$i]->docblock->tags['access'][0]->value == 'private')
$arr[$par->getName()]['methods'][] = $parmethods[$i];
$arr[$par->getName()]['file'] = $par->curfile;
if (is_a($oldx, 'parserClass') && is_a($oldx->getExtends(true), 'ReflectionClass')) {
$extends = $oldx->getExtends(true);
foreach ($extends->getMethods() as $method) {
if ($method->returnsReference()) {
$var->setReturnsReference();
foreach ($method->getParameters() as $param) {
$value = $param->isDefaultValueAvailable() ? var_export($param->getDefaultValue(), true) : null;
if ($param->isPassedByReference()) {
$var->addParam('&$' . $param->getName(), $value, $param->isOptional(),
$var->addParam('$' . $param->getName(), $value, $param->isOptional(),
$var->setName($method->getName());
$doc->addPackage('package', $oldx->getPackage());
$par = $method->getDeclaringClass();
$var->setLineNumber($par->getStartLine());
if ($method->isPrivate()) {
$modifiers[] = 'private';
if ($method->isAbstract()) {
$modifiers[] = 'abstract';
if ($method->isFinal()) {
if ($method->isProtected()) {
$modifiers[] = 'protected';
if ($method->isPublic()) {
if ($method->isStatic()) {
if ($method->isConstructor()) {
$var->setModifiers($modifiers);
$arr[$oldx->getExtends()]['methods'][] = $var;
$arr[$oldx->getExtends()]['file'] = '(internal)';
* @param Converter this function will not work before the Conversion stage of parsing
* @param boolean determines whether overriden vars should be included in the list of inherited vars
* @return array returns an array of vars by parent classname array(name => array(var1,var1..),name2 => array(var1....))
while ($x->parent && is_array($x->parent))
$par = $x->getParent($c);
$parvarnames = $par->getVarNames($c);
$parvars = $par->getVars($c);
for($i= 0; $i< count($parvarnames); $i++ )
if ($parvars[$i]->docblock && $parvars[$i]->docblock->hasaccess && !$c->parseprivate && $parvars[$i]->docblock->tags['access'][0]->value == 'private')
$vars[] = $parvarnames[$i];
$arr[$par->getName()]['vars'][] = $parvars[$i];
$arr[$par->getName()]['file'] = $par->curfile;
if ($parvars[$i]->docblock && $parvars[$i]->docblock->hasaccess && !$c->parseprivate && $parvars[$i]->docblock->tags['access'][0]->value == 'private')
$arr[$par->getName()]['vars'][] = $parvars[$i];
$arr[$par->getName()]['file'] = $par->curfile;
if (is_a($oldx, 'parserClass') && is_a($oldx->getExtends(true), 'ReflectionClass')) {
$extends = $oldx->getExtends(true);
foreach ($extends->getProperties() as $property) {
$var->setName('$' . $property->getName());
$doc->addPackage('package', $oldx->getPackage());
$par = $property->getDeclaringClass();
$var->setLineNumber($par->getStartLine());
if ($property->isPrivate()) {
$modifiers[] = 'private';
$doc->addAccess('private');
if ($property->isProtected()) {
$modifiers[] = 'protected';
$doc->addAccess('protected');
if ($property->isPublic()) {
$doc->addAccess('public');
$var->setModifiers($modifiers);
$arr[$oldx->getExtends()]['vars'][] = $var;
$arr[$oldx->getExtends()]['file'] = '(internal)';
* @param Converter this function will not work before the Conversion stage of parsing
* @param boolean determines whether overriden vars should be included in the list of inherited vars
* @return array returns an array of consts by parent classname array(name => array(const1,const2..),name2 => array(const1....))
while ($x->parent && is_array($x->parent))
$par = $x->getParent($c);
$parvarnames = $par->getConstNames($c);
$parvars = $par->getConsts($c);
for($i= 0; $i< count($parvarnames); $i++ )
if (!in_array($parvarnames[$i],$consts))
if ($parvars[$i]->docblock && $parvars[$i]->docblock->hasaccess && !$c->parseprivate && $parvars[$i]->docblock->tags['access'][0]->value == 'private')
$consts[] = $parvarnames[$i];
$arr[$par->getName()]['consts'][] = $parvars[$i];
$arr[$par->getName()]['file'] = $par->curfile;
if ($parvars[$i]->docblock && $parvars[$i]->docblock->hasaccess && !$c->parseprivate && $parvars[$i]->docblock->tags['access'][0]->value == 'private')
$arr[$par->getName()]['consts'][] = $parvars[$i];
$arr[$par->getName()]['file'] = $par->curfile;
if (is_a($oldx, 'parserClass') && is_a($oldx->getExtends(true), 'ReflectionClass')) {
$extends = $oldx->getExtends(true);
if (!$extends->getConstants()) {
foreach ($extends->getConstants() as $property => $value) {
$var->setName($property);
$doc->addPackage('package', $oldx->getPackage());
$var->setLineNumber($extends->getStartLine());
$arr[$oldx->getExtends()]['consts'][] = $var;
$arr[$oldx->getExtends()]['file'] = '(internal)';
* @param Converter this function will not work before the Conversion stage of parsing
* @return array Format: array(parentclassname => parserClass/false if no parent, parentclassname2 => ...)
$result[$arr->name] = $arr->getParent($c);
$arr = $arr->getParent($c);
* returns a list of all child classes of this class
* @param Converter this function will not work before the Conversion stage of parsing
* @return array Format: array(parserClass child1,parserClass child2,...)
$kids = $c->classes->getDefiniteChildren($this->name,$this->curfile);
foreach($kids as $chile => $file)
$list[] = $c->classes->getClass($chile,$file);
global $_phpDocumentor_options;
// this may throw an exception. Hopefully it won't if the class exists
$parent = new ReflectionClass($extends);
if (!$parent->isInternal()) {
if (!isset ($this->extends)) return false;
* @subpackage ParserElements
* @version $Id: ParserElements.inc,v 1.15 2006/08/17 02:36:50 cellog Exp $
* Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
* @var string always 'var'
/** @var string class that contains this var */
* Retrieve the class name
* @return string Class name that this var belongs to
* Return a list of access modifiers (static/private/etc.)
* Return name of the class that contains this method
* quick way to link to this element
* @return mixed converter-specific link to this var
* @param string $text text to display for the link or false for default text
function getLink($c, $text = false, $returnobj = false)
return $c->getVarLink($this->name, $this->class, $this->docblock->package, false, $text);
* @return mixed {@link parserVar} representing var this var overrides from the parent class, or false if none
$class = $c->classes->getClass($this->class,$this->path);
$par = $class->getParent($c);
if (is_a($class->getExtends(true), 'ReflectionClass')) {
$pare = $class->getExtends(true);
$property = $par->getProperty(substr($this->name, 1));
$ret->setName('$' . $property->getName());
$doc->addPackage('package', $class->getPackage());
$ret->setLineNumber($par->getStartLine());
if ($property->isPrivate()) {
$modifiers[] = 'private';
$doc->addAccess('private');
if ($property->isProtected()) {
$modifiers[] = 'protected';
$doc->addAccess('protected');
if ($property->isPublic()) {
$doc->addAccess('public');
$ret->setModifiers($modifiers);
if ($par->hasVar($c,$this->name))
$var = $par->getVar($c,$this->name);
if (!($var->docblock && $var->docblock->hasaccess &&
!$c->parseprivate && $var->docblock->tags['access'][0]->value == 'private')) {
$par = $par->getParent($c);
* @return array an array of parserVars from ALL child classes that override this var
$class = $c->classes->getClass($this->class,$this->path);
* @return array an array of parserVars from ALL child classes that override this var in the given class
if (!$class) return $meths;
$kids = $class->getChildClassList($c);
for($i= 0; $i< count($kids); $i++ )
if ($kids[$i]->hasVar($c, $this->name))
$var = $kids[$i]->getVar($c,$this->name);
if (!($var->docblock && $var->docblock->hasaccess && !$c->parseprivate && $var->docblock->tags['access'][0]->value == 'private'))
* @subpackage ParserElements
* Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
* @var string always 'const'
/** @var string class that contains this var */
* Retrieve the class name
* @return string Class name that this var belongs to
* quick way to link to this element
* @return mixed converter-specific link to this var
* @param string $text text to display for the link or false for default text
function getLink($c, $text = false, $returnobj = false)
return $c->getConstLink($this->name, $this->class, $this->docblock->package, false, $text);
* @subpackage ParserElements
* @version $Id: ParserElements.inc,v 1.15 2006/08/17 02:36:50 cellog Exp $
* Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
* @var string always 'method'
/** @var boolean whether this method is a constructor */
/** @var boolean whether this method is a destructor by PEAR standards */
/** @var string class that contains this method */
* @param string default value parsed from function definition
* @param boolean indicates whether this parameter has a default value
* @param null|stringclass type hint
function addParam($name, $value, $has_default = true, $typehint = null)
$this->params[$name] = array($value, $has_default);
$this->params[$name][2] = $typehint;
* adds "constructor " to start of function call if {@link $isConstructor} is true
* @see parent::getFunctionCall()
* Return name of the class that contains this method
* Return name of the class that contains this method
* Return name of the class that contains this method
* @return mixed {@link parserMethod} representing method this method
* overrides from the parent class, or false if none
$class = $c->classes->getClass($this->class,$this->path);
$par = $class->getParent($c);
if (is_a($class->getExtends(true), 'ReflectionClass')) {
$pare = $class->getExtends(true);
$method = $par->getMethod($this->name);
if ($method->returnsReference()) {
$var->setReturnsReference();
foreach ($method->getParameters() as $param) {
$value = $param->isOptional() ? var_export($param->getDefaultValue(), true) : null;
if ($param->isPassedByReference()) {
$var->addParam('&$' . $param->getName(), $value, $param->isOptional(),
$var->addParam('$' . $param->getName(), $value, $param->isOptional(),
$var->setName($method->getName());
$par = $method->getDeclaringClass();
$var->setLineNumber($par->getStartLine());
if ($method->isPrivate()) {
$modifiers[] = 'private';
$doc->addAccess('private');
if ($method->isAbstract()) {
$modifiers[] = 'abstract';
$doc->addKeyword('abstract', $blank);
if ($method->isFinal()) {
$doc->addKeyword('final', $blank);
if ($method->isProtected()) {
$modifiers[] = 'protected';
$doc->addAccess('protected');
if ($method->isPublic()) {
$doc->addAccess('public');
if ($method->isStatic()) {
$doc->addKeyword('static', $blank);
if ($method->isConstructor()) {
$var->setModifiers($modifiers);
if ($par->hasMethod($c,$this->name))
$meth = $par->getMethod($c,$this->name);
if (!($meth->docblock && $meth->docblock->hasaccess &&
!$c->parseprivate && $meth->docblock->tags['access'][0]->value == 'private')) {
$par = $par->getParent($c);
* @return mixed {@link parserMethod} representing method this method implements
* from an interface, or false if none
$class = $c->classes->getClass($this->class,$this->path);
$implements = $class->getImplements();
if (!count($implements)) {
foreach ($implements as $interface) {
$interface_link = $c->getLink('object ' . $interface);
if (is_a($interface_link, 'classlink')) {
$par = $c->classes->getClass($interface_link->name,
if ($par->hasMethod($c, $this->name, true))
$meth = $par->getMethod($c, $this->name);
$meth = $par->getMethod($c, $this->name, true);
if (!($meth->docblock && $meth->docblock->hasaccess &&
!$c->parseprivate && $meth->docblock->tags['access'][0]->value == 'private')) {
if (isset ($haveAlready[$meth->getClass()])) {
// this ensures extended interfaces don't cause
// 2 links to the same method
if ($haveAlready[$meth->getClass()] == $this->name) {
$haveAlready = array($meth->getClass() => $this->name);
$info = new ReflectionClass($interface);
$method = $par->getMethod($this->name);
if ($method->returnsReference()) {
$var->setReturnsReference();
foreach ($method->getParameters() as $param) {
$value = $param->isOptional() ? var_export($param->getDefaultValue(), true) : null;
if ($param->isPassedByReference()) {
$var->addParam('&$' . $param->getName(), $value, $param->isOptional(),
$var->addParam('$' . $param->getName(), $value, $param->isOptional(),
$var->setName($method->getName());
$par = $method->getDeclaringClass();
$var->setLineNumber($par->getStartLine());
if ($method->isPrivate()) {
$modifiers[] = 'private';
$doc->addAccess('private');
if ($method->isAbstract()) {
$modifiers[] = 'abstract';
$doc->addKeyword('abstract', $blank);
if ($method->isFinal()) {
$doc->addKeyword('final', $blank);
if ($method->isProtected()) {
$modifiers[] = 'protected';
$doc->addAccess('protected');
if ($method->isPublic()) {
$doc->addAccess('public');
if ($method->isStatic()) {
$doc->addKeyword('static', $blank);
if ($method->isConstructor()) {
$var->setModifiers($modifiers);
* quick way to link to this element
* @return mixed converter-specific link to this method
* @param string $text text to display for the link or false for default text
function getLink($c, $text = false, $returnobj = false)
return $c->getLink($this->class . '::' . $this->name . '()', $this->docblock->package);
return $c->getMethodLink($this->name, $this->class, $this->docblock->package, false, $text);
* Use this method to tell the parser that this method is the class constructor
* Use this method to tell the parser that this method is the class constructor
* @return array an array of parserMethods from child classes that override this method
$class = $c->classes->getClass($this->class,$this->path);
* @return array an array of parserMethods from ALL child classes that override this method in the given class
if (!$class) return $meths;
$kids = $class->getChildClassList($c);
for($i= 0; $i< count($kids); $i++ )
if ($kids[$i]->hasMethod($c, $this->name))
$meth = $kids[$i]->getMethod($c,$this->name);
if (!($meth->docblock && $meth->docblock->hasaccess && !$c->parseprivate && $meth->docblock->tags['access'][0]->value == 'private'))
* @subpackage ParserElements
* @version $Id: ParserElements.inc,v 1.15 2006/08/17 02:36:50 cellog Exp $
* Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
* @var string always 'define'
* quick way to link to this element
* @return mixed converter-specific link to this define
* @param string $text text to display for the link or false for default text
function getLink($c, $text = false, $returnobj = false)
return $c->getLink('constant ' . $this->name, $this->docblock->package);
return $c->getDefineLink($this->name, $this->docblock->package, false, $text);
* Returns all defines in other packages that have the same name as this define
* @return mixed false or an array Format: (package => {@link parserDefine} of conflicting defines)
$a = $c->proceduralpages->getDefineConflicts($this->name);
* @subpackage ParserElements
* @version $Id: ParserElements.inc,v 1.15 2006/08/17 02:36:50 cellog Exp $
* Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
* @var string always 'packagepage'
var $type = 'packagepage';
* @subpackage ParserElements
* Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
* @var string always 'tutorial'
* Either cls, pkg, or proc
* The documentable element this tutorial is linked to
* Can be a parserData, parserClass, or nothing for package/subpackage docs
* path to the tutorial page
* filename minus extension of this tutorial (used for @tutorial tag)
* output from tutorialname.ext.ini
* an array generated by {@link phpDocumentor_parse_ini_file()} containing
* an index 'Linked Tutorials' with an array of tutorial names in the order
* they should appear. This is used to generate a linked list of tutorials like
* {@tutorial phpDocumentor/tags.pkg}
* link to the next tutorial in a document series, or false if none
* link to the previous tutorial in a document series, or false if none
* link to the parent tutorial in a document series, or false if none
* This is used to generate an "Up" or "Home" link like the php manual.
* The parent is defined as a tutorial that has a parenttutorialname.ext.ini
* file and is not contained by any other tutorial's tutorialname.ext.ini
* links to the child tutorials, or false if none
* @param parserXMLDocBookTag top-level tag (<refentry> for 1.2.0)
* @param information about the tutorial file. Format:
* array('tutename' => tutorial name,
* 'path' => relative path of tutorial to tutorials/ directory
* 'ini' => contents of the tutorial .ini file, if any)
$this->subpackage = $info['subpackage'];
$this->name = $info['tutename'];
$this->path = $info['path'];
$this->ini = $info['ini'];
* Retrieve the title of the tutorial, or of any subsection
* @param string which subsection to retrieve the title from, if any
* @uses parserXMLDocBookTag::getSubSection() retrieve the subsection to
$z = $this->value->getSubSection($c,$subsection);
return $this->value->getTitle($c);
* @param boolean determines whether character data is postprocessed to be
* Converter-friendly or not.
function Convert(&$c, $postprocess = true)
return $this->value->Convert($c, $postprocess);
* @uses $parent creates a link to the documentation for the parent tutorial
$this->parent->addLink('', $parent->path, $parent->name, $parent->package, $parent->subpackage, $parent->getTitle($c));
* @param array array of parserTutorials that have child tutorials
foreach($parents as $i => $parent)
if ($parent->path == $this->path) continue;
if ($parent->ini && ($parent->package == $this->package) && ($parent->subpackage == $this->subpackage) && ($parent->tutorial_type == $this->tutorial_type))
foreach($parent->ini['Linked Tutorials'] as $child)
* Retrieve converter-specific link to the parent tutorial's documentation
if (!$this->parent) return false;
return $c->returnSee($this->parent);
* @uses $next creates a link to the documentation for the next tutorial
$this->next->addLink('', $next->path, $next->name, $next->package, $next->subpackage, $next->getTitle($c));
* Retrieve converter-specific link to the next tutorial's documentation
if (!$this->next) return false;
return $c->returnSee($this->next);
* @uses $prev creates a link to the documentation for the previous tutorial
$this->prev->addLink('', $prev->path, $prev->name, $prev->package, $prev->subpackage, $prev->getTitle($c));
* Retrieve converter-specific link to the previous tutorial's documentation
if (!$this->prev) return false;
return $c->returnSee($this->prev);
* Get a link to this tutorial, or to any subsection of this tutorial
* @param boolean if true, returns a {@link tutorialLink} instead of a string
* @param string section name to link to
* @return string|tutorialLink
function getLink(&$c,$pure = false,$section = '')
$link->addLink($section, $this->path, $this->name, $this->package, $this->subpackage, $this->getTitle($c), $this->category);
return $c->returnSee($link);
|