+++ /dev/null
-<?php\r
-/**\r
- * DocBlock Parser Classes\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 ParserDocBlock\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: ParserDocBlock.inc,v 1.12 2007/04/19 20:20:57 ashnazg Exp $\r
- * @link http://www.phpdoc.org\r
- * @link http://pear.php.net/PhpDocumentor\r
- * @see Parser, WordParser\r
- * @since 1.0rc1\r
- */\r
-/**\r
- * represents a short or long description in a DocBlock ({@link parserDocBlock})\r
- * @package phpDocumentor\r
- * @subpackage ParserDocBlock\r
- * @author Greg Beaver <cellog@php.net>\r
- * @since 1.0rc1\r
- * @version $Id: ParserDocBlock.inc,v 1.12 2007/04/19 20:20:57 ashnazg Exp $\r
- */\r
-class parserDesc extends parserStringWithInlineTags\r
-{\r
- /**\r
- * Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'\r
- * always '_desc'\r
- * @var string\r
- */\r
- var $type = '_desc';\r
- \r
- /**\r
- * @param mixed like {@link parserStringWithInlineTags::add()}, this can be a string or parserInlineTag, but it can also be a\r
- * parserStringWithInlineTags, and the contents will be merged\r
- */\r
- function add($stringOrClass)\r
- {\r
- if (is_object($stringOrClass))\r
- {\r
- if (phpDocumentor_get_class($stringOrClass) == 'parserstringwithinlinetags' ||\r
- phpDocumentor_get_class($stringOrClass) == 'parserdesc')\r
- {\r
- for($i=0;$i<count($stringOrClass->value);$i++)\r
- {\r
- parserStringWithInlineTags::add($stringOrClass->value[$i]);\r
- }\r
- } else\r
- {\r
- parserStringWithInlineTags::add($stringOrClass);\r
- }\r
- } else return parserStringWithInlineTags::add($stringOrClass);\r
- }\r
- \r
- /**\r
- * @return boolean whether this desc has an {@}inheritdoc} inline tag\r
- */\r
- function hasInheritDoc()\r
- {\r
- for($i=0;$i<count($this->value);$i++)\r
- {\r
- if (phpDocumentor_get_class($this->value[$i])=='parserinheritdocinlinetag') return true;\r
- }\r
- }\r
- \r
- /**\r
- * @return boolean whether this desc has an {@}source} inline tag\r
- */\r
- function hasSource()\r
- {\r
- for($i=0;$i<count($this->value);$i++)\r
- {\r
- if (phpDocumentor_get_class($this->value[$i])=='parsersourceinlinetag') return true;\r
- }\r
- }\r
- \r
- /**\r
- * replaces {@}inheritdoc} with the contents of the parent DocBlock\r
- * @param parserDesc parent parserDesc, used to retrieve the description\r
- */\r
- function replaceInheritDoc($desc)\r
- {\r
- $value = $this->value;\r
- $this->value = array();\r
- for($i=0;$i<count($value);$i++)\r
- {\r
- if (phpDocumentor_get_class($value[$i])=='parserinheritdocinlinetag')\r
- {\r
- for($j=0;$j<count($desc->value);$j++)\r
- {\r
- $this->add($desc->value[$j]);\r
- }\r
- } else $this->add($value[$i]);\r
- }\r
- }\r
-}\r
-\r
-/**\r
- * Represents a docblock and its components, {@link $desc}, {@link $sdesc}, {@link $tags}, and also {@link $params} for functions\r
- * @package phpDocumentor\r
- * @subpackage ParserDocBlock\r
- * @author Greg Beaver <cellog@php.net>\r
- * @since 1.0rc1\r
- * @version $Id: ParserDocBlock.inc,v 1.12 2007/04/19 20:20:57 ashnazg Exp $\r
- */\r
-class parserDocBlock\r
-{\r
- /**\r
- * @var parserDesc\r
- */\r
- var $desc = false;\r
- /**\r
- * @var array array of {@link parserDesc}s\r
- */\r
- var $processed_desc = false;\r
- /**\r
- * @var array array of {@link parserDesc}s\r
- */\r
- var $processed_sdesc = false;\r
- /**\r
- * @var parserDesc\r
- */\r
- var $sdesc = false;\r
- /**\r
- * Line number in the source on which this docblock begins\r
- * @since 1.2\r
- * @var false|integer\r
- */\r
- var $linenumber = false;\r
- /**\r
- * Line number in the source on which this docblock ends\r
- * @since 1.2\r
- * @var false|integer\r
- */\r
- var $endlinenumber = false;\r
- /**\r
- * array of {@link parserTag}s\r
- * @var array\r
- */\r
- var $tags = array();\r
- /**\r
- * array of unrecognized {@link parserTag}s\r
- * @var array\r
- */\r
- var $unknown_tags = array();\r
- /**\r
- * array of param data.\r
- * Format:\r
- * array(index of param in function parameter list -OR- parameter name =>\r
- * parserStringWithInlineTags,...)\r
- * @var array\r
- */\r
- var $params = array();\r
- /**\r
- * array of global variable data.\r
- * Format:\r
- * array(index of global variable in @global tag list -OR- global variable name =>\r
- * array(datatype,parserStringWithInlineTags),...)\r
- * @var array\r
- */\r
- var $funcglobals = array();\r
- \r
- /**\r
- * array of static variable data.\r
- * Format:\r
- * array(index of static variable in @global tag list -OR- static variable name =>\r
- * {@link parserStaticvarTag},...)\r
- * @var array\r
- */\r
- var $statics = array();\r
- /**\r
- * array of {@link parserPropertyTag}, {@link parserPropertyReadTag}, {@link parserPropertyWriteTag}, {@link parserMethodTag} magic tags\r
- */\r
- var $properties = array();\r
- /**\r
- * This is either a {@link parserReturnTag} or false if no return tag is present\r
- * @var mixed\r
- */\r
- var $return = false;\r
- /**\r
- * This is either a {@link parserVarTag} or false if no var tag is present\r
- * @var mixed\r
- */\r
- var $var = false;\r
- /**\r
- * fix for bug 591396\r
- * @var boolean\r
- */\r
- var $explicitpackage = false;\r
- /**\r
- * fix for bug 708559\r
- * @var boolean\r
- */\r
- var $explicitcategory = false;\r
- /** @var string */\r
- var $category;\r
- /** @var string */\r
- var $package = 'default';\r
- /** @var string */\r
- var $subpackage = '';\r
- /**\r
- * whether this DocBlock has an @access tag\r
- * @var boolean */\r
- var $hasaccess = false;\r
- /**\r
- * whether this DocBlock has a @name tag\r
- * @var boolean */\r
- var $hasname = false;\r
- /**\r
- * description of package parsed from @package tag\r
- * Unused in this version\r
- * @var string\r
- */\r
- var $packagedescrip = '';\r
- /**\r
- * description of subpackage parsed from @package tag\r
- * Unused in this version\r
- * @var string\r
- */\r
- var $subpackagedescrip = '';\r
- /**\r
- * Determines whether a DocBlock can legally have a {@}source} tag\r
- * @tutorial tags.inlinesource.pkg\r
- * @var boolean\r
- * @access private\r
- */\r
- var $_canSource = false;\r
- \r
- /**\r
- * sets package to default\r
- * @global string default package name\r
- */\r
- function parserDocBlock()\r
- {\r
- global $phpDocumentor_DefaultPackageName;\r
- $this->package = $GLOBALS['phpDocumentor_DefaultPackageName'];\r
- $this->category = $GLOBALS['phpDocumentor_DefaultCategoryName'];\r
- }\r
- \r
- /**\r
- * Sets the starting line number for the DocBlock\r
- * @param integer\r
- */\r
- function setLineNumber($number)\r
- {\r
- $this->linenumber = $number;\r
- }\r
- \r
- /**\r
- * Retrieve starting line number\r
- * @return integer\r
- */\r
- function getLineNumber()\r
- {\r
- return $this->linenumber;\r
- }\r
- \r
- /**\r
- * Sets the ending line number for the DocBlock\r
- * @param integer\r
- */\r
- function setEndLineNumber($number)\r
- {\r
- $this->endlinenumber = $number;\r
- }\r
- \r
- /**\r
- * Retrieve ending line number\r
- * @return integer\r
- */\r
- function getEndLineNumber()\r
- {\r
- return $this->endlinenumber;\r
- }\r
- \r
- /**\r
- * Parse out any html tags from doc comments, and make them into\r
- * abstract structures\r
- * @uses parserDescParser::parse()\r
- */\r
- function postProcess()\r
- {\r
- if ($this->sdesc)\r
- {\r
- $parser = new parserDescParser;\r
- $parser->subscribe('*',$this);\r
- if ($this->desc) $parser->parse($this->desc->value);\r
- $parser->parse($this->sdesc->value,true);\r
- }\r
- }\r
- \r
- /**\r
- * Tells the DocBlock it can have a @filesource tag\r
- *\r
- * Only page-level DocBlocks may have a @filesource tag\r
- */\r
- function canSource()\r
- {\r
- $this->_canSource = true;\r
- }\r
- \r
- /**\r
- * Tells the DocBlock it can't have a @filesource tag\r
- *\r
- * Only page-level DocBlocks may have a @filesource tag\r
- */\r
- function cantSource()\r
- {\r
- $this->_canSource = false;\r
- }\r
- \r
- /**\r
- * Indirectly called after parsing by {@link postProcess}\r
- *\r
- * @param integer either 1 for long desc or 2 for short desc\r
- * @param array data organized into paragraphs. Each entry is a {@link parserStringWithInlineTags}\r
- * @uses $processed_desc sets to the array passed from {@link parserDescParser::parse()}\r
- * @uses $processed_sdesc sets to the array passed from {@link parserDescParser::parse()}\r
- * @access private\r
- */\r
- function HandleEvent($event,$data)\r
- {\r
- if ($event == 1)\r
- $this->processed_desc = $data;\r
- else\r
- $this->processed_sdesc = $data;\r
- }\r
- \r
- /**\r
- * @param array\r
- */\r
- function updateModifiers($modifiers)\r
- {\r
- if (is_array($modifiers) && count($modifiers))\r
- {\r
- foreach ($modifiers as $modifier)\r
- {\r
- switch ($modifier)\r
- {\r
- case 'private' :\r
- case 'public' :\r
- case 'protected' :\r
- unset($this->tags['access']);\r
- $x = new parserAccessTag($modifier);\r
- if ($x->isvalid)\r
- {\r
- $this->hasaccess = true;\r
- $this->tags['access'][] = $x;\r
- }\r
- break;\r
- case 'static' :\r
- case 'abstract' :\r
- unset($this->tags[$modifier]);\r
- $this->addKeyword($modifier, '');\r
- break;\r
- }\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * Set the short description of the DocBlock\r
- *\r
- * Setting the short description is possible by passing in one of three\r
- * possible parameters:\r
- * <ul>\r
- * <li>another DocBlock's short description</li>\r
- * <li>another DocBlock, the short description will be extracted</li>\r
- * <li>a Zend Studio-compatible @desc tag</li>\r
- * </ul>\r
- * @param parserDesc|parserDocBlock|parserTag sets {@link $sdesc}\r
- */\r
- function setShortDesc($desc)\r
- {\r
- if (phpDocumentor_get_class($desc) == 'parsertag')\r
- {\r
- $this->sdesc = new parserDesc;\r
- $this->processed_sdesc = $desc->value;\r
- return;\r
- }\r
- if (phpDocumentor_get_class($desc) == 'parserdesc') {\r
- $this->sdesc = $desc;\r
- } else\r
- {\r
- $this->sdesc = $desc->sdesc;\r
- $this->processed_sdesc = $desc->processed_sdesc;\r
- }\r
- \r
- if ($this->sdesc && $this->sdesc->hasSource())\r
- {\r
- addWarning(PDERROR_SOURCE_TAG_IGNORED,$this->sdesc->getString());\r
- }\r
- }\r
- \r
- /**\r
- * Passes to {@link parserStringWithInlineTags::setSource()}\r
- *\r
- * After passing, it calls {@link postProcess()} to set up the new\r
- * source\r
- * @param string|array tokenized highlight-ready source code\r
- * @param false|string name of class if this is a method source\r
- */\r
- function setSource($source, $class = false)\r
- {\r
- if ($this->desc)\r
- {\r
- $this->desc->setSource($source, $class);\r
- $this->postProcess();\r
- }\r
- }\r
- \r
- /**\r
- * @param parserDesc|parserDocBlock sets {@link $desc}\r
- */\r
- function setDesc($desc)\r
- {\r
- if (phpDocumentor_get_class($desc) == 'parserdesc')\r
- $this->desc = $desc;\r
- else\r
- {\r
- $this->desc = $desc->desc;\r
- $this->processed_desc = $desc->processed_desc;\r
- }\r
- }\r
- \r
- /**\r
- * Wrapper for {@link parserDesc::hasInheritDoc()}\r
- * @return boolean\r
- */\r
- function hasInheritDoc()\r
- {\r
- if (!$this->desc) return false;\r
- return $this->desc->hasInheritDoc();\r
- }\r
- \r
- /**\r
- * Wrapper for {@link parserDesc::replaceInheritDoc()}\r
- *\r
- * Also replaces {@}inheritdoc} in the {@link $processed_desc}\r
- * @param parserDesc\r
- */\r
- function replaceInheritDoc($desc)\r
- {\r
- if (!$this->desc) return false;\r
- $this->desc->replaceInheritDoc($desc->desc);\r
- $this->postProcess();\r
- }\r
- \r
- /**\r
- * @param Converter takes {@link $sdesc} and converts it to a string and returns it if present, otherwise returns ''\r
- * @return string\r
- */\r
- function getSDesc(&$converter)\r
- {\r
- if ($this->sdesc && $this->processed_sdesc)\r
- {\r
- $result = '';\r
- foreach($this->processed_sdesc as $desc)\r
- {\r
- if (count($desc->value))\r
- $result .= $desc->Convert($converter);\r
- }\r
- return $result;\r
- } else\r
- {\r
-// var_dump($this->desc,$this->processed_desc);\r
- }\r
- return '';\r
- }\r
- \r
- /**\r
- * @param Converter takes {@link $desc} and converts it to a string and returns it if present, otherwise returns ''\r
- * @return string\r
- */\r
- function getDesc(&$converter)\r
- {\r
- if ($this->desc && $this->processed_desc)\r
- {\r
- $result = '';\r
- foreach($this->processed_desc as $desc)\r
- {\r
- if (count($desc->value))\r
- $result .= $converter->EncloseParagraph($desc->Convert($converter));\r
- }\r
- return $result;\r
- } else\r
- {\r
-// var_dump($this->desc,$this->processed_desc);\r
- }\r
- return '';\r
- }\r
- \r
- /**\r
- * @param string $paramVar if empty, param is indexed in the order received and set using {@link changeParam()}\r
- * @param parserStringWithInlineTags $value\r
- */\r
- function addParam($paramVar, $paramType, $value)\r
- {\r
- if (empty($paramVar))\r
- $this->params[count($this->params)] = new parserParamTag($paramType,$value);\r
- else\r
- $this->params[$paramVar] = new parserParamTag($paramType,$value);\r
- }\r
-\r
- function resetParams()\r
- {\r
- $this->params = array();\r
- }\r
- /**\r
- * @param integer $index index of parameter in the {@link $params} array\r
- * @param string $name name of the parameter to set in the $params array\r
- * @param string|null $type type of the parameter\r
- */\r
- function changeParam($index, $name, $type)\r
- {\r
- if ($name === $index) {\r
- return;\r
- }\r
- $this->params[$name] = $this->params[$index];\r
- unset($this->params[$index]);\r
- }\r
- \r
- /**\r
- * replaces nameless parameters in the {@link $params} array with their names\r
- * add @param tags for params in the function with no entry\r
- * @param array $params Format: array(parameter key =>\r
- * array(0 => parameter name[,1 => default value][,2 => type hint]),...)\r
- */\r
- function updateParams($params)\r
- {\r
- $countparams = array_values($params);\r
- reset($params);\r
- for($i=0;$i<count($countparams);$i++, next($params))\r
- {\r
- if (isset($this->params[$i]))\r
- {\r
- $info = current($params);\r
- $type = isset($info[2]) ? $info[2] : null;\r
- $this->changeParam($i, key($params), $type);\r
- $params[key($params)] = false;\r
- }\r
- }\r
- $blank = new parserStringWithInlineTags;\r
- foreach ($params as $key => $info) {\r
- if (!$info) {\r
- continue;\r
- }\r
- $type = isset($info[2]) ? $info[2] : null;\r
- if (!isset($this->params[$info[0]])) {\r
- $this->addParam($info[0], $type, $blank);\r
- }\r
- }\r
- reset($params);\r
- \r
- if (isset($this->tags))\r
- unset($this->tags['param']);\r
- }\r
- \r
- /**\r
- * Used to insert DocBlock Template tags into a docblock\r
- * @param parserTag tag\r
- * @global array used to determine whether to add ignored tags, or not\r
- */\r
- function addTag($tag)\r
- {\r
- global $_phpDocumentor_setting;\r
- if (phpDocumentor_setup::checkIgnoreTag($tag->keyword)) return;\r
- $value = $tag->value;\r
- if (is_array($value)) $value = $value[0];\r
- if ($tag->keyword == 'uses')\r
- {\r
- $this->addUses($value, $tag->_description);\r
- } else\r
- {\r
- $this->addKeyword($tag->keyword, $value);\r
- }\r
- }\r
-\r
- /**\r
- * @param string $keyword tag name\r
- * @param parserStringWithInlineTags $value the contents of the tag\r
- * @global array used to determine whether to add the @internal tag or not\r
- */\r
- function addKeyword($keyword, $value)\r
- {\r
- global $_phpDocumentor_setting;\r
- $keyword = trim($keyword);\r
- if (phpDocumentor_setup::checkIgnoreTag($keyword)) return;\r
- // don't add the tag at all if it was specified to ignore it with --ignore-tags\r
- if ($keyword == 'package' || $keyword == 'subpackage' || $keyword == 'category') return $this->addPackage($keyword, $value);\r
- if ($keyword == 'access') return $this->addAccess($value);\r
- if ($keyword == 'link') return $this->addLink($value);\r
- if ($keyword == 'see' || $keyword == 'tutorial') return $this->addSee($keyword,$value);\r
- if ($keyword == 'uses') return $this->addUses($keyword, $value);\r
- if ($keyword == 'name') return $this->addName($value);\r
- if (!in_array($keyword,$GLOBALS['_phpDocumentor_tags_allowed']))\r
- $this->addUnknownTag($keyword,$value);\r
- else\r
- {\r
- if ($keyword == 'internal' && (!isset($_phpDocumentor_setting['parseprivate']) || $_phpDocumentor_setting['parseprivate'] == 'off')) return;\r
- if (!isset($this->tags[$keyword])) {\r
- $this->tags[$keyword] = array();\r
- }\r
- $ptag = 'parserTag';\r
- if (class_exists('parser'.$keyword.'tag'))\r
- $ptag = 'parser'.ucfirst($keyword).'Tag';\r
- array_unshift($this->tags[$keyword], new $ptag($keyword, $value));\r
- }\r
- }\r
- \r
- /**\r
- * adds an @example tag\r
- * @param string contents of the tag\r
- * @param string path to the file containing this tag\r
- */\r
- function addExample($value, $path)\r
- {\r
- $this->tags['example'][] = new parserExampleTag($value, $path);\r
- }\r
- \r
- /**\r
- * adds an unknown tag to the {@link $unknown_tags} array for use by custom converters\r
- * @param string tag name\r
- * @param string tag value\r
- */\r
- function addUnknownTag($keyword, $value)\r
- {\r
- addWarning(PDERROR_UNKNOWN_TAG,$keyword);\r
- $this->unknown_tags[$keyword][] = new parserTag($keyword, $value);\r
- }\r
- \r
- /**\r
- * set the element's package to the passed values. Used in {@link phpDocumentor_IntermediateParser} to align package of\r
- * elements inside a class or procedural page to the package of the class/procedural page\r
- * @param string\r
- * @param string\r
- * @param string\r
- * @param string element name\r
- * @param string element type (include, define, var, method, global, function, const)\r
- */\r
- function overridePackage($category, $package,$subpackage,$elname,$type)\r
- {\r
- if ($this->package != $GLOBALS['phpDocumentor_DefaultPackageName'])\r
- {\r
- addError(PDERROR_OVERRIDDEN_PACKAGE_TAGS,$elname,$type,$this->package);\r
- $this->explicitpackage = false;\r
- }\r
- if (!empty($this->subpackage))\r
- addError(PDERROR_OVERRIDDEN_SUBPACKAGE_TAGS,$type,$elname,$this->subpackage);\r
- $this->package = $GLOBALS['phpDocumentor_DefaultPackageName'];\r
- $this->subpackage = '';\r
- $this->category = $category;\r
- $this->addPackage('package',$package);\r
- $this->addPackage('subpackage',$subpackage);\r
- }\r
- \r
- /**\r
- * Used if this docblock has a @package tag.\r
- *\r
- * phpDocumentor will guess package for DocBlocks that don't have\r
- * a @package tag\r
- * @uses $explicitpackage\r
- */\r
- function setExplicitPackage()\r
- {\r
- $this->explicitpackage = true;\r
- }\r
- \r
- /**\r
- * If the DocBlock has a @package tag, then this returns true\r
- * @return boolean\r
- */\r
- function getExplicitPackage()\r
- {\r
- return $this->explicitpackage;\r
- }\r
- \r
- /**\r
- * Used if this docblock has a @category tag.\r
- *\r
- * phpDocumentor will guess category for DocBlocks that don't have\r
- * a @category tag\r
- * @uses $explicitcategory\r
- */\r
- function setExplicitCategory()\r
- {\r
- $this->explicitcategory = true;\r
- }\r
- \r
- /**\r
- * If the DocBlock has a @category tag, then this returns true\r
- * @return boolean\r
- */\r
- function getExplicitCategory()\r
- {\r
- return $this->explicitcategory;\r
- }\r
- \r
- /**\r
- * @param string $keyword tag name (either package or subpackage)\r
- * @param mixed $value either a string or a parserStringWithInlineTags. Strips all inline tags and use the text as the package\r
- */\r
- function addPackage($keyword, $value)\r
- {\r
- if ($keyword == 'package')\r
- {\r
- if (!$this->explicitpackage)\r
- {\r
- if (!is_string($value))\r
- $value = $value->getString();\r
- $rest = '';\r
- $value = explode(' ',$value);\r
- if (count($value) - 1)\r
- {\r
- $rest = $value;\r
- $value = trim($value[0]);\r
- unset($rest[0]);\r
- $rest = implode($rest,' ');\r
- } else\r
- {\r
- $value = explode("\t",$value[0]);\r
- if (count($value) - 1)\r
- {\r
- $rest = $value;\r
- $value = trim($value[0]);\r
- unset($rest[0]);\r
- $rest = implode($rest,"\t");\r
- } else $value = trim($value[0]);\r
- }\r
- $value = preg_replace('/[^\[\]0-9\-a-zA-Z_\x7f-\xff]/', '-', $value);\r
- $this->packagedescrip = $this->package = trim($value);\r
- if (!empty($rest)) $this->packagedescrip = $rest;\r
- } else\r
- {\r
- if (is_string($value))\r
- addError(PDERROR_MULTIPLE_PACKAGE_TAGS,$value);\r
- else\r
- addError(PDERROR_MULTIPLE_PACKAGE_TAGS,$value->getString());\r
- }\r
- } elseif ($keyword == 'subpackage')\r
- {\r
- if (empty($this->subpackage))\r
- {\r
- if (!is_string($value))\r
- $value = $value->getString();\r
- $rest = '';\r
- $value = explode(' ',$value);\r
- if (count($value) - 1)\r
- {\r
- $rest = $value;\r
- $value = $value[0];\r
- unset($rest[0]);\r
- $rest = implode($rest,' ');\r
- } else\r
- {\r
- $value = explode("\t",$value[0]);\r
- if (count($value) - 1)\r
- {\r
- $rest = $value;\r
- $value = $value[0];\r
- unset($rest[0]);\r
- $rest = implode($rest,"\t");\r
- } else $value = $value[0];\r
- }\r
- if (!empty($value))\r
- {\r
- $value = preg_replace('/[^\[\]0-9\-a-zA-Z_\x7f-\xff]/', '-', $value);\r
- }\r
- $this->subpackage = trim($value);\r
- if (!empty($rest)) $this->subpackagedescrip = $rest;\r
- } else\r
- {\r
- if (is_string($value))\r
- addError(PDERROR_MULTIPLE_SUBPACKAGE_TAGS,$value);\r
- else\r
- addError(PDERROR_MULTIPLE_SUBPACKAGE_TAGS,$value->getString());\r
- }\r
- } elseif ($keyword == 'category')\r
- {\r
- if (!$this->explicitcategory)\r
- {\r
- if (!is_string($value))\r
- $value = $value->getString();\r
- $value = preg_replace('/[^\[\]0-9\-a-zA-Z_\x7f-\xff]/', '-', $value);\r
- $this->category = $value;\r
- } else\r
- {\r
- if (is_string($value))\r
- addError(PDERROR_MULTIPLE_CATEGORY_TAGS,$value);\r
- else\r
- addError(PDERROR_MULTIPLE_CATEGORY_TAGS,$value->getString());\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * Adds a @name tag to the tag list\r
- * @param string new name of element\r
- */\r
- function addName($value)\r
- {\r
- if (is_object($value)) $value = $value->getString();\r
- if (!$this->hasname)\r
- {\r
- $x = new parserNameTag('name',$value);\r
- $this->hasname = true;\r
- $this->tags['name'][] = $x;\r
- } else\r
- {\r
- addError(PDERROR_MULTIPLE_NAME_TAGS,$value);\r
- }\r
- }\r
- \r
- /**\r
- * @param string if empty, staticvar is indexed in the order received and set using {@link changeStatic()}\r
- * @param string data type\r
- * @param parserStringWithInlineTags\r
- */\r
- function addStaticVar($staticvar, $type, $descrip)\r
- {\r
- if (empty($staticvar))\r
- $this->statics[] = new parserStaticvarTag($type,$descrip);\r
- else\r
- $this->statics[$staticvar] = new parserStaticvarTag($type,$descrip);\r
- }\r
- \r
- /**\r
- * adds a function declaration of @global to the {@link $funcglobals} array\r
- * @param string global type\r
- * @param string description of how the global is used in the function\r
- */\r
- function addFuncGlobal($type,$value)\r
- {\r
- $this->funcglobals[] = array($type,$value);\r
- }\r
- \r
- /**\r
- * @param integer $index index of parameter in the {@link $funcglobals} array\r
- * @param string $name name of the parameter to set in the $funcglobals array\r
- */\r
- function changeGlobal($index,$name)\r
- {\r
- $this->funcglobals[$name] = $this->funcglobals[$index];\r
- unset($this->funcglobals[$index]);\r
- }\r
-\r
- /**\r
- * @param integer $index index of parameter in the {@link $statics} array\r
- * @param string $name name of the parameter to set in the $statics array\r
- */\r
- function changeStatic($index,$name)\r
- {\r
- $this->statics[$name] = $this->statics[$index];\r
- unset($this->statics[$index]);\r
- }\r
-\r
- /**\r
- * replaces nameless global variables in the {@link $funcglobals} array with their names\r
- * @param array\r
- */\r
- function updateGlobals($funcs)\r
- {\r
- for($i=0;$i<count($funcs);$i++)\r
- {\r
- if (isset($this->funcglobals[$i]))\r
- {\r
- $this->changeGlobal($i,$funcs[$i]);\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * replaces nameless static variables in the {@link $statics} array with their names\r
- * @param array\r
- */\r
- function updateStatics($funcs)\r
- {\r
- for($i=0;$i<count($funcs);$i++)\r
- {\r
- if (isset($this->statics[$i]))\r
- {\r
- $this->changeStatic($i,$funcs[$i]);\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * add an @access tag to the {@link tags} array\r
- * @param string should be either public or private\r
- */\r
- function addAccess($value)\r
- {\r
- if (is_object($value)) $value = $value->getString();\r
- $value = strtolower($value);\r
- if (!$this->hasaccess)\r
- {\r
- $x = new parserAccessTag($value);\r
- if ($x->isvalid)\r
- {\r
- $this->hasaccess = true;\r
- $this->tags['access'][] = $x;\r
- }\r
- } else\r
- {\r
- if (is_string($value))\r
- addError(PDERROR_MULTIPLE_ACCESS_TAGS,$value);\r
- else\r
- addError(PDERROR_MULTIPLE_ACCESS_TAGS,$value->getString());\r
- }\r
- }\r
- \r
- /**\r
- * Adds a new @filesource tag to the DocBlock\r
- * @tutorial tags.filesource.pkg\r
- * @param string full path to the file\r
- * @param array tokenized source code, ordered by line number\r
- */\r
- function addFileSource($path, $source)\r
- {\r
- if (isset($this->tags['filesource'])) return;\r
- $this->tags['filesource'][] = new parserFileSourceTag($path, $source);\r
- }\r
- \r
- /**\r
- * creates a {@link parserLinkTag} and adds it to the {@link $tags} array\r
- * @param string $link\r
- */\r
- function addLink($link)\r
- {\r
- if (phpDocumentor_setup::checkIgnoreTag('@link')) return;\r
- $this->tags['link'][] = new parserLinkTag($link);\r
- }\r
- \r
- /**\r
- * creates a {@link parserLinkTag} and adds it to the {@link $tags} array\r
- * @param string either see or uses\r
- * @param string $value\r
- */\r
- function addSee($keyword,$value)\r
- {\r
- if (phpDocumentor_setup::checkIgnoreTag($keyword)) return;\r
- $tag = 'parser'.ucfirst($keyword).'Tag';\r
- $this->tags[$keyword][] = new $tag($value);\r
- }\r
- \r
- /**\r
- * creates a {@link parserReturnTag} and adds it to the {@link $tags} array\r
- * @param string $returnType the one-word name of the return type (mixed should be used if more than one type)\r
- * @param parserStringWithInlineTags $value\r
- */\r
- function addReturn($returnType, $value)\r
- {\r
- // only take the first one\r
- if (!$this->return)\r
- {\r
- $this->return = new parserReturnTag($returnType, $value);\r
- } else\r
- {\r
- addError(PDERROR_MULTIPLE_RETURN_TAGS,$returnType,$value->getString());\r
- }\r
- }\r
- \r
- /**\r
- * creates a {@link parserVarTag} and adds it to the {@link $tags} array\r
- * @param string $varType the one-word name of the variable type (mixed should be used if more than one type)\r
- * @param parserStringWithInlineTags $value\r
- */\r
- function addVar($varType, $value)\r
- {\r
- // only take the first one\r
- if (!$this->var)\r
- {\r
- $this->var = new parserVarTag($varType, $value);\r
- } else\r
- {\r
- addError(PDERROR_MULTIPLE_VAR_TAGS,$varType,$value->getString());\r
- }\r
- }\r
- \r
- /**\r
- * Adds a virtual @usedby tag to output\r
- * @param abstractLink link to the element that has a @uses tag\r
- * @param parserStringWithInlinetags description of how the elements uses\r
- * this one\r
- * @access private\r
- */\r
- function addUsedBy($link, $descrip)\r
- {\r
- $this->tags['usedby'][] = new parserUsedByTag($link, $descrip);\r
- }\r
- \r
- /**\r
- * Add a @uses tag to the DocBlock\r
- * @param string @see-style text, used for {@link Converter::getLink()}\r
- * @param parserStringWithInlineTags description of how the used element is\r
- * used\r
- * @tutorial tags.uses.pkg\r
- */\r
- function addUses($seeel, $description)\r
- {\r
- $this->tags['uses'][] = new parserUsesTag($seeel, $description);\r
- usort($this->tags['uses'], array($this, '_sortUses'));\r
- }\r
-\r
- /**\r
- * Adds a @property(-read or -write) or @method magic tag to the DocBlock\r
- */\r
- function addProperty( $tagName, $propertyName, $propertyType, $value )\r
- {\r
- if ( empty( $propertyName ) )\r
- {\r
- addWarning ( PDERROR_MISSING_PROPERTY_TAG_NAME, $tagName, $tagName, $propertyType, $value->getString() );\r
- }\r
- else\r
- {\r
- switch ( $tagName )\r
- {\r
- case 'property':\r
- $this->properties[ $propertyName ] = new parserPropertyTag( $propertyType, $value );\r
- break;\r
- case 'property-read':\r
- $this->properties[ $propertyName ] = new parserPropertyReadTag( $propertyType, $value );\r
- break;\r
- case 'property-write':\r
- $this->properties[ $propertyName ] = new parserPropertyWriteTag( $propertyType, $value );\r
- break;\r
- case 'method':\r
- $this->properties[ $propertyName ] = new parserMethodTag( $propertyType, $value );\r
- break;\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * Custom sorting function for sorting @uses tags\r
- *\r
- * @param parserTag $a\r
- * @param parserTag $b\r
- * @access private\r
- * @return int\r
- */\r
- function _sortUses($a, $b)\r
- {\r
- return strnatcasecmp($a->getString(), $b->getString());\r
- }\r
-\r
- /**\r
- * @param string\r
- * @return mixed false if no keyword, unconverted value if one keyword, array of unconverted values if more than one keyword\r
- */\r
- function getKeyword($keyword)\r
- {\r
- if ($keyword == 'filesource' && !$this->_canSource) return false;\r
- if (isset($this->tags[$keyword]))\r
- {\r
- if (count($this->tags[$keyword]) == 1)\r
- {\r
- return $this->tags[$keyword][0];\r
- } else return $this->tags[$keyword];\r
- } else return false;\r
- }\r
- \r
- /**\r
- * @return array Format: array('var' => tag name, 'data' => unconverted tag value)\r
- */\r
- function listParams()\r
- {\r
- if (isset($this->params))\r
- {\r
- $ret = array();\r
- foreach($this->params as $key => $val)\r
- {\r
- $ret[] = array("var" => ucfirst($key),"data" => $val);\r
- }\r
- return $ret;\r
- } else {\r
- return array();\r
- }\r
- }\r
-\r
- /**\r
- * @return array Format: array('var' => tag name, 'data' => unconverted tag value)\r
- */\r
- function listProperties()\r
- {\r
- $ret = array();\r
- if (isset($this->properties))\r
- {\r
- foreach($this->properties as $key => $val)\r
- {\r
- $ret[] = array("var" => ucfirst($key),"data" => $val);\r
- }\r
- }\r
- return $ret;\r
- }\r
- \r
- /**\r
- * @param Converter\r
- */\r
- function listTags()\r
- {\r
- $tags = array();\r
- foreach($this->tags as $keyword => $vals)\r
- {\r
- if ($keyword == 'filesource' && !$this->_canSource) continue;\r
- foreach($vals as $val)\r
- {\r
- $tags[] = $val;\r
- }\r
- }\r
- usort($tags,'tagsort');\r
- return $tags;\r
- }\r
- \r
- /** @return string always 'docblock' */\r
- function getType()\r
- {\r
- return 'docblock';\r
- }\r
-}\r
-\r
-/**\r
- * Determines the arbitrary tag rank value for a given tag\r
- * @access private\r
- */\r
-function getTagRanking($tag)\r
-{\r
- switch(phpDocumentor_get_class($tag))\r
- {\r
- case 'parserreturntag' :\r
- $o = 0;\r
- break;\r
- case 'parservartag' :\r
- $o = 1;\r
- break;\r
- case 'parsertutorialtag' :\r
- $o = 2;\r
- break;\r
- case 'parserstaticvartag' :\r
- $o = 3;\r
- break;\r
- case 'parserseetag' :\r
- $o = 10;\r
- break;\r
- case 'parserlinktag' :\r
- $o = 11;\r
- break;\r
- case 'parsertag' :\r
- switch ($tag->keyword)\r
- {\r
- case 'author' :\r
- $o = 4;\r
- break;\r
- case 'version' :\r
- $o = 5;\r
- break;\r
- case 'copyright' :\r
- $o = 6;\r
- break;\r
- case 'deprecated' :\r
- case 'deprec' :\r
- $o = 12;\r
- break;\r
- case 'todo' :\r
- case 'TODO' :\r
- $o = 13;\r
- break;\r
- case 'abstract' :\r
- $o = 14;\r
- break;\r
- default :\r
- $o = 15;\r
- break;\r
- }\r
- break;\r
- case 'parseraccesstag' :\r
- $o = 18;\r
- break;\r
- case 'parsernametag' :\r
- $o = 19;\r
- break;\r
- default :\r
- $o = 20;\r
- break;\r
- }\r
- return $o;\r
-}\r
-\r
-/**\r
- * Utilizes the getTagRanking method to determine tag sort order of two given tags\r
- * @access private\r
- */\r
-function tagsort($a, $b)\r
-{\r
- $returnval = 0;\r
- $o = getTagRanking($a);\r
- $p = getTagRanking($b);\r
- if ($o == $p) return 0;\r
- if ($o < $p) return -1;\r
- if ($o > $p) return 1;\r
-}\r
-?>\r