+++ /dev/null
-<?php\r
-/**\r
- * The phpDocumentor_IntermediateParser Class\r
- *\r
- * The Intermediary Data Parser (intermediate between Parse and Converter)\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
- * @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: IntermediateParser.inc,v 1.21 2007/12/09 06:11:35 ashnazg Exp $\r
- * @filesource\r
- * @link http://www.phpdoc.org\r
- * @link http://pear.php.net/PhpDocumentor\r
- * @since 1.1\r
- */\r
-/** The phpDocumentor_IntermediateParser Class\r
- *\r
- * This class performs the work of organizing raw data from the parser in the\r
- * format of descendants of the {@link parserElement} class. This is also where\r
- * processing of package pages occurs, in\r
- * {@link phpDocumentor_IntermediateParser::handleClass()} for class-level\r
- * packages and {@link phpDocumentor_IntermediateParser::handleDocBlock()} for\r
- * page-level packages.\r
- *\r
- * Most of the work of this parser goes to matching up\r
- * DocBlocks with the elements that they are documenting. Since DocBlocks are\r
- * passed before the element they document, the last DocBlock is stored in\r
- * {@link phpDocumentor_IntermediateParser::$last} and then placed into the\r
- * $docblock parameter of the parserElement\r
- * descendant object.\r
- * @author Gregory Beaver\r
- * @version $Id: IntermediateParser.inc,v 1.21 2007/12/09 06:11:35 ashnazg Exp $\r
- * @copyright 2002 Gregory Beaver\r
- * @package phpDocumentor\r
- */\r
-class phpDocumentor_IntermediateParser\r
-{\r
- /**\r
- * @var parserDocBlock\r
- */\r
- var $last;\r
- \r
- /**\r
- * type of the last parser Element handled\r
- *\r
- * This is used in handleDocBlock to determine whether a DocBlock is a\r
- * page-level DocBlock in conjunction with the {@link parserData::$clean}\r
- * var. A page-level DocBlock is alwaysthe first DocBlock in a file, and\r
- * must be followed by another DocBlock. The first test is handled by\r
- * parserData::$clean, which is set to false on the first encounter of an\r
- * element, and the second test is handled by this variable, which must be\r
- * equal to "docblock"\r
- * @see handleDocBlock()\r
- * @var string\r
- */\r
- var $lasttype = '';\r
- \r
- /**\r
- * Name of the class currently being parsed.\r
- * It is only used (and only valid) when phpDocumentor_IntermediateParser is\r
- * parsing a class\r
- * @var string\r
- */\r
- var $cur_class = '';\r
- \r
- /**\r
- * type of the current parser Element being handled\r
- * \r
- * This is used by {@link HandleEvent()} to set the {@link $lasttype} var,\r
- * which is used to detect page-level DocBlocks\r
- * @var string\r
- */\r
- var $type = '';\r
- \r
- /**\r
- * set in {@link Setup.inc.php} to the value of the parseprivate commandline\r
- * option. If this option is true, elements with an @access private tag\r
- * will be parsed and displayed\r
- * @tutorial phpDocumentor.howto.pkg#using.command-line.parseprivate\r
- * @var boolean\r
- */\r
- var $parsePrivate = false;\r
- \r
- /**\r
- * this variable is used to prevent parsing of elements with an @ignore tag\r
- * @see $packageoutput\r
- * @see $parsePrivate\r
- */\r
- var $private_class = false;\r
- \r
- /**\r
- * used to set the output directory\r
- * @see setTargetDir()\r
- */\r
- var $targetDir;\r
- \r
- /**\r
- * used to set the template base directory\r
- * @see setTemplateBase()\r
- */\r
- var $templateBase;\r
- \r
- /**\r
- * array of parsed package pages\r
- *\r
- * used by {@link Convert()} to convert all package pages into output\r
- * @var array\r
- */\r
- var $package_pages = array();\r
- \r
- /**\r
- * @var array array of all {@link parserData} containing page information\r
- */\r
- var $pages = array();\r
- /**\r
- * Put away a page that has been @ignored or @access private if\r
- * !{@link $parsePrivate}\r
- *\r
- * When a page has @access private in its DocBlock, it is placed here\r
- * instead of in {@link $pages}, to allow for proper Class parsing. Since\r
- * classes and pages are parsed as if they were separate, this array allows\r
- * public classes on private pages to retrieve information needed about the\r
- * page that holds the class and to {@link addPageIfNecessary()} to the\r
- * $pages array\r
- * @var array\r
- */\r
- var $privatepages = array();\r
- /**\r
- * Keeps track of packages of classes that have parent classes in another\r
- * package. Used in automatic linking.\r
- *\r
- * This array is updated by {@link addPackageParent()}, which is called in\r
- * {@link Classes::processChild()} to keep track of classes that descend\r
- * from classes in different packages. In other words, if class foo is in\r
- * package one, and class bar is in package two, an entry\r
- * $package_parents['two'] = 'one' will be made.\r
- * @var array Format: packagename => parentpackagename\r
- * @see Converter::getLink()\r
- */\r
- var $package_parents = array();\r
- \r
- /**\r
- * Used to determine the category for tutorials.\r
- *\r
- * <b>WARNING:</b> If more than one category exists, the last category\r
- * encountered will overwrite the previous and will raise a big warning\r
- * @var array Format: packagename => categoryname\r
- */\r
- var $packagecategories = array();\r
- \r
- /**\r
- * list of all packages encountered while documenting. Used in automatic\r
- * linking.\r
- * \r
- * Converter::getLink() first checks if an ambiguous link is found in the\r
- * current package. If not, it then checks in parent packages, and if still\r
- * not found, uses this array to check in the rest of the packages before\r
- * giving up\r
- * @var array Format: array(packagename => 1, packagename => 1,...)\r
- * @see Converter::getLink()\r
- */\r
- var $all_packages = array();\r
- \r
- /**\r
- * array of packages to parser and output documentation for, if not all\r
- * packages should be documented\r
- *\r
- * Format:<br />\r
- * array(package1,package2,...)<br />\r
- * or false if not set\r
- *\r
- * Use this option to limit output similar to ignoring files. If you have\r
- * some temporary files that you don't want to specify by name but don't\r
- * want included in output, set a package name for all the elements in your\r
- * project, and set packageoutput to that name. the default package will be\r
- * ignored. Parsing speed does not improve. If you want to ignore files\r
- * for speed reasons, use the ignore command-line option\r
- * @tutorial phpDocumentor.howto.pkg#using.command-line.packageoutput\r
- * @see Io\r
- * @var false|array\r
- */\r
- var $packageoutput = false;\r
- \r
- /**\r
- * the functions which handle output from the {@link Parser}\r
- * @see handleEvent(), handleDocBlock(), handlePage(), handleClass()\r
- * @see handleDefine(), handleFunction(), handleMethod(), handleVar()\r
- * @see handlePackagePage(), handleInclude(), handleTutorial()\r
- */\r
- var $event_handlers = array(\r
- 'docblock' => 'handleDocBlock',\r
- 'page' => 'handlePage',\r
- 'class' => 'handleClass',\r
- 'define' => 'handleDefine',\r
- 'function' => 'handleFunction',\r
- 'method' => 'handleMethod',\r
- 'var' => 'handleVar',\r
- 'const' => 'handleConst',\r
- 'packagepage' => 'handlePackagePage',\r
- 'include' => 'handleInclude',\r
- 'global' => 'handleGlobal',\r
- 'tutorial' => 'handleTutorial',\r
- );\r
- \r
- /**\r
- * $data contains parsed structures for the current page being parsed\r
- *\r
- * In version 1.1+, $data is only used to store the current page information.\r
- * All handling of documented elements is handled by the\r
- * {@link ProceduralPages} and {@link Classes} classes.\r
- * @var parserData\r
- */\r
- var $data;\r
- \r
- /**\r
- * set in {@link Setup.inc.php} to the value of the quitemode commandline\r
- * option.\r
- *\r
- * If this option is true, informative output while parsing will not be\r
- * displayed (documentation is unaffected)\r
- * @var boolean\r
- * @tutorial phpDocumentor.howto.pkg#using.command-line.quiet\r
- */\r
- var $quietMode = false;\r
-\r
- /**\r
- * set in {@link Setup.inc.php} to the value of the undocumentedElementWarnings commandline\r
- * option.\r
- *\r
- * If this option is true, warnings about certain elements (classes, methods) \r
- * that are not documented with DocBlocks will be shown while parsing,\r
- * and will also be displayed in the errors.html page \r
- * (other documentation is unaffected)\r
- * @var boolean\r
- * @tutorial phpDocumentor.howto.pkg#using.command-line.undocumentedelements\r
- */\r
- var $undocumentedElementWarnings = false;\r
- \r
- /**\r
- * used to keep track of inheritance at the smartest level possible for a\r
- * dumb computer\r
- * @var Classes\r
- */\r
- var $classes = false;\r
- \r
- /**\r
- * used to keep track of all elements in a procedural page. Handles name\r
- * conflicts with elegance\r
- * @since 1.1\r
- * @var ProceduralPages\r
- */\r
- var $proceduralpages = false;\r
- \r
- /**\r
- * an array of template names indexed by converter name\r
- *\r
- * For example, if the default HTMLframesConverter is using the DOM/l0l33t\r
- * template, the array will be\r
- * <code>$converters['frames'] = 'DOM/l0l33t'</code>\r
- * @var array Format: array(Convertername1 => templatename)\r
- * @see Converter\r
- */\r
- var $converters = false;\r
- /** \r
- * @var string Title of generated documentation, passed to Converters\r
- */\r
- var $title = '';\r
- \r
- var $uses = array();\r
-\r
- var $db_template;\r
- \r
- /**\r
- * Stores parsed CHANGELOG/INSTALL/README files\r
- * @var array Format: array(CHANGELOG => contents,\r
- * INSTALL => contents,\r
- * README => contents)\r
- */\r
- var $ric = array();\r
- \r
- /**\r
- * Flag used to determine whether the last docblock\r
- * was a page-level docblock.\r
- * @var boolean\r
- * @access private\r
- */\r
- var $_lastDocBlockWasPageLevel = false;\r
- \r
- /**\r
- * Flag used to determine whether the Page-level\r
- * DocBlock was declared in old or new style\r
- * @var boolean\r
- * @access private\r
- */\r
- var $_oldPageLevel = false;\r
-\r
- /**\r
- * sets up basic data structures\r
- * @param string Title of generated documentation, passed to Converters\r
- * @see $title, $data, $classes, $proceduralpages\r
- */\r
- function phpDocumentor_IntermediateParser($title='Generated Documentation')\r
- {\r
- $this->title = $title;\r
- $this->data = new parserData;\r
- $this->classes = new Classes;\r
- $this->proceduralpages = new ProceduralPages;\r
- }\r
- \r
- /**\r
- * Retrieve the relative path. If the path contains "pear/" it will\r
- * be used as the base, otherwise the Program_Root string will be used.\r
- * @global array uses 'Program_Root' option to replace it with '' for\r
- * retrieving the source location of a file\r
- * @param string path to file\r
- * @return string\r
- * @see $sourceLocation\r
- * @access private\r
- */\r
- function _getSourceLocation($sl, $sourceloc)\r
- {\r
- global $_phpDocumentor_options;\r
- if (empty($sl)) return false;\r
- $sl = str_replace('\\','/',$sl);\r
- if (strpos($sl,'pear/'))\r
- {\r
- $sl = substr($sl,strpos($sl,'pear/') + 5);\r
- if (dirname($sl) == '.')\r
- {\r
- return 'PEAR';\r
- }\r
- return dirname($sl);\r
- } else\r
- {\r
- if (strpos(str_replace($_phpDocumentor_options['Program_Root'] . PATH_DELIMITER,'',$sourceloc),PATH_DELIMITER) === false)\r
- return '';\r
- return dirname(str_replace($_phpDocumentor_options['Program_Root'] . PATH_DELIMITER,'',$sourceloc));\r
- }\r
- }\r
- \r
- /**\r
- * Guess the package/subpackage based on subdirectory if the --pear option\r
- *\r
- * A file in pear/dir/file.php will be in package "dir." A file in\r
- * pear/dir/subdir/file.php will be in package "dir," subpackage "subdir."\r
- * @param string full path of file\r
- * @param template-ready source location Program_Root/dir/file.php\r
- * @global array uses the 'pear' option to determine whether to guess based\r
- * on subdirectory\r
- * @tutorial phpDocumentor.howto.pkg#using.command-line.pear\r
- */\r
- function _guessPackage($path, $sourceloc)\r
- {\r
- global $_phpDocumentor_setting;\r
- if ($_phpDocumentor_setting['pear'])\r
- {\r
- $subpath = explode(PATH_DELIMITER, $this->_getSourceLocation($path, $sourceloc));\r
- if (!empty($subpath[0]))\r
- { // can only have package and subpackage in this version\r
- $package = $subpath[0];\r
- $subpackage = '';\r
- if (isset($subpath[1])) $subpackage = $subpath[1];\r
- return array($package,$subpackage);\r
- } else return array($this->package, $this->subpackage);\r
- } else return array($this->package, $this->subpackage);\r
- }\r
- \r
- /**\r
- * handles post-parsing of include/require/include_once/require_once\r
- *\r
- * This function sets {@link $data}->clean to false to tell the\r
- * phpDocumentor_IntermediateParser that a page-level DocBlock can't be\r
- * found after this point on this page. It then sets the package\r
- * to be the same as the page, and adds itself to the\r
- * {@link ProceduralPages} class\r
- * @param integer $event Event number from {@link Parser.inc}\r
- * @param parserInclude $data\r
- */\r
- function handleInclude($event,$data)\r
- {\r
- if ($this->_lastDocBlockWasPageLevel)\r
- {\r
- addWarning(PDERROR_DOCBLOCK_CONFLICT, $data->getName(), $data->getValue());\r
- if (!$this->_oldPageLevel)\r
- {\r
- unset($this->last);\r
- }\r
- }\r
- $this->_lastDocBlockWasPageLevel = false;\r
- $this->data->clean = false;\r
- // page was @ignored\r
- if ($this->private_page)\r
- {\r
- unset($this->last);\r
- return;\r
- }\r
- if (empty($this->last))\r
- {\r
- if (isset($this->db_template))\r
- {\r
- // use the docblock template\r
- $this->last = phpDocumentor_clone($this->db_template);\r
- }\r
- else\r
- {\r
- // we don't have a docblock, create an empty one to get rid of errors\r
- $this->last = new parserDocblock();\r
- }\r
- }\r
-// $this->last->setLineNumber($data->getLineNumber());\r
- if ($this->last->getKeyword('ignore'))\r
- {\r
- $this->last = false;\r
- return;\r
-// addWarning(PDERROR_IGNORE_TAG_IGNORED,'include',$data->getName().'('.$data->getValue().')');\r
- }\r
-\r
- $this->last->overridePackage($this->category,$this->package,$this->subpackage,$data->getName(),'include');\r
- $data->setDocBlock($this->last);\r
- $this->proceduralpages->addInclude($data);\r
- $this->last = false;\r
- }\r
- \r
- /**\r
- * handles post-parsing of global variables\r
- *\r
- * This function sets {@link $data}->clean to false to tell the\r
- * phpDocumentor_IntermediateParser that a page-level DocBlock can't be\r
- * found after this point on this page. It then sets the package\r
- * to be the same as the page, and adds itself to the\r
- * {@link ProceduralPages} class\r
- * @param integer $event Event number from {@link Parser.inc}\r
- * @param parserGlobal $data\r
- */\r
- function handleGlobal($event,$data)\r
- {\r
- if ($this->_lastDocBlockWasPageLevel)\r
- {\r
- addWarning(PDERROR_DOCBLOCK_CONFLICT, 'global variable', $data->getName());\r
- if (!$this->_oldPageLevel)\r
- {\r
- unset($this->last);\r
- }\r
- }\r
- $this->_lastDocBlockWasPageLevel = false;\r
- $this->data->clean = false;\r
- if ($this->private_page)\r
- {\r
- unset($this->last);\r
- return;\r
- }\r
- if (empty($this->last))\r
- {\r
- if (isset($this->db_template))\r
- {\r
- // use the docblock template\r
- $this->last = phpDocumentor_clone($this->db_template);\r
- }\r
- else\r
- {\r
- // we don't have a docblock, create an empty one to get rid of errors\r
- $this->last = new parserDocblock();\r
- }\r
- }\r
-// $this->last->setLineNumber($data->getLineNumber());\r
- if ($this->last->getKeyword('ignore'))\r
- {\r
- addWarning(PDERROR_IGNORE_TAG_IGNORED,'global variable - just don\'t document the',$data->getName());\r
- $this->last = false;\r
- return;\r
- }\r
- $this->last->overridePackage($this->category,$this->package,$this->subpackage,$data->getName(),'global');\r
- $data->setDocBlock($this->last);\r
- if ($data->docblock->getKeyword('name'))\r
- {\r
- $a = $data->docblock->getKeyword('name');\r
- if (is_object($a)) $a = $a->value;\r
- $data->setName($a);\r
- }\r
- $this->proceduralpages->addGlobal($data);\r
- $this->last = false;\r
- }\r
- \r
- /**\r
- * handles post-parsing of Package-level documentation pages.\r
- *\r
- * sets the {@link $package_pages}[$data->package] to $data\r
- * @param integer $event Event number from {@link Parser.inc}\r
- * @param parserPackagePage $data\r
- */\r
- function handlePackagePage($event,$data)\r
- {\r
- $this->package_pages[$data->package] = &$data;\r
- $this->last = false;\r
- }\r
- \r
- /**\r
- * handle post-parsing of Tutorials.\r
- *\r
- * This adds the parsed tutorial to the tutorial tree\r
- * @uses $tutorials sets the value of tutorials to parameter $data\r
- * @param integer $event Event Number\r
- * @param parserTutorial $data\r
- * @since 1.2\r
- */\r
- function handleTutorial($event,$data)\r
- {\r
- if (isset($this->packagecategories[$data->package]))\r
- {\r
- $data->category = $this->packagecategories[$data->package];\r
- } else\r
- {\r
- $data->category = $GLOBALS['phpDocumentor_DefaultCategoryName'];\r
- }\r
- $this->tutorials[$data->package][$data->subpackage][$data->tutorial_type][$data->name] = $data;\r
- }\r
- \r
- /**\r
- * handles post-parsing of class vars\r
- *\r
- * This function sets up a @var tag if none is found, and aligns $data's\r
- * $path var and packages to match the parent object\r
- * @param integer $event Event number from {@link Parser.inc}\r
- * @param parserVar $data\r
- */\r
- function handleVar($event,$data)\r
- {\r
- global $_phpDocumentor_setting;\r
- if ($this->private_class)\r
- {\r
- unset($this->last);\r
- return;\r
- }\r
- if (empty($this->last))\r
- {\r
- if (isset($this->db_template))\r
- {\r
- // use the docblock template\r
- $this->last = phpDocumentor_clone($this->db_template);\r
- } \r
- else \r
- {\r
- // we don't have a docblock, create an empty one to get rid of errors\r
- $this->last = new parserDocblock();\r
- }\r
- }\r
-// $this->last->setLineNumber($data->getLineNumber());\r
- $this->last->overridePackage($this->category,$this->package,$this->subpackage,$data->getName(),'var');\r
- $this->last->updateModifiers($data->getModifiers());\r
-\r
- if ($this->last->getKeyword('ignore'))\r
- {\r
- $this->last = false;\r
- return;\r
-// addWarning(PDERROR_IGNORE_TAG_IGNORED,'var',$this->cur_class.'::'.$data->getName());\r
- }\r
- if (!$this->last->var)\r
- {\r
- $this->last->addVar('mixed',new parserStringWithInlineTags);\r
- }\r
- \r
- if ($_phpDocumentor_setting['pear'])\r
- {\r
- if (strpos($data->getName(), '_') == 1 && !$this->last->getKeyword('access'))\r
- {\r
- addWarning(PDERROR_PRIVATE_ASSUMED,'class variable',$data->class.'::'.$data->getName());\r
- $this->last->addKeyword('access','private');\r
- $data->setDocBlock($this->last);\r
- }\r
- }\r
- $data->setDocBlock($this->last);\r
- $data->path = $this->data->parent->path;\r
- $this->classes->addVar($data);\r
- $this->last = false;\r
- }\r
- \r
- /**\r
- * handles post-parsing of class constants\r
- *\r
- * This function aligns $data's\r
- * $path var and packages to match the parent object\r
- * @param integer $event Event number from {@link Parser.inc}\r
- * @param parserVar $data\r
- */\r
- function handleConst($event,$data)\r
- {\r
- global $_phpDocumentor_setting;\r
- if ($this->private_class)\r
- {\r
- unset($this->last);\r
- return;\r
- }\r
- if (empty($this->last))\r
- {\r
- if (isset($this->db_template))\r
- {\r
- // use the docblock template\r
- $this->last = phpDocumentor_clone($this->db_template);\r
- }\r
- else\r
- {\r
- // we don't have a docblock, create an empty one to get rid of errors\r
- $this->last = new parserDocblock();\r
- }\r
- }\r
-// $this->last->setLineNumber($data->getLineNumber());\r
- $this->last->overridePackage($this->category,$this->package,$this->subpackage,$data->getName(),'const');\r
-\r
- if ($this->last->getKeyword('ignore'))\r
- {\r
- $this->last = false;\r
- return;\r
-// addWarning(PDERROR_IGNORE_TAG_IGNORED,'var',$this->cur_class.'::'.$data->getName());\r
- }\r
- $data->setDocBlock($this->last);\r
- $data->path = $this->data->parent->path;\r
- $this->classes->addConst($data);\r
- $this->last = false;\r
- }\r
- \r
- /**\r
- * handles post-parsing of class methods\r
- *\r
- * This function first aligns $data's path and package to match the parent\r
- * object, and also aligns the docblock's @param, @global, and @staticvar\r
- * tags with the information parsed from the method source code. It also\r
- * checks to see if the method is a constructor and sets the $isConstructor\r
- * flag. If source code has been parsed by a {@}source} tag, the source is\r
- * added to its docblock\r
- *\r
- * Finally, it adds the method to the {@link Classes} class.\r
- * @param integer $event Event number from {@link Parser.inc}\r
- * @param parserMethod $data\r
- */\r
- function handleMethod($event,$data)\r
- {\r
- global $_phpDocumentor_setting;\r
- if ($this->private_class)\r
- {\r
- unset($this->last);\r
- return;\r
- }\r
-\r
- if (empty($this->last))\r
- {\r
- if ($this->undocumentedElementWarnings)\r
- {\r
- addWarning(PDERROR_UNDOCUMENTED_ELEMENT,'Method',$data->getName(),'method');\r
- } \r
- if (isset($this->db_template))\r
- {\r
- // use the docblock template\r
- $this->last = phpDocumentor_clone($this->db_template);\r
- }\r
- else\r
- {\r
- // we don't have a docblock, create an empty one to get rid of errors\r
- $this->last = new parserDocblock();\r
- }\r
- }\r
-// $this->last->setLineNumber($data->getLineNumber());\r
- if ($this->last->getKeyword('ignore'))\r
- {\r
- $this->last = false;\r
- return;\r
-// addWarning(PDERROR_IGNORE_TAG_IGNORED,'method',$this->cur_class.'::'.$data->getName());\r
- }\r
- $this->last->overridePackage($this->category,$this->package,$this->subpackage,$data->getName(),'method');\r
- if ($data->hasSource())\r
- {\r
- $this->last->setSource($data->getSource(), $data->getClass());\r
- }\r
- foreach($data->listParams() as $key => $param)\r
- {\r
- $update_params[$key] = $param;\r
- }\r
- foreach($data->listGlobals() as $param)\r
- {\r
- $update_globals[] = $param[1];\r
- }\r
- foreach($data->listStatics() as $param)\r
- {\r
- $update_statics[] = $param[0];\r
- }\r
- if (isset($update_params))\r
- $this->last->updateParams($update_params);\r
- if (isset($update_globals))\r
- $this->last->updateGlobals($update_globals);\r
- if (isset($update_statics))\r
- $this->last->updateStatics($update_statics);\r
- $this->last->updateModifiers($data->getModifiers());\r
- unset($update_params);\r
- unset($update_globals);\r
- unset($update_statics);\r
-\r
- if ($data->getName() == $this->cur_class) $data->setConstructor();\r
- if ($data->getName() == '__construct') {\r
- $data->setConstructor();\r
- }\r
- if ($data->getName() == '__destruct') {\r
- $data->setDestructor();\r
- }\r
-\r
- if ($_phpDocumentor_setting['pear'])\r
- {\r
- if (strpos($data->getName(), '_') === 0 && substr($data->getName(), 1) == $data->class)\r
- { // is destructor\r
- $data->setDestructor();\r
- } elseif (strpos($data->getName(), '_') === 0 && !$this->last->getKeyword('access'))\r
- {\r
- if (strpos($data->getName(), '__') !== 0) {\r
- addWarning(PDERROR_PRIVATE_ASSUMED,'method',$data->class.'::'.$data->getName().'()');\r
- $this->last->addKeyword('access','private');\r
- $data->setDocBlock($this->last);\r
- }\r
- }\r
- }\r
- $data->setDocBlock($this->last);\r
- $data->path = $this->data->parent->path;\r
- $this->classes->addMethod($data);\r
- $this->last = false;\r
- }\r
-\r
- /**\r
- * handles post-parsing of functions\r
- *\r
- * This function sets {@link $data}->clean to false to tell the\r
- * phpDocumentor_IntermediateParser that a page-level DocBlock can't be\r
- * found after this point on this page. It then sets the package to be the\r
- * same as the page, aligns the docblock's @param, @global, and @staticvar\r
- * tags with the information parsed from the function source code.\r
- *\r
- * If source code has been parsed by a {@}source} tag, the source is added\r
- * to its docblock, and then the parserFunction adds itself to the\r
- * {@link ProceduralPages} class\r
- * @param integer $event Event number from {@link Parser.inc}\r
- * @param parserFunction $data\r
- */\r
- function handleFunction($event,$data)\r
- {\r
- if ($this->_lastDocBlockWasPageLevel)\r
- {\r
- addWarning(PDERROR_DOCBLOCK_CONFLICT, 'function', $data->getName());\r
- if (!$this->_oldPageLevel)\r
- {\r
- unset($this->last);\r
- }\r
- }\r
- $this->_lastDocBlockWasPageLevel = false;\r
- $this->data->clean = false;\r
- if ($this->private_page)\r
- {\r
- unset($this->last);\r
- return;\r
- }\r
-\r
- if (empty($this->last))\r
- {\r
- if (isset($this->db_template))\r
- {\r
- // use the docblock template\r
- $this->last = phpDocumentor_clone($this->db_template);\r
- }\r
- else\r
- {\r
- // we don't have a docblock, create an empty one to get rid of errors\r
- $this->last = new parserDocblock();\r
- }\r
- }\r
-// $this->last->setLineNumber($data->getLineNumber());\r
- if ($this->last->getKeyword('ignore'))\r
- {\r
- unset($this->last);\r
- return;\r
- }\r
- $this->last->overridePackage($this->category,$this->package,$this->subpackage,$data->getName(),'function');\r
-\r
- foreach($data->listParams() as $key => $param)\r
- {\r
- $update_params[$key] = $param;\r
- }\r
- foreach($data->listGlobals() as $param)\r
- {\r
- $update_globals[] = $param[1];\r
- }\r
- foreach($data->listStatics() as $param)\r
- {\r
- $update_statics[] = $param[0];\r
- }\r
- if (isset($update_params))\r
- $this->last->updateParams($update_params);\r
- if (isset($update_globals))\r
- $this->last->updateGlobals($update_globals);\r
- if (isset($update_statics))\r
- $this->last->updateStatics($update_statics);\r
- unset($update_params);\r
- unset($update_globals);\r
- unset($update_statics);\r
-\r
- if ($data->hasSource())\r
- {\r
- $this->last->setSource($data->getSource());\r
- }\r
- if (count($this->last->params) == 1 && !count($data->listParams()))\r
- {\r
- // if the function has no parameters, and 1 @param, add it to the list as optional, default value is description from @param\r
- $pars = $this->last->listParams();\r
- $data->addParam($pars[0]['var'],$pars[0]['data']->getString());\r
- }\r
- $data->setDocBlock($this->last);\r
- $this->proceduralpages->addFunction($data);\r
- $this->last = false;\r
- }\r
- \r
- /**\r
- * handles post-parsing of defines\r
- *\r
- * This function sets {@link $data}->clean to false to tell the\r
- * phpDocumentor_IntermediateParser that a page-level DocBlock can't be\r
- * found after this point on this page. It then sets the package to be the\r
- * same as the page and adds itself to the {@link ProceduralPages} class\r
- * @param integer $event Event number from {@link Parser.inc}\r
- * @param parserDefine $data\r
- */\r
- function handleDefine($event,$data)\r
- {\r
- if ($this->_lastDocBlockWasPageLevel)\r
- {\r
- addWarning(PDERROR_DOCBLOCK_CONFLICT, 'define', $data->getName());\r
- if (!$this->_oldPageLevel)\r
- {\r
- unset($this->last);\r
- }\r
- }\r
- $this->_lastDocBlockWasPageLevel = false;\r
- $this->data->clean = false;\r
- if ($this->private_page)\r
- {\r
- unset($this->last);\r
- return;\r
- }\r
- if (empty($this->last))\r
- {\r
- if (isset($this->db_template))\r
- {\r
- // use the docblock template\r
- $this->last = phpDocumentor_clone($this->db_template);\r
- }\r
- else\r
- {\r
- // we don't have a docblock, create an empty one to get rid of errors\r
- $this->last = new parserDocblock();\r
- }\r
- }\r
-// $this->last->setLineNumber($data->getLineNumber());\r
- if ($this->last->getKeyword('ignore'))\r
- {\r
- unset($this->last);\r
- return;\r
- }\r
-\r
- $this->last->overridePackage($this->category,$this->package,$this->subpackage,$data->getName(),'define');\r
- $data->setDocBlock($this->last);\r
- $this->proceduralpages->addDefine($data);\r
- $this->last = false;\r
- }\r
- \r
- /**\r
- * handles post-parsing of classes\r
- *\r
- * This function sets {@link $data}->clean to false to tell the\r
- * phpDocumentor_IntermediateParser that a page-level DocBlock can't be\r
- * found after this point on this page. It sets {@link $cur_class} to its\r
- * name, and if an @ignore tag is found in the DocBlock, it sets\r
- * {@link $private_class} to true, to prevent post-parsing of any of the\r
- * class's vars or methods. Then it checks for the existence of a package\r
- * page for the class's package\r
- * @param integer $event Event number from {@link Parser.inc}\r
- * @param parserClass $data\r
- */\r
- function handleClass($event,$data)\r
- {\r
- global $_phpDocumentor_setting;\r
- if ($data->isInterface()) \r
- {\r
- $objectType = 'interface';\r
- }\r
- else\r
- {\r
- $objectType = 'class';\r
- }\r
- if ($this->_lastDocBlockWasPageLevel)\r
- {\r
- if (!$this->_oldPageLevel)\r
- {\r
- addWarning(PDERROR_DOCBLOCK_GOES_CLASS, $data->getName());\r
- $doc = new parserDocBlock;\r
- $doc->category = $this->category;\r
- $doc->package = $this->package;\r
- $doc->subpackage = $this->subpackage;\r
- if ($_phpDocumentor_setting['sourcecode']) {\r
- $doc->canSource();\r
- $doc->addFileSource($this->data->parent->path, $this->data->parent->source);\r
- }\r
- $this->data->setDocBlock($doc);\r
- unset($doc);\r
- if ($this->last) {\r
- $this->last->cantSource();\r
- }\r
- }\r
- }\r
- $this->_lastDocBlockWasPageLevel = false;\r
- $this->data->clean = false;\r
- if (empty($this->last))\r
- {\r
- if ($this->undocumentedElementWarnings)\r
- {\r
- addWarning(PDERROR_UNDOCUMENTED_ELEMENT,'Class',$data->getName(),'Class');\r
- }\r
- if (isset($this->db_template))\r
- {\r
- // use the docblock template\r
- $this->last = phpDocumentor_clone($this->db_template);\r
- }\r
- else\r
- {\r
- // we don't have a docblock, create an empty one to get rid of errors\r
- $this->last = new parserDocblock();\r
- }\r
- list($this->last->package, $this->last->subpackage) = $this->_guessPackage($this->data->parent->path, $this->data->parent->getSourceLocation('dummy'));\r
- addWarning(PDERROR_NO_PACKAGE_TAG,$objectType,$data->getName(),$this->last->package);\r
- } else\r
- {\r
- if (!$this->last->getExplicitPackage())\r
- {\r
- list($this->last->package, $this->last->subpackage) = $this->_guessPackage($this->data->parent->path, $this->data->parent->getSourceLocation('dummy'));\r
- addWarning(PDERROR_NO_PACKAGE_TAG,$objectType,$data->getName(),$this->last->package);\r
- } else\r
- {\r
- if (isset($this->packagecategories[$this->package])\r
- && $this->packagecategories[$this->package] != $this->category)\r
- addWarning(PDERROR_PACKAGECAT_SET,$this->package,\r
- $this->packagecategories[$this->package],\r
- $this->category);\r
- $this->packagecategories[$this->package] = $this->category;\r
- }\r
- }\r
- $this->last->updateModifiers($data->getModifiers());\r
-// $this->last->setLineNumber($data->getLineNumber());\r
- $data->setDocBlock($this->last);\r
- $this->cur_class = $name = $data->getName();\r
- if ($this->last->getKeyword('ignore'))\r
- {\r
- $this->private_class = true;\r
- unset($this->last);\r
- return;\r
- }\r
- $data->path = $this->data->parent->path;\r
- $this->classes->addClass($data);\r
- $this->private_class = false;\r
- if ($this->last->package)\r
- {\r
- $this->parsePackagePage($this->last->package, $this->data->parent->getPath());\r
- }\r
- $this->last = false;\r
- }\r
- \r
- /**\r
- * handles post-parsing of procedural pages\r
- *\r
- * this event is called at the start of a new page, before the Parser knows\r
- * whether the page will contain any procedural pages or not\r
- * @param integer $event Event number from {@link Parser.inc}\r
- * @param parserPage $data\r
- */\r
- function handlePage($event,$data)\r
- {\r
- $type = 'page';\r
- $this->private_page = false;\r
- $this->data = new parserData;\r
- $data->category = $this->category = $GLOBALS['phpDocumentor_DefaultCategoryName'];\r
- $this->package = $GLOBALS['phpDocumentor_DefaultPackageName'];\r
- $this->subpackage = '';\r
- $this->proceduralpages->addPage($data);\r
- $this->data->setParent($data);\r
- $this->pages[$data->getPath()] = $this->data;\r
- $this->classes->nextFile($data->getPath());\r
- $this->packageoutput = $data->getPackageOutput();\r
- }\r
- \r
- /**\r
- * handles post-parsing of DocBlocks\r
- *\r
- * This function sets {@link $last} to the DocBlock represented by $data, to\r
- * allow the next documentable element passed to\r
- * phpDocumentor_IntermediateParser to link the DocBlock into its $docblock\r
- * property. This function also checks for two special cases of DocBlocks:\r
- * <ol>\r
- * <li>First DocBlock in the file contains a @package tag</li>\r
- * <li>First DocBlock in the file is immediately followed by another\r
- * DocBlock</li>\r
- * </ol>\r
- * In both cases, the function extracts this tag and uses it as the\r
- * page-level package. If the @package tag is in the DocBlock of an\r
- * element (function, global variable, whatever) that isn't a page-level\r
- * DocBlock, a warning will be raised to notify the author that a @package\r
- * tag belongs in a page-level DocBlock.\r
- *\r
- * <b>New</b> in version 1.2.2, if the first DocBlock in a file contains\r
- * a @package tag, it is a page-level DocBlock.\r
- *\r
- * If the DocBlock is page-level, it is processed with\r
- * {@link _processPageLevelDocBlock}\r
- *\r
- * Finally, the function replaces the old parserPage in\r
- * {@link parserData::$data}->parent with the new one containing information\r
- * from the DocBlock by calling {@link addPage()}, and checks for\r
- * package-level docs.\r
- * @param integer $event Event number from {@link Parser.inc}\r
- * @param parserDocBlock $data\r
- */\r
- function handleDocBlock($event,$data)\r
- {\r
- $type = 'docblock';\r
- $data->postProcess();\r
- // Zend desc support\r
- if ($tdesc = $data->getKeyword('desc'))\r
- {\r
- $data->setShortDesc($tdesc);\r
- unset($data->tags['desc']);\r
- }\r
- $this->_lastDocBlockWasPageLevel = false;\r
- // 1st docblock in file, check for @package\r
- if ($this->data->isClean() && !isset($this->last))\r
- {\r
- if ($data->getExplicitPackage())\r
- {\r
- // new with 1.2.2:\r
- // if the first docblock in a file\r
- // contains a @package tag, then it is\r
- // a page-level docblock\r
- $this->_processPageLevelDocBlock($data);\r
- $this->_lastDocBlockWasPageLevel = true;\r
- $this->all_packages[$data->package] = 1;\r
- $this->last = $data;\r
- return;\r
- }\r
- $doc = new parserDocBlock;\r
- $doc->category = $this->category;\r
- $doc->package = $this->package;\r
- $doc->subpackage = $this->subpackage;\r
- $this->data->setDocBlock($doc);\r
- $this->proceduralpages->addPagePackage($this->data->parent->getPath(),$this->package,$this->subpackage);\r
- unset($doc);\r
- }\r
- // 2nd docblock in a row, and it's at the top of the file, page-level docblock\r
- if ($this->lasttype == "docblock" && $this->data->isClean())\r
- {\r
- $this->_processPageLevelDocBlock($this->last);\r
- $this->_oldPageLevel = true;\r
- $this->_lastDocBlockWasPageLevel = false;\r
- }\r
- $this->all_packages[$data->package] = 1;\r
- $this->last = $data;\r
- }\r
- \r
- /**\r
- * Process a Page-level DocBlock\r
- *\r
- * First, it checks for an @ignore tag,\r
- * and if found, calls {@link ProceduralPages::ignorePage()}. An @ignore\r
- * tag in a page-level DocBlock will ignore all functions, defines, global\r
- * variables, and includes. It will not ignore classes! The function next\r
- * checks for an @access private, and if --parseprivate is off, performs the\r
- * same actions as @ignore.\r
- * Next, it checks for the @name tag, which is used to rename the page.\r
- * This is also a PEAR compatibility issue, and may not be very useful in\r
- * the long run. Documentation is best when it refers to real entities in\r
- * the package, and not to aliases.\r
- * @access private\r
- */\r
- function _processPageLevelDocBlock($data)\r
- {\r
- global $_phpDocumentor_setting;\r
- // can only have 1 package-level docblock, others are ignored\r
- if (!$this->data->isClean())\r
- {\r
- return;\r
- }\r
- $this->data->clean = false;\r
- $this->data->explicitDocBlock();\r
- $data->canSource();\r
- if ($_phpDocumentor_setting['sourcecode'])\r
- {\r
- $data->addFileSource($this->data->parent->path, $this->data->parent->source);\r
- }\r
- if (!$data->getExplicitPackage())\r
- {\r
- list($data->package,$data->subpackage) = $this->_guessPackage($this->data->parent->getPath(), $this->data->parent->getSourceLocation('dummy'));\r
- addWarning(PDERROR_NO_PACKAGE_TAG,'file',$this->data->parent->getPath(),$this->last->package);\r
- }\r
- if (isset($this->packagecategories[$this->package])\r
- && $this->packagecategories[$this->package] != $data->category)\r
- addWarning(PDERROR_PACKAGECAT_SET,$this->package,\r
- $this->packagecategories[$this->package],\r
- $data->category);\r
- $this->packagecategories[$this->package] = $data->category;\r
- $this->category = $this->data->parent->category = $data->category;\r
- $this->packagecategories[$this->package] = $this->category;\r
- $this->subpackage = $this->data->parent->subpackage = $data->subpackage;\r
- $this->data->setDocBlock($data);\r
- if ($data->getKeyword('ignore'))\r
- {\r
- $this->proceduralpages->ignorePage($this->data->parent);\r
- $this->private_page = true;\r
- unset($this->last);\r
- $this->privatepages[$this->data->parent->getPath()] = $this->data;\r
- unset($this->pages[$this->data->parent->getPath()]);\r
- return;\r
- }\r
- $this->package = $this->data->parent->package = $data->package;\r
- $this->subpackage = $this->data->parent->subpackage = $data->subpackage;\r
- $this->proceduralpages->addPagePackage($this->data->parent->getPath(),$this->package,$this->subpackage);\r
- if ($access = $data->getKeyword('access'))\r
- {\r
- if (is_object($access) && ($access->getString() == 'private') && (!$this->parsePrivate))\r
- {\r
- $this->proceduralpages->ignorePage($this->data->parent);\r
- $this->private_page = true;\r
- unset($this->last);\r
- $this->privatepages[$this->data->parent->getPath()] = $this->data;\r
- unset($this->pages[$this->data->parent->getPath()]);\r
- return;\r
- }\r
- }\r
- if ($data->getKeyword('name'))\r
- {\r
- $a = $data->getKeyword('name');\r
- if (is_object($a)) $a = $a->value;\r
- $this->data->parent->setFile($a);\r
- $this->proceduralpages->setName($a);\r
- }\r
- $this->addPage($this->data->parent, $this->data->parent->getPath());\r
- if ($this->package)\r
- {\r
- $this->parsePackagePage($this->package, $this->data->parent->getPath());\r
- }\r
- }\r
- \r
- /**\r
- * Backward-compatibility only, use the new tutorials for more power\r
- * @tutorial tutorials.pkg\r
- * @param string package name of package file to parse\r
- * @param string directory of file that contains package name\r
- */\r
- function parsePackagePage($package, $path)\r
- {\r
- if (!isset($this->package_pages[$package]))\r
- {\r
- if (file_exists(dirname($path) . SMART_PATH_DELIMITER . $package . '.html'))\r
- {\r
- if ($this->quietMode === false)\r
- {\r
- phpDocumentor_out("Reading package-level file ".$package . '.html');\r
- flush();\r
- }\r
- $fp = fopen(dirname($path) . SMART_PATH_DELIMITER . $package . '.html',"r");\r
- $ret = fread($fp,filesize(dirname($path) . SMART_PATH_DELIMITER . $package . '.html'));\r
- fclose($fp);\r
- unset($fp);\r
- if ($this->quietMode === false)\r
- {\r
- phpDocumentor_out(" -- Parsing File\n");\r
- flush();\r
- }\r
- $pageParser = new ppageParser;\r
- $tempp = $this->package;\r
- $lp = $this->last;\r
- $pageParser->subscribe('*',$this);\r
- $pageParser->parse($ret,false,$package);\r
- $this->package = $tempp;\r
- $this->last = $lp;\r
- unset($tempp);\r
- unset($pageParser);\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * called via {@link Parser::parse()} and Parser's inherited method\r
- * {@link Publisher::publishEvent()}\r
- *\r
- * $event is one of the PHPDOC constants from Parser.inc. If it is not\r
- * PHPDOCUMENTOR_EVENT_NEWSTATE, then a function name is retrieved from the\r
- * {@link $event_handlers} array and called to handle the $data\r
- * @param integer $event event number from {@link Parser.inc}\r
- * @param mixed $data if $event is {@link PHPDOCUMENTOR_EVENT_NEWSTATE}, $data is a {@link PHP_DOC_EVENT_END_PAGE} or {@link STATE_END_CLASS},\r
- * otherwise $data is either a {@link parserDocBlock}, {@link parserPage} or descendant of {@link parserElement}\r
- * @global array we use 'sourcecode' to determine whether to highlight the source\r
- * of the current file if it has no file-level docblock\r
- */\r
- function HandleEvent($event,$data)\r
- {\r
- global $_phpDocumentor_setting;\r
- global $phpDocumentor_DefaultPackageName, $phpDocumentor_DefaultCategoryName;\r
- if (empty($this->packagecategories))\r
- $this->packagecategories[$phpDocumentor_DefaultPackageName] = $phpDocumentor_DefaultCategoryName;\r
- if ($event == PHPDOCUMENTOR_EVENT_NEWSTATE)\r
- {\r
- if ($data == STATE_END_CLASS)\r
- {\r
- } elseif ($data == PHPDOCUMENTOR_EVENT_END_PAGE)\r
- {\r
- if (!$this->private_page)\r
- {\r
- $this->all_packages[$this->package] = 1;\r
- if (!$this->data->hasExplicitDocBlock())\r
- {\r
- $doc = $this->data->docblock;\r
- if (!$this->data->docblock)\r
- {\r
- $doc = new parserDocBlock;\r
- }\r
- if ($_phpDocumentor_setting['sourcecode'])\r
- {\r
- $doc->canSource();\r
- $doc->addFileSource($this->data->parent->path, $this->data->parent->source);\r
- }\r
- list($doc->package,$doc->subpackage) = $this->_guessPackage($this->data->parent->getPath(), $this->data->parent->getSourceLocation('dummy'));\r
- addWarning(PDERROR_NO_PAGE_LEVELDOCBLOCK,$this->data->parent->getPath());\r
- $this->data->setDocBlock($doc);\r
- $this->proceduralpages->addPage($this->data->parent,$doc->package,$doc->subpackage);\r
- }\r
- $this->pages[$this->data->parent->getPath()] = $this->data;\r
- }\r
- $this->private_page = false;\r
- $this->private_class = false;\r
- if (isset($this->db_template))\r
- {\r
- addWarning(PDERROR_DB_TEMPLATE_UNTERMINATED);\r
- }\r
- unset($this->db_template);\r
- unset($this->last);\r
- } elseif ($data == PHPDOCUMENTOR_EVENT_END_DOCBLOCK_TEMPLATE)\r
- {\r
- unset($this->db_template);\r
- }\r
- //echo $this->state_lookup[$data] . "\n";\r
- //echo $data."\n";\r
- } \r
- else \r
- {\r
- if ($event == PHPDOCUMENTOR_EVENT_README_INSTALL_CHANGELOG)\r
- {\r
- $this->ric[$data[0]] = $data[1];\r
- return;\r
- }\r
- if ($event == PHPDOCUMENTOR_EVENT_DOCBLOCK_TEMPLATE)\r
- {\r
- $data->postProcess();\r
- $this->db_template = $data;\r
- $this->_lastDocBlockWasPageLevel = false;\r
- // 2nd docblock in a row, and it's at the top of the file, page-level docblock\r
- if ($this->type == "docblock" && $this->data->isClean())\r
- {\r
- // can only have 1 package-level docblock, others are ignored\r
- $this->data->clean = false;\r
- if ($this->last->getKeyword('ignore'))\r
- {\r
- $this->proceduralpages->ignorePage($this->data->parent);\r
- $this->private_page = true;\r
- unset($this->last);\r
- $this->privatepages[$this->data->parent->getPath()] = $this->data;\r
- unset($this->pages[$this->data->parent->getPath()]);\r
- return;\r
- }\r
- $this->data->setDocBlock($this->last);\r
- $this->package = $this->data->parent->package = $this->last->package;\r
- $this->subpackage = $this->data->parent->subpackage = $this->last->subpackage;\r
- $this->proceduralpages->addPagePackage($this->data->parent->getPath(),$this->package,$this->subpackage);\r
- if ($access = $this->last->getKeyword('access'))\r
- {\r
- if (is_object($access) && ($access->getString() == 'private') && (!$this->parsePrivate))\r
- {\r
- addWarning(PDERROR_PARSEPRIVATE, $this->data->parent->getPath());\r
- $this->proceduralpages->ignorePage($this->data->parent);\r
- $this->private_page = true;\r
- unset($this->last);\r
- $this->privatepages[$this->data->parent->getPath()] = $this->data;\r
- unset($this->pages[$this->data->parent->getPath()]);\r
- return;\r
- }\r
- }\r
- if ($this->last->getKeyword('name'))\r
- {\r
- $a = $this->last->getKeyword('name');\r
- if (is_object($a)) $a = $a->value;\r
- $this->data->parent->setFile($a);\r
- $this->proceduralpages->setName($a);\r
- }\r
- $this->addPage($this->data->parent, $this->data->parent->getPath());\r
- if ($this->package)\r
- {\r
- $this->parsePackagePage($this->package, $this->data->parent->getPath());\r
- }\r
- }\r
- unset($this->last);\r
- } else\r
- {\r
- $this->lasttype = $this->type;\r
- $type = $data->getType();\r
-// fancy_debug($type,$data);\r
- if (($type != 'page') && ($type != 'docblock') && ($type != 'packagepage') && ($type != 'tutorial'))\r
- {\r
- $data->setFile($this->data->parent->getFile());\r
- }\r
- $this->type = $type;\r
- //echo $type . "\n";\r
- \r
- if (isset($this->event_handlers[$type]))\r
- {\r
- $handle = $this->event_handlers[$type];\r
- $this->$handle($event,$data);\r
- }\r
- } \r
- }\r
- }\r
- \r
- /**\r
- * Replaces the {@link parserPage} represented by $this->pages[$path] with\r
- * $page\r
- *\r
- * Called by {@link addPageIfNecessary(), handleDocBlock()} and\r
- * {@link ProceduralPages::setupPages()}, this method first checks to see if\r
- * the page has been added. If not, it assumes that the page has either\r
- * been @ignored or set with @access private with --parseprivate off, and\r
- * returns {@link addPrivatePage()}. Otherwise, it sets the pages[$path] to\r
- * be the parserPage $page and sets the package and subpackage to that of\r
- * $page\r
- * @see $pages\r
- * @param parserPage\r
- * @param string full path to the file\r
- */\r
- function addPage($page, $path)\r
- {\r
- if (!isset($this->pages[$path])) return $this->addPrivatePage($page, $path);\r
- $this->pages[$path]->setParent($page);\r
- if ($page->package != $GLOBALS['phpDocumentor_DefaultPackageName'])\r
- {\r
- if (!$this->pages[$path]->docblock)\r
- {\r
- $docblock = new parserDocBlock;\r
- $docblock->package = $page->package;\r
- $docblock->subpackage = $page->subpackage;\r
- $this->pages[$path]->docblock = $docblock;\r
- } else\r
- {\r
- $this->pages[$path]->docblock->package = $page->package;\r
- $this->pages[$path]->docblock->subpackage = $page->subpackage;\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * add a new {@link parserPage} to the $pages array if none is found\r
- *\r
- * This method is used when a page has been @ignored or marked with @access\r
- * private, and a public class is in the page (a class with no @access\r
- * private in its DocBlock). The method first creates a new page in the\r
- * {@link $pages} array and then copies path information, and calls\r
- * {@link addPage()} to set up packages\r
- * @param string full path of page\r
- */\r
- function addPageIfNecessary($path, &$class)\r
- {\r
- global $_phpDocumentor_setting;\r
- if (!$this->parsePrivate)\r
- {\r
- if (!isset($this->pages[$path]))\r
- {\r
- $this->pages[$path] = new parserData;\r
- $this->pages[$path]->docblock = new parserDocBlock;\r
- $this->pages[$path]->docblock->package = $this->privatepages[$path]->docblock->package;\r
- $this->pages[$path]->docblock->subpackage = $this->privatepages[$path]->docblock->subpackage;\r
- $par = $this->privatepages[$path]->parent;\r
- $this->pages[$path]->setParent($par);\r
- $this->proceduralpages->addPage($par);\r
- }\r
- }\r
- if (!empty($_phpDocumentor_setting['packageoutput']))\r
- $packages = explode(',',$_phpDocumentor_setting['packageoutput']);\r
- if (!empty($_phpDocumentor_setting['packageoutput']) &&\r
- $this->pages[$path]->parent->package != $class->docblock->package &&\r
- !in_array($this->pages[$path]->parent->package,$packages))\r
- {\r
- $this->pages[$path]->parent->package = $class->docblock->package;\r
- $this->addPage($this->pages[$path]->parent, $path);\r
- $this->proceduralpages->addPage($this->pages[$path]->parent);\r
- }\r
- }\r
- \r
- /**\r
- * Adds a {@link parserPage} element to the {@link parserData} element in\r
- * $this->privatepages[$path]\r
- *\r
- * Performs a similar function to addPage, but adds to the\r
- * {@link $privatePages} array\r
- * @param parserPage $page\r
- * @param string $path full path to the page\r
- * @see addPage()\r
- */\r
- function addPrivatePage($page, $path)\r
- {\r
- /*\r
- * if privatepages is still empty,\r
- * we need to initialize it with an empty \r
- * path=>ParserData element, so that it has\r
- * a top-level element... otherwise the setParent() call\r
- * below will crap out.\r
- */\r
- if (count($this->privatepages) == 0) {\r
- $this->privatepages[$path] = new ParserData();\r
- }\r
- $this->privatepages[$path]->setParent($page);\r
- if (isset($page->package) && $page->package != $GLOBALS['phpDocumentor_DefaultPackageName'])\r
- {\r
- if (!$this->privatepages[$path]->docblock)\r
- {\r
- $docblock = new parserDocBlock;\r
- $docblock->package = $page->package;\r
- $docblock->subpackage = $page->subpackage;\r
- $this->privatepages[$path]->docblock = $docblock;\r
- } else\r
- {\r
- $this->privatepages[$path]->docblock->package = $page->package;\r
- $this->privatepages[$path]->docblock->subpackage = $page->subpackage;\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * adds a processed descendant of {@link parserElement} to the {@link $pages}\r
- * array or {@link $privatepages} array\r
- *\r
- * This function expects the page to exist in either $pages or $privatepages. It calls the\r
- * {@link parserData::addElement()} method to add $element to the page.\r
- * @param parserElement $element this will actually be a descendant of parserElement\r
- * @param string $path\r
- */\r
- function addElementToPage($element, $path)\r
- {\r
- if (isset($this->privatepages[$path]))\r
- {\r
- if (isset($this->pages[$path]))\r
- {\r
- if ($element->type == 'class' || $element->type == 'method'\r
- || $element->type == 'var' || $element->type == 'const')\r
- {\r
- $this->pages[$path]->addElement($element);\r
- } else\r
- $this->privatepages[$path]->addElement($element);\r
- } else\r
- $this->privatepages[$path]->addElement($element);\r
- } else\r
- {\r
- if (isset($this->pages[$path]))\r
- {\r
- $this->pages[$path]->addElement($element);\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * Add all the @uses tags from $element to the $uses array so that @usedby\r
- * virtual tags can be added\r
- * @uses parserUsesTag::getSeeElement() used to initialize {@link $uses}\r
- * @uses parserUsesTag::getDescription() used to initialize {@link $uses}\r
- * @param parserElement descendant of parserElement\r
- * @param string full path to the file \r
- */\r
- function addUses($element, $path)\r
- {\r
- if (isset($element->type) && $element->type == 'page')\r
- {\r
- $element = $this->pages[$element->path];\r
- }\r
- if (!$this->parsePrivate && isset($element->docblock->hasaccess) && $element->docblock->hasaccess)\r
- {\r
- $a = $element->docblock->getKeyword('access');\r
- if (is_object($a) && $a->getString() == 'private') return;\r
- }\r
- if (isset($this->privatepages[$path]))\r
- {\r
- if (isset($this->pages[$path]))\r
- {\r
- $uses = $element->docblock->getKeyword('uses');\r
- if ($uses)\r
- {\r
- if (!is_array($uses)) $uses = array($uses);\r
- foreach($uses as $use)\r
- {\r
- if (!is_object($use)) continue;\r
- $el = $use->getSeeElement();\r
- $description = $use->getDescription();\r
- $this->uses[$el][] = array($element, $description);\r
- }\r
- }\r
- }\r
- } else\r
- {\r
- if (isset($this->pages[$path]))\r
- {\r
- $uses = $element->docblock->getKeyword('uses');\r
- if ($uses)\r
- {\r
- if (!is_array($uses)) $uses = array($uses);\r
- foreach($uses as $use)\r
- {\r
- if (!is_object($use)) continue;\r
- $el = $use->getSeeElement();\r
- $description = $use->getDescription();\r
- $this->uses[$el][] = array($element, $description);\r
- }\r
- }\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * Add a {@link parserUsedByTag} link to every element referred to by @uses\r
- * @param Converter temporary converter used to retrieve abstract links\r
- * @uses phpDocumentor_IntermediateParser::addUses() indirectly, as\r
- * addUses() sets up $uses, which is iterated over here\r
- * @uses $pages sets up all @usedby tags from here\r
- * @access private\r
- */\r
- function _setupUsesList(&$converter)\r
- {\r
- ob_start();\r
- $converter->_createPkgElements($this->pages);\r
- ob_end_clean();\r
- ksort($this->uses);\r
- foreach($this->uses as $link => $elements)\r
- {\r
- foreach($elements as $element)\r
- {\r
- if ($element[0]->type == 'method' || $element[0]->type == 'var' ||\r
- $element[0]->type == 'const')\r
- {\r
- $converter->class = $element[0]->getClass();\r
- }\r
- if ($element[0]->type == 'class')\r
- {\r
- $converter->class = $element[0]->getName();\r
- }\r
- $reallink = $converter->getLink($link,$element[0]->docblock->package);\r
- if (is_object($reallink))\r
- {\r
- // add a used by tag to the docblock of the destination\r
- switch(phpDocumentor_get_class($reallink))\r
- {\r
- case 'pagelink' :\r
- $this->pages[$reallink->path]->docblock->addUsedBy(\r
- $element[0]->getLink($converter, false, true),\r
- $element[1]);\r
- break;\r
- case 'functionlink' :\r
- case 'definelink' :\r
- case 'globallink' :\r
- if (isset($this->pages[$reallink->path]))\r
- {\r
- for ($i=0;\r
- $i<count($this->pages[$reallink->path]->elements);\r
- $i++) {\r
- if ($this->pages[$reallink->path]->elements[$i]->type ==\r
- str_replace('link', '',\r
- phpDocumentor_get_class($reallink)) &&\r
- $this->pages[$reallink->path]->\r
- elements[$i]->getName() \r
- == $reallink->name) {\r
- $this->pages[$reallink->path]->elements[$i]->\r
- docblock->addUsedBy(\r
- $element[0]->getLink($converter,false,true),\r
- $element[1]);\r
-// debug('added @usedby to '.str_replace('link','',phpDocumentor_get_class($reallink)).' '.$reallink->name);\r
- }\r
- }\r
- }\r
- break;\r
- case 'classlink' :\r
- case 'methodlink' :\r
- case 'varlink' :\r
- case 'constlink' :\r
- if (isset($this->pages[$reallink->path]))\r
- {\r
- for ($i=0;$i<count($this->pages[$reallink->path]->classelements);$i++)\r
- {\r
- if ($this->pages[$reallink->path]->classelements[$i]->type ==\r
- str_replace('link','',phpDocumentor_get_class($reallink)) &&\r
- $this->pages[$reallink->path]->classelements[$i]->getName() == $reallink->name &&\r
- (!isset($reallink->class) || \r
- $this->pages[$reallink->path]->classelements[$i]->getClass() == $reallink->class))\r
- {\r
- $this->pages[$reallink->path]->classelements[$i]->docblock->addUsedBy($element[0]->getLink($converter,false,true), $element[1]);\r
-// debug('added @usedby to '.str_replace('link','',phpDocumentor_get_class($reallink)).' '.$reallink->name);\r
- }\r
- }\r
- }\r
- break;\r
- }\r
- }\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * Interface to the Converter\r
- *\r
- * This function simply passes {@link $pages} and {@link package_pages} to\r
- * the walk() method, and then calls the Output() method. Note that\r
- * Output() is not required to do anything, and in fact doesn't in\r
- * HTMLframesConverter.\r
- * @uses Converter::walk() passes {@link $pages} and {@link $package_pages}\r
- * @uses Converter::Output()\r
- */\r
- function Convert($title, $converter)\r
- {\r
- $converter->walk($this->pages, $this->package_pages);\r
- $converter->Output($title);\r
- $converter->cleanup();\r
- }\r
- \r
- /**\r
- * Clean up classes\r
- *\r
- * {@source}\r
- * @access private\r
- * @uses Classes::Inherit() passes $this\r
- */\r
- function fixClasses()\r
- {\r
- $this->classes->Inherit($this);\r
- }\r
- \r
- /**\r
- * Clean up Procedural Pages\r
- * {@source}\r
- * @access private\r
- * @uses ProceduralPages::setupPages() passes $this\r
- */\r
- function fixProcPages()\r
- {\r
- $this->proceduralpages->setupPages($this);\r
- }\r
- \r
- /**\r
- * If the parent class of $class is in a different package, adds it to the\r
- * {@link $package_parents} array\r
- * @param parserClass &$class\r
- */\r
- function addPackageParent(&$class)\r
- {\r
- if (!is_array($class->parent)) return;\r
- $par = $this->classes->getClass($class->parent[1], $class->parent[0]);\r
- if ($class->docblock->package == $par->docblock->package) return;\r
- $this->package_parents[$class->docblock->package] = $par->docblock->package;\r
- if (!isset($this->package_parents[$par->docblock->package]) || !$this->package_parents[$par->docblock->package]) $this->package_parents[$par->docblock->package] = false;\r
- }\r
- \r
- /**\r
- * Add a converter name to use to the list of converters\r
- *\r
- * Sets up the {@link $converters} array.\r
- * {@internal\r
- * First, the Converter's file is included, and then, if successful,\r
- * the converter classname is tested for existance. If all is good,\r
- * then the templates are added to the list of converters/templates to use}}\r
- * @param string $output output format (HTML, PDF, XML). Must be all caps\r
- * @param string $name Converter name (frames, for example, is the name of\r
- * HTMLframesConverter)\r
- * @param string $template template to use, should be a relative path to the\r
- * templates dir (like DOM/default)\r
- */\r
- function addConverter($output,$name,$template)\r
- {\r
- if ($this->templateBase) {\r
- $templateBase = str_replace('\\','/', $this->templateBase) . '/Converters';\r
- } else {\r
- if ('@PEAR-DIR@' != '@'.'PEAR-DIR@') {\r
- $templateBase = 'PhpDocumentor/phpDocumentor/Converters';\r
- } else {\r
- $templateBase = str_replace('\\','/',$GLOBALS['_phpDocumentor_install_dir']) . '/phpDocumentor/Converters';\r
- }\r
- }\r
- if (strpos($name,PATH_DELIMITER))\r
- {\r
- // include the parent template\r
- $parent = explode(PATH_DELIMITER,$name);\r
- $parent = $parent[0];\r
- if (!class_exists($output . $parent . 'Converter')) {\r
- $filename = $templateBase . '/' . $output . '/' . $parent . '/' . $output\r
- . $parent . 'Converter.inc';\r
- if (Io::isIncludeable($filename))\r
- {\r
- include_once($filename);\r
- }\r
- }\r
- if (!class_exists($output . $parent . 'Converter'))\r
- {\r
- addError(PDERROR_CONVERTER_NOT_FOUND,"parent Converter ".$output . $parent . "Converter of child Converter ".$output . str_replace(PATH_DELIMITER,'',$name) . "Converter");\r
- }\r
- }\r
- $filename = $templateBase .\r
- PATH_DELIMITER . $output . PATH_DELIMITER . $name . PATH_DELIMITER . $output .\r
- str_replace(PATH_DELIMITER, '', $name) . "Converter" . ".inc";\r
- if (Io::isIncludeable($filename))\r
- {\r
- include_once($filename);\r
- }\r
- if (class_exists($output . str_replace(PATH_DELIMITER,'',$name) . 'Converter'))\r
- {\r
- $this->converters[$output][$output . str_replace(PATH_DELIMITER,'',$name) . "Converter"][] = $template;\r
- } else\r
- {\r
- addError(PDERROR_CONVERTER_NOT_FOUND,$output . str_replace(PATH_DELIMITER,'',$name) . "Converter");\r
- }\r
- }\r
-\r
- /**\r
- * does a natural case sort on two {@link parserElement} descendants\r
- *\r
- * @param mixed $a\r
- * @param mixed $b\r
- * @return int\r
- * @see generateElementIndex()\r
- */\r
- function elementCmp ($a, $b)\r
- {\r
- return strnatcasecmp($a->getName(), $b->getName());\r
- }\r
- \r
- /**\r
- * does a natural case sort on two class elements (either\r
- * {@link parserClass, parserMethod} or {@link parserVar}\r
- *\r
- * @param mixed $a\r
- * @param mixed $b\r
- * @return int\r
- * @see generateElementIndex()\r
- */\r
- function ClasselementCmp ($a, $b)\r
- {\r
- if (phpDocumentor_get_class($a) == 'parserclass') $atest = $a->name; else $atest = $a->class;\r
- if (phpDocumentor_get_class($b) == 'parserclass') $btest = $b->name; else $btest = $b->class;\r
- \r
- if(($c = strnatcasecmp($atest, $btest)) != 0) return $c;\r
- if (phpDocumentor_get_class($a) != 'parserclass') $atest .= $a->name;\r
- if (phpDocumentor_get_class($b) != 'parserclass') $btest .= $b->name;\r
- if (phpDocumentor_get_class($a) == 'parsermethod' && phpDocumentor_get_class($b) == 'parsermethod')\r
- {\r
- if ($a->isConstructor) return -1;\r
- if ($b->isConstructor) return 1;\r
- if ($a->isDestructor) return -1;\r
- if ($b->isDestructor) return 1;\r
- }\r
- return strnatcasecmp($atest,$btest);\r
- }\r
- \r
- /**\r
- * call this method once parsing has completed.\r
- *\r
- * This method calls the private methods fixClasses and fixProcPages, both\r
- * of which adjust inheritance and package information based on complicated\r
- * post-parsing rules described in {@link ProceduralPages::setupPages()}\r
- * and {@link Classes::Inherit()}. Then, it sorts elements of the $pages\r
- * array and calls Convert for each Converter in the $converters array\r
- * @see $converters\r
- * @see $pages\r
- * @see Convert()\r
- */\r
- function Output ($title = "Generated Documentation")\r
- {\r
- $GLOBALS['phpDocumentor_errors']->curfile = false;\r
- $this->fixClasses();\r
- $this->fixProcPages();\r
-// var_dump($this->uses);\r
-// exit;\r
- phpDocumentor_out("\nSorting page elements...");\r
- flush();\r
- uasort($this->pages,'pagesort');\r
- foreach($this->pages as $i => $page)\r
- {\r
- usort($this->pages[$i]->elements,array($this,'elementCmp'));\r
- usort($this->pages[$i]->classelements,array($this,'ClasselementCmp'));\r
- }\r
- phpDocumentor_out("done\n");\r
- flush();\r
- $complicatedout = false;\r
- if (is_array($this->converters))\r
- {\r
- if (count($this->converters) > 1)\r
- {\r
- $complicatedout = true;\r
- }\r
- phpDocumentor_out("Formatting @uses list...");\r
- flush();\r
- $a = new __dummyConverter($this->all_packages, $this->package_parents, $this->classes, $this->proceduralpages, $this->packageoutput, $this->parsePrivate, $this->quietMode, $this->targetDir , '', $this->title);\r
- $this->_setupUsesList($a);\r
- unset($a);\r
- phpDocumentor_out("done\n\n");\r
- flush();\r
- foreach($this->converters as $converter => $blah)\r
- {\r
- if (is_array($blah))\r
- {\r
- if (count($blah) > 1)\r
- {\r
- $complicatedout = true;\r
- }\r
- foreach($blah as $converter => $templates)\r
- {\r
- foreach($templates as $template)\r
- {\r
- $extraout = '';\r
- if ($complicatedout)\r
- {\r
- $extraout = SMART_PATH_DELIMITER . $converter;\r
- }\r
- if (count($templates) > 1)\r
- {\r
- $extraout .= SMART_PATH_DELIMITER . str_replace(PATH_DELIMITER, SMART_PATH_DELIMITER, substr($template,0,strlen($template) - 1));\r
- }\r
- $a = new $converter($this->all_packages, $this->package_parents, $this->classes, $this->proceduralpages, $this->packageoutput, $this->parsePrivate, $this->quietMode, $this->targetDir . $extraout, $template, $this->title);\r
- if (isset($this->templateBase))\r
- {\r
- $a->setTemplateBase($this->templateBase, $template);\r
- }\r
- $a->ric = $this->ric;\r
- $a->packagecategories = $this->packagecategories;\r
- if (isset($this->tutorials)) $a->setTutorials($this->tutorials);\r
- $this->Convert($title, $a);\r
- unset($a);\r
- }\r
- }\r
- }\r
- }\r
- } else\r
- {\r
- addErrorDie(PDERROR_NO_CONVERTERS);\r
- }\r
- }\r
-\r
- /**\r
- * Sets the output directory\r
- *\r
- * @param string $dir the output directory\r
- */\r
- function setTargetDir($dir)\r
- {\r
- $this->targetDir = $dir;\r
- }\r
-\r
- /**\r
- * Sets the template base directory\r
- *\r
- * @param string $dir the template base directory\r
- * @tutorial phpDocumentor.howto.pkg#using.command-line.templatebase\r
- */\r
- function setTemplateBase($dir)\r
- {\r
- $this->templateBase = $dir;\r
- }\r
-\r
- /**\r
- * set parsing information output mode (quiet or verbose)\r
- *\r
- * If set to false, no parsing information (parsing /php/file/thisfile.php,\r
- * Converting etc.) will be displayed.\r
- * Useful for cron jobs\r
- * @param bool $quietMode\r
- */\r
- function setQuietMode($quietMode)\r
- {\r
- $this->quietMode = $quietMode;\r
- }\r
-\r
- /**\r
- * show warnings for undocumented elements\r
- *\r
- * If set to false, no warnings will be shown for undocumented elements.\r
- * Useful for identifying classes and methods that haven't yet been documented.\r
- * @param bool $undocumentedElementWarnings\r
- */\r
- function setUndocumentedElementWarningsMode($undocumentedElementWarnings)\r
- {\r
- $this->undocumentedElementWarnings = $undocumentedElementWarnings;\r
- }\r
- \r
- /**\r
- * set display of elements marked with @access private\r
- *\r
- * If set to true, elements will be displayed\r
- * @param bool $parse\r
- */\r
- function setParsePrivate($parse)\r
- {\r
- $this->parsePrivate = $parse;\r
- }\r
-}\r
-\r
-/** @access private */\r
-function pagesort($a, $b)\r
-{\r
- return strnatcasecmp($a->parent->file,$b->parent->file);\r
-}\r
-?>\r