+++ /dev/null
-<?php\r
-/**\r
- * Parser Data Structures\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 ParserData\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: ParserData.inc,v 1.8 2007/04/24 21:27:43 ashnazg Exp $\r
- * @link http://www.phpdoc.org\r
- * @link http://pear.php.net/PhpDocumentor\r
- * @since 1.0rc1\r
- */\r
-/**\r
- * Contains information about a PHP file, used to group procedural elements\r
- * together.\r
- * @package phpDocumentor\r
- * @subpackage ParserData\r
- * @author Greg Beaver <cellog@php.net>\r
- * @since 1.0rc1\r
- * @version $Id: ParserData.inc,v 1.8 2007/04/24 21:27:43 ashnazg Exp $\r
- */\r
-class parserPage\r
-{\r
- /**\r
- * Type is used by many functions to skip the hassle of if\r
- * <code>phpDocumentor_get_class($blah) == 'parserBlah'</code>\r
- * @var string\r
- */\r
- var $type = 'page';\r
- /**\r
- * not implemented in this version, will be used to link xml output pages\r
- * @var string\r
- */\r
- var $id = '';\r
- /**\r
- * filename.ext (no path)\r
- * @var string\r
- */\r
- var $file = '';\r
- /**\r
- * relative source location\r
- * @var string\r
- */\r
- var $sourceLocation = '';\r
- /**\r
- * phpdoc-safe name (only letters, numbers and _)\r
- * @var string\r
- */\r
- var $name = '';\r
- /**\r
- * original phpdoc-safe name (only letters, numbers and _)\r
- * \r
- * This fixes [ 1391432 ] Too many underscores in include links.\r
- * @var string\r
- */\r
- var $origName = '';\r
- /**\r
- * @var string\r
- */\r
- var $category = 'default';\r
- /**\r
- * @var string\r
- */\r
- var $package = 'default';\r
- /**\r
- * @var string\r
- */\r
- var $subpackage = '';\r
- /**\r
- * @var string\r
- */\r
- var $parserVersion = PHPDOCUMENTOR_VER;\r
- /**\r
- * not implemented yet\r
- * file modification date, will be used for makefiles\r
- * @var string\r
- */\r
- var $modDate = '';\r
- /**\r
- * @var string full path this page represents\r
- */\r
- var $path = '';\r
- /**\r
- * Tokenized source code of the file\r
- * @var array\r
- */\r
- var $source = array();\r
- /**\r
- * Used to limit output, contains contents of --packageoutput commandline.\r
- * Does not increase parsing time. Use --ignore for that\r
- * @see phpDocumentor_IntermediateParser::$packageoutput, Converter::$package_output\r
- * @var mixed either false or an array of packages\r
- */\r
- var $packageOutput = false;\r
- \r
- /**\r
- * sets package to default package\r
- * @global string default package name\r
- */\r
- function parserPage()\r
- {\r
- global $phpDocumentor_DefaultPackageName;\r
- $this->package = $GLOBALS['phpDocumentor_DefaultPackageName'];\r
- }\r
- \r
- /**\r
- * @return string always "page"\r
- */\r
- function getType()\r
- {\r
- return 'page';\r
- }\r
- \r
- /**\r
- * Sets the source code of the file for highlighting.\r
- *\r
- * PHP 4.3.0+ passes an array of tokenizer tokens by line number. PHP\r
- * 4.2.3- passes a string to be passed to {@link highlight_string()}\r
- * @param string|array\r
- */\r
- function setSource($source)\r
- {\r
- $this->source = $source;\r
- }\r
- \r
- /**\r
- * Sets the name to display in documentation (can be an alias set with @name)\r
- * @param string $file\r
- */\r
- function setFile($file)\r
- {\r
- $this->file = $file;\r
- }\r
- \r
- /**\r
- * @return string filename.ext or @name alias\r
- */\r
- function getFile()\r
- {\r
- if (!isset($this->file)) return false;\r
- return $this->file;\r
- }\r
- \r
- /**\r
- * @param string $path full path to file\r
- */\r
- function setPath($path)\r
- {\r
- // look for special windows case\r
- if(SMART_PATH_DELIMITER === '\\')\r
- $this->path = strtr($path,'/','\\');\r
- else\r
- $this->path = $path;\r
- }\r
- \r
- /**\r
- * @return string fully delimited path (OS-dependent format)\r
- */\r
- function getPath()\r
- {\r
- if (!isset($this->path)) return false;\r
- return $this->path;\r
- }\r
- \r
- /**\r
- * @param array $packages array of packages to display in documentation (package1,package2,...)\r
- * @see phpDocumentor_IntermediateParser::$packageoutput\r
- */\r
- function setPackageOutput($packages)\r
- {\r
- $this->packageOutput = $packages;\r
- }\r
- \r
- /**\r
- * @return array array of packages (package1,package2,...)\r
- * @see phpDocumentor_IntermediateParser::$packageoutput\r
- */\r
- function getPackageOutput()\r
- {\r
- return $this->packageOutput;\r
- }\r
- \r
- /**\r
- * @param string $name phpdoc-safe name (only _, numbers and letters) set by Parser::parse()\r
- * @see Parser::parse()\r
- */\r
- function setName($name)\r
- {\r
- $this->origName = $name;\r
- $this->name = $name;\r
- }\r
- \r
- /**\r
- * @return string phpdoc-safe name (only _, numbers and letters)\r
- */\r
- function getName()\r
- {\r
- if (!isset($this->name)) return false;\r
- return $this->name;\r
- }\r
- \r
- /**\r
- * @param string $source path of this file relative to program root\r
- */\r
- function setSourceLocation($source)\r
- {\r
- $this->sourceLocation = $source;\r
- }\r
- \r
- /**\r
- * @param Converter\r
- * @param boolean if this parameter is true, it will truncate the source location to the\r
- * subdirectory of pear\r
- * @return string path of this file relative to program root\r
- * @todo determine if the str_replace in the 'pear/' ELSE branch should be removed \r
- * (see Documentation/tests/bug1574043.php). It does NOT exist in the similar\r
- * function parserClass->getSourceLocation() in ParserElements.inc.\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
- else\r
- {\r
- $sl = str_replace($_phpDocumentor_options['Program_Root'] . PATH_DELIMITER,'',$sl);\r
- }\r
- }\r
- }\r
- return $sl;\r
- }\r
- /**\r
- * Not implemented in this version\r
- * @return boolean tell the parser whether to parse the file, otherwise\r
- * this function will retrieve the parsed data from external file\r
- */\r
- function getParseData()\r
- {\r
- return true;\r
- }\r
-}\r
-\r
-/**\r
- * Contains an in-memory representation of all documentable elements\r
- * ({@link parserPage}, {@link parserFunction}, {@link parserDefine},\r
- * {@link parserInclude}, {@link parserClass}, {@link parserMethod},\r
- * {@link parserVar}) and their DocBlocks ({@link parserDocBlock}).\r
- *\r
- * This class works in coordination with {@link phpDocumentor_IntermediateParser}\r
- * to take output from {@link Parser::handleEvent()} and create indexes, links,\r
- * and other assorted things (all documented in phpDocumentor_IntermediateParser\r
- * and {@link Converter})\r
- * @package phpDocumentor\r
- * @subpackage ParserData\r
- * @author Greg Beaver <cellog@php.net>\r
- * @since 1.0rc1\r
- * @version $Id: ParserData.inc,v 1.8 2007/04/24 21:27:43 ashnazg Exp $\r
- */\r
-class parserData\r
-{\r
- /**\r
- * {@link parserPage} element that is this parserData's parent, or false if\r
- * not set.\r
- * @var false|parserPage\r
- */\r
- var $parent = false;\r
- /**\r
- * array of parsed elements\r
- * @var array\r
- */\r
- var $elements = array();\r
- /**\r
- * @var boolean\r
- * @access private\r
- */\r
- var $_hasclasses = false;\r
- /**\r
- * @var boolean\r
- * @access private\r
- */\r
- var $_hasinterfaces = false;\r
- /**\r
- * array of parsed elements with @access private\r
- * @var array\r
- */\r
- var $privateelements = array();\r
- /**\r
- * array of parsed class elements\r
- * @var array\r
- */\r
- var $classelements = array();\r
- \r
- /**\r
- * @var parserTutorial|false\r
- */\r
- var $tutorial = false;\r
- /**\r
- * array of parsed class elements with @access private\r
- * @var array\r
- */\r
- var $privateclasselements = array();\r
- /**\r
- * array of links descended from {@link abstractLink}\r
- * @var array\r
- * @see pageLink, defineLink, classLink, functionLink, methodLink, varLink\r
- */\r
- var $links = array();\r
- /**\r
- * used by {@link phpDocumentor_IntermediateParser::handleDocBlock()} to\r
- * determine whether a docblock is a page-level docblock or not. $clean is\r
- * true as long as only 0 or 1 docblock has been parsed, and no element\r
- * other than parserPage has been parsed\r
- * @var boolean\r
- */\r
- var $clean = true;\r
- /**\r
- * DocBlock ({@link parserDocBlock}) for this page, or false if not set\r
- * @var mixed\r
- */\r
- var $docblock = false;\r
- /**\r
- * Flag used to determine whether a page-level docblock is present\r
- * @var boolean\r
- * @access private\r
- */\r
- var $_explicitdocblock = false;\r
- /**\r
- * Type is used by many functions to skip the hassle of if\r
- * <code>phpDocumentor_get_class($blah) == 'parserBlah'</code>\r
- * always 'page', used in element indexing and conversion functions found in\r
- * {@link Converter}\r
- * @var string\r
- */\r
- var $type = 'page';\r
- \r
- /**\r
- * @param parserElement add a parsed element to the {@link $elements} array,\r
- * also sets {@link $clean} to false\r
- */\r
- function addElement(&$element)\r
- {\r
- $element->setPath($this->parent->path);\r
- if ($element->getType() == 'class' || $element->getType() == 'method' || $element->getType() == 'var'\r
- || $element->getType() == 'const')\r
- {\r
- if ($element->getType() == 'class') {\r
- if ($element->isInterface()) {\r
- $this->_hasinterfaces = true;\r
- } else {\r
- $this->_hasclasses = true;\r
- }\r
- }\r
- $this->classelements[] = $element;\r
- } else\r
- {\r
- $this->elements[] = $element;\r
- }\r
- $this->clean = false;\r
- }\r
-\r
- /**\r
- * Does this package have interfaces?\r
- *\r
- * @return boolean\r
- */\r
- function hasInterfaces()\r
- {\r
- return $this->_hasinterfaces;\r
- }\r
-\r
- /**\r
- * Does this package have classes?\r
- *\r
- * @return boolean\r
- */\r
- function hasClasses()\r
- {\r
- return $this->_hasclasses;\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
- * If this file has a tutorial associated with it, returns a link to the\r
- * tutorial.\r
- * @return tutorialLink\r
- */\r
- function getTutorial()\r
- {\r
- return $this->tutorial;\r
- }\r
- \r
- /**\r
- * If the page-level DocBlock was present in the source, returns true\r
- * @return boolean\r
- */\r
- function hasExplicitDocBlock()\r
- {\r
- return $this->_explicitdocblock;\r
- }\r
- \r
- /**\r
- * Tells this page that its DocBlock was not implicit\r
- */\r
- function explicitDocBlock()\r
- {\r
- $this->_explicitdocblock = true;\r
- }\r
- \r
- /**\r
- * @param parserElement element to add a new link (descended from\r
- * {@link abstractLink})to the {@link $links} array\r
- * @param string classname for elements that are class-based (this may be\r
- * deprecated in the future, as the classname should be\r
- * contained within the element. if $element is a page, this\r
- * parameter is a package name\r
- * @param string subpackage name for page elements\r
- */\r
- function addLink(&$element,$classorpackage = '', $subpackage = '')\r
- {\r
- switch($element->type)\r
- {\r
- case 'function':\r
- $x = new functionLink;\r
- $x->addLink($this->parent->path, $this->parent->name, $element->name, $element->docblock->package, $element->docblock->subpackage);\r
- return $x;\r
- break;\r
- case 'define':\r
- $x = new defineLink;\r
- $x->addLink($this->parent->path, $this->parent->name, $element->name, $element->docblock->package, $element->docblock->subpackage);\r
- return $x;\r
- break;\r
- case 'global':\r
- $x = new globalLink;\r
- $x->addLink($this->parent->path, $this->parent->name, $element->name, $element->docblock->package, $element->docblock->subpackage);\r
- return $x;\r
- break;\r
- case 'class':\r
- $x = new classLink;\r
- $x->addLink($this->parent->path, $this->parent->name, $element->name, $element->docblock->package, $element->docblock->subpackage);\r
- return $x;\r
- break;\r
- case 'method':\r
- $x = new methodLink;\r
- $x->addLink($classorpackage, $this->parent->path, $this->parent->name, $element->name, $element->docblock->package, $element->docblock->subpackage);\r
- return $x;\r
- break;\r
- case 'var':\r
- $x = new varLink;\r
- $x->addLink($classorpackage, $this->parent->path, $this->parent->name, $element->name, $element->docblock->package, $element->docblock->subpackage);\r
- return $x;\r
- break;\r
- case 'page':\r
- if (empty($classorpackage)) $classorpackage = $GLOBALS['phpDocumentor_DefaultPackageName'];\r
- $x = new pageLink;\r
- $x->addLink($element->path,$element->name,$element->file,$classorpackage, $subpackage);\r
- return $x;\r
- break;\r
- }\r
- }\r
- \r
- function &getLink(&$c, $text = false)\r
- {\r
- $a = $c->getPageLink($this->parent->file, $this->docblock->package, $this->parent->path, $text);\r
- return $a;\r
- }\r
- \r
- /**\r
- * returns a list of all classes declared in a file\r
- * @param Converter &$c\r
- * @return array Format: array(packagename => parserClass,packagename => parserClass,...)\r
- */\r
- function getClasses(&$c)\r
- {\r
- $r = $c->classes->getClassesInPath($this->parent->path);\r
- $rr = array();\r
- if ($r)\r
- foreach($r as $class => $obj)\r
- {\r
- $rr[$obj->docblock->package][] = $obj;\r
- }\r
- return $rr;\r
- }\r
- \r
- /**\r
- * Get the output-safe filename (. changed to _)\r
- * @return string\r
- */\r
- function getName()\r
- {\r
- if (isset($this->parent) && $this->parent)\r
- return $this->parent->getName();\r
- }\r
- \r
- /**\r
- * @param parserPage parent element of this parsed data\r
- */\r
- function setParent(&$parent)\r
- {\r
- $this->parent = $parent;\r
- }\r
- \r
- /**\r
- * @return bool returns the value of {@link $clean}\r
- */\r
- function isClean()\r
- {\r
- return $this->clean;\r
- }\r
- \r
- /**\r
- * @param parserDocBlock\r
- * @see parserDocBlock\r
- */\r
- function setDocBlock(&$docblock)\r
- {\r
- $this->docblock = $docblock;\r
- }\r
-}\r
-\r
-/**\r
- * Base class for all elements\r
- * @package phpDocumentor\r
- * @subpackage ParserData\r
- * @abstract\r
- * @author Greg Beaver <cellog@php.net>\r
- * @since 1.0rc1\r
- * @version $Id: ParserData.inc,v 1.8 2007/04/24 21:27:43 ashnazg Exp $\r
- */\r
-class parserBase\r
-{\r
- /**\r
- * Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'\r
- * always base\r
- * @var string\r
- */\r
- var $type = 'base';\r
- /**\r
- * set to different things by its descendants\r
- * @abstract\r
- * @var mixed\r
- */\r
- var $value = false;\r
-\r
- /**\r
- * @return string returns value of {@link $type}\r
- */\r
- function getType()\r
- {\r
- return $this->type;\r
- }\r
- \r
- /**\r
- * @param mixed set the value of this element\r
- */\r
- function setValue($value)\r
- {\r
- $this->value = $value;\r
- }\r
- \r
- /**\r
- * @return mixed get the value of this element (element-dependent)\r
- */\r
- function getValue()\r
- {\r
- return $this->value;\r
- }\r
-}\r
-\r
-\r
-/**\r
- * Used to represent strings that contain inline tags, so that they can be properly parsed at link time\r
- * @package phpDocumentor\r
- * @subpackage ParserData\r
- * @author Greg Beaver <cellog@php.net>\r
- * @since 1.0rc1\r
- * @version $Id: ParserData.inc,v 1.8 2007/04/24 21:27:43 ashnazg Exp $\r
- */\r
-class parserStringWithInlineTags extends parserBase\r
-{\r
- /**\r
- * Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'\r
- * always '_string'\r
- * @var string\r
- */\r
- var $type = '_string';\r
- /** @access private */\r
- var $cache = false;\r
- /**\r
- * array of strings and {@link parserInlineTag}s\r
- * Format:\r
- * array(string1,string2,parserInlineTag1,string3,parserInlineTag2,...)\r
- * @var array\r
- */\r
- var $value = array();\r
-\r
- /**\r
- * equivalent to the . operator ($a = $b . $c)\r
- * @param mixed either a string or a {@link parserInlineTag}\r
- */\r
- function add($stringOrInlineTag)\r
- {\r
- if (is_string($stringOrInlineTag))\r
- {\r
- if (!count($this->value))\r
- {\r
- $this->value[] = $stringOrInlineTag;\r
- return;\r
- }\r
- if (is_string($this->value[count($this->value) - 1]))\r
- {\r
- $this->value[count($this->value) - 1] .= $stringOrInlineTag;\r
- return;\r
- } else\r
- {\r
- $this->value[] = $stringOrInlineTag;\r
- return;\r
- }\r
- } else\r
- {\r
- if (is_a($stringOrInlineTag,'parserinlinetag') && phpDocumentor_setup::checkIgnoreTag($stringOrInlineTag->inlinetype, true)) return;\r
- $this->value[] = $stringOrInlineTag;\r
- }\r
- }\r
- \r
- /**\r
- * Determine whether the string contains any inline tags\r
- * @tutorial inlinetags.pkg\r
- * @return boolean\r
- */\r
- function hasInlineTag()\r
- {\r
- for($i=0;$i<count($this->value);$i++)\r
- {\r
- if (is_a($this->value[$i],'parserinlinetag')) return true;\r
- }\r
- return false;\r
- }\r
- \r
- /**\r
- * Pass source code to any {@}source} tags contained within the string\r
- * for later conversion.\r
- * @param string|array source code ready to be highlighted\r
- */\r
- function setSource($source)\r
- {\r
- for($i=0;$i<count($this->value);$i++)\r
- {\r
- if (phpDocumentor_get_class($this->value[$i]) == 'parsersourceinlinetag')\r
- {\r
- $this->value[$i]->setSource($source);\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * equivalent to trim(strlen($string))\r
- * @return integer length of the string this object represents\r
- */\r
- function trimmedStrlen()\r
- {\r
- $a = 0;\r
- for($i=0;$i<count($this->value);$i++)\r
- {\r
- if (is_string($this->value[$i]))\r
- {\r
- if ($i == 0)\r
- {\r
- $a += strlen(ltrim($this->value[$i]));\r
- } elseif ($i == count($this->value[$i]) - 1)\r
- {\r
- $a += strlen(chop($this->value[$i]));\r
- }\r
- } else\r
- {\r
- $a += $this->value[$i]->Strlen();\r
- }\r
- }\r
- return $a;\r
- }\r
- \r
- /**\r
- * return the string unconverted (all inline tags are taken out - this\r
- * should only be used in pre-parsing to see if any other text\r
- * is in the string)\r
- * @uses parserInlineTag::getString() removes inline tag length, as it is\r
- * indeterminate until conversion.\r
- * @return string trimmed value\r
- */\r
- function getString($trim = true)\r
- {\r
- $a = '';\r
- for($i=0; $i<count($this->value); $i++)\r
- {\r
- if (is_string($this->value[$i]))\r
- {\r
- $a .= $this->value[$i];\r
- } else\r
- {\r
- $a .= $this->value[$i]->getString();\r
- }\r
- }\r
- if ($trim) $a = trim($a);\r
- return $a;\r
- }\r
- \r
- /**\r
- * Use to convert the string to a real string with all inline tags parsed and linked\r
- * @see Converter::returnSee()\r
- * @param Converter\r
- * @param boolean true if one needs to postprocess\r
- * @param boolean false if the output should not be trimmed\r
- */\r
- function Convert(&$converter,$postprocess = true, $trim = true)\r
- {\r
- if ($this->cache)\r
- {\r
- if ($converter->name == $this->cache['name'] && $converter->outputformat == $this->cache['output'] && $converter->checkState($this->cache['state']) && $this->cache['postprocess'] === $postprocess) return $this->cache['contents'];\r
- if ($converter->name != $this->cache['name']) {\r
- $this->cache = false;\r
- }\r
- }\r
- if (is_string($this->value)) return $this->value;\r
- $a = '';\r
- for($i=0; $i<count($this->value); $i++)\r
- {\r
- if (is_string($this->value[$i]))\r
- {\r
- if ($postprocess && !method_exists($converter,'postProcess')) var_dump('a',$converter);\r
- if ($postprocess) $a .= $converter->postProcess($this->value[$i]);\r
- else $a .= $this->value[$i];\r
- } else\r
- {\r
- $a .= $this->value[$i]->Convert($converter, $postprocess);\r
- }\r
- }\r
- if ($trim) {\r
- $a = trim($a);\r
- }\r
- $this->cache = array('name' => $converter->name,'output' => $converter->outputformat, 'contents' => $a, 'state' => $converter->getState(), 'postprocess' => $postprocess);\r
- return $a;\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file