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