+++ /dev/null
-<?php\r
-/**\r
- * Intermediate class parsing structure.\r
- *\r
- * phpDocumentor :: automatic documentation generator\r
- * \r
- * PHP versions 4 and 5\r
- *\r
- * Copyright (c) 2001-2007 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
- * @category ToolsAndUtilities\r
- * @package phpDocumentor\r
- * @author Greg Beaver <cellog@php.net>\r
- * @copyright 2001-2007 Gregory Beaver\r
- * @license http://www.opensource.org/licenses/lgpl-license.php LGPL\r
- * @version CVS: $Id: Classes.inc,v 1.11 2007/10/10 01:18:25 ashnazg Exp $\r
- * @filesource\r
- * @link http://www.phpdoc.org\r
- * @link http://pear.php.net/PhpDocumentor\r
- * @see parserDocBlock, parserInclude, parserPage, parserClass\r
- * @see parserDefine, parserFunction, parserMethod, parserVar\r
- * @since 1.0rc1\r
- * @todo CS cleanup - change package to PhpDocumentor\r
- */\r
-/**\r
- * Intermediate class parsing structure.\r
- *\r
- * The {@link phpDocumentor_IntermediateParser} class uses this class and its\r
- * cousin, {@link ProceduralPages} to organize all parsed source code elements.\r
- * Data is fed to each immediately after it is parsed, and at conversion time,\r
- * everything is organized.\r
- *\r
- * The Classes class is responsible for all inheritance, including resolving\r
- * name conflicts between classes, determining which classes extend other\r
- * classes, and is responsible for all inheritance of documentation.\r
- * {@internal\r
- * This structure parses classes, vars and methods by file, and then iterates\r
- * over the class tree to set up inheritance. The {@link Inherit()}\r
- * method is the meat of the class, and processes the class trees from root to\r
- * branch, ensuring that parsing order is unimportant.}}\r
- *\r
- * @category ToolsAndUtilities\r
- * @package phpDocumentor\r
- * @author Greg Beaver <cellog@php.net>\r
- * @copyright 2001-2007 Gregory Beaver\r
- * @license http://www.opensource.org/licenses/lgpl-license.php LGPL\r
- * @version Release: 1.4.1\r
- * @link http://www.phpdoc.org\r
- * @link http://pear.php.net/PhpDocumentor\r
- * @since 1.0rc1\r
- * @todo CS cleanup - change package to PhpDocumentor\r
- */\r
-class Classes\r
-{\r
- /**#@+\r
- * @access private\r
- */\r
- /**\r
- * file being parsed, used in every add function to match up elements with \r
- * the file that contains them\r
- *\r
- * This variable is used during parsing to associate class elements added\r
- * to the data structures that contain them with the file they reside in\r
- * @see addClass(), addMethod(), addVar(), nextFile()\r
- * @var string\r
- */\r
- var $curfile;\r
- /**\r
- * class being parsed, used to match up methods and vars with their parent\r
- * class\r
- *\r
- * This variable is used during parsing to associate class elements added\r
- * to the data structures that contain them with the file they reside in\r
- * @see addMethod(), addVar()\r
- * @var string\r
- */\r
- var $curclass;\r
- \r
- /**\r
- * Used when a definite match is made between a parent class and a child\r
- * class\r
- *\r
- * This variable is used in post-parsing.\r
- *\r
- * Format:<pre>\r
- * array(\r
- * parent => array(\r
- * parentfile => array(\r
- * child => childfile\r
- * )\r
- * )\r
- * )</pre>\r
- * @var array\r
- */\r
- var $definitechild;\r
- /**\r
- * array of parsed classes organized by the name of the file that contains\r
- * the class.\r
- *\r
- * Format:<pre>\r
- * array(\r
- * filename => array(\r
- * classname => {@link parserClass}\r
- * )\r
- * )</pre>\r
- * @var array\r
- */\r
- var $classesbyfile = array();\r
- /**\r
- * array of file names organized by classes that are in the file.\r
- *\r
- * This structure is designed to handle name conflicts. Two files can\r
- * contain classes with the same name, and this array will record both\r
- * filenames to help control linking and inheritance errors\r
- *\r
- * Format:<pre>\r
- * array(\r
- * classname => array(\r
- * name of file containing classname,\r
- * name of file 2 containing classname,\r
- * ...\r
- * )\r
- * )</pre>\r
- * @var array\r
- */\r
- var $classesbynamefile = array();\r
- /**\r
- * array of parsed methods organized by the file that contains them.\r
- *\r
- * Format:<pre>\r
- * array(\r
- * filename => array(\r
- * classname => array(\r
- * {@link parserMethod} 1, \r
- * {@link parserMethod} 2,\r
- * ...\r
- * )\r
- * )\r
- * )</pre>\r
- * @var array\r
- */\r
- var $methodsbyfile = array();\r
- /**\r
- * array of parsed vars organized by the file that contains them.\r
- *\r
- * Format:<pre>\r
- * array(\r
- * filename => array(\r
- * classname => array(\r
- * {@link parserVar} 1, \r
- * {@link parserVar} 2,\r
- * ...\r
- * )\r
- * )\r
- * )</pre>\r
- * @var array\r
- */\r
- var $varsbyfile = array();\r
- /**\r
- * array of parsed class constants organized by the file that contains them.\r
- *\r
- * Format:<pre>\r
- * array(\r
- * filename => array(\r
- * classname => array(\r
- * {@link parserConst} 1, \r
- * {@link parserConst} 2,\r
- * ...\r
- * )\r
- * )\r
- * )</pre>\r
- * @var array\r
- */\r
- var $constsbyfile = array();\r
- /**\r
- * keeps track of extend declarations by file, used to find inheritance\r
- *\r
- * Format:<pre>\r
- * array(\r
- * filename => array(\r
- * classname => parentclassname\r
- * )\r
- * )</pre>\r
- * @var array\r
- */\r
- var $extendsbyfile = array();\r
- /**\r
- * Keeps track of child classes by file.\r
- * Since phpDocumentor can document collections of files that contain name\r
- * conflicts (PHP would give a fatal error), it\r
- * is impossible to assume a class that declares "extends foo" necessarily\r
- * extends the class foo in file X. It could be an\r
- * extended class of class foo in file Y. Because of this, phpDocumentor\r
- * relies on packaging to resolve the name conflict\r
- * This array keeps track of the packages of a child class\r
- *\r
- * Format:<pre>\r
- * array(\r
- * parentclassname => array(\r
- * filename => array(\r
- * childclassname => array(\r
- * packagename, \r
- * packagename\r
- * )\r
- * )\r
- * )\r
- * )</pre>\r
- * @var array\r
- */\r
- var $classchildrenbyfile = array();\r
- /**\r
- * Keeps track of class packages found in a file.\r
- * This is used in {@link getParentClass()} to determine the number of\r
- * packages in a file, in order to resolve inheritance issues\r
- * Format:<pre>\r
- * array(\r
- * filename => array(\r
- * packagename1, \r
- * packagename2,\r
- * ...\r
- * )\r
- * )</pre>\r
- * @var array\r
- */\r
- var $classpackagebyfile = array();\r
- /**\r
- * a tree of class inheritance by name.\r
- *\r
- * Format:<pre>\r
- * array(\r
- * childname => parentname,\r
- * childname1 => parentname1,\r
- * rootname => 0, \r
- * ...\r
- * )</pre>\r
- * @var array\r
- * @see Converter::generateSortedClassTreeFromClass()\r
- */\r
- var $classparents = array();\r
- /**\r
- * Keeps track of package and subpackage for each class name, organized\r
- * by package\r
- *\r
- * Format:<pre>\r
- * array(\r
- * classname => array(\r
- * path => array(\r
- * package,\r
- * subpackage\r
- * ),\r
- * path2 => array(\r
- * package,\r
- * subpackage\r
- * ),\r
- * ...\r
- * )\r
- * )</pre>\r
- * @var array\r
- */\r
- var $classpathpackages = array();\r
- /**\r
- * used to delete duplicates in the same package to avoid documentation errors\r
- *\r
- * Specifically used in {@link Converter::checkKillClass()}\r
- */\r
- var $killclass = array();\r
- /**\r
- * array of methods by package and class\r
- *\r
- * format:<pre>\r
- * array(packagename =>\r
- * array(classname =>\r
- * array(methodname1 => {@link parserMethod} class,\r
- * methodname2 => {@link parserMethod} class,...)\r
- * )\r
- * )\r
- * )</pre>\r
- * @var array\r
- * @see Converter\r
- */\r
- var $methods = array();\r
- \r
- /**\r
- * array of class variables by package and class\r
- *\r
- * format:<pre>\r
- * array(packagename =>\r
- * array(classname =>\r
- * array(variablename1 => {@link parserVar} class,\r
- * variablename2 => {@link parserVar} class,...\r
- * )\r
- * )\r
- * )</pre>\r
- * @var array\r
- * @see Converter\r
- */\r
- var $vars = array();\r
- \r
- /**\r
- * array of class variables by package and class\r
- *\r
- * format:<pre>\r
- * array(packagename =>\r
- * array(classname =>\r
- * array(constname1 => {@link parserConst} class,\r
- * constname2 => {@link parserConst} class,...\r
- * )\r
- * )\r
- * )</pre>\r
- * @var array\r
- * @see Converter\r
- */\r
- var $consts = array();\r
- /**\r
- * Reverse class_packages_by_file, used to prevent duplicates\r
- * @var array Format: array(packagename => 1)\r
- */\r
- var $revcpbf = array();\r
- /**\r
- * All classes with no parents (no extends clause) are tracked in this array\r
- * by the file that contains them.\r
- *\r
- * Format:<pre>\r
- * array(\r
- * classname => array(\r
- * name of file1 that contains root classname,\r
- * name of file2 that contains root classname,\r
- * ...\r
- * )\r
- * )</pre>\r
- * @var array\r
- */\r
- var $roots = array();\r
- /**\r
- * All classes with a parent that was not parsed are included in this array\r
- *\r
- * Format:<pre>\r
- * array(\r
- * classname => array(\r
- * name of file1 that contains root classname,\r
- * name of file2 that contains root classname,\r
- * ...\r
- * )\r
- * )</pre>\r
- * @var array\r
- */\r
- var $specialRoots = array();\r
- \r
- /**\r
- * array of all files that contain classes with the same name\r
- * @var array Format: (classname => array(path1, path2,...))\r
- */\r
- var $potentialclassconflicts = array();\r
- \r
- /**\r
- * array of all inter-package name conflicts of classes\r
- *\r
- * This array allows documentation of PHP namespace conflicts that would\r
- * occur should a user try to include these files in the same file\r
- * @var array Format: (classname => array(path1, path2,...))\r
- */\r
- var $classconflicts = array();\r
- /**#@-*/\r
- /**\r
- * While parsing, add a class to the list of parsed classes\r
- *\r
- * sets up the {@link $classesbyfile, $classesbynamefile, $extendsbyfile},\r
- * {@link $classchildrenbyfile, $roots} arrays, and sets {@link $curclass}\r
- *\r
- * @param parserClass &$element element is a {@link parserClass}\r
- *\r
- * @return void\r
- * @uses addPackageToFile() marks the current class's package as being\r
- * present in a file\r
- */\r
- function addClass(&$element)\r
- {\r
- $this->curclass = $element->getName();\r
- $element->curfile = $this->curfile;\r
- if (isset($this->classesbyfile[$this->curfile][$this->curclass])) {\r
- addWarning(PDERROR_ELEMENT_IGNORED, \r
- 'class', $this->curclass, $this->curfile);\r
- $this->curclass = false;\r
- return;\r
- }\r
- $this->\r
- classesbyfile\r
- [$this->curfile][$this->curclass]\r
- = $element;\r
- $this->\r
- classesbynamefile[$this->curclass][]\r
- = $this->curfile;\r
- $this->\r
- extendsbyfile[$this->curfile][$this->curclass]\r
- = $element->getExtends();\r
- $this->\r
- classchildrenbyfile[$element->getExtends()]\r
- [$this->curfile][$this->curclass][] \r
- = $element->docblock->package;\r
- if ($element->docblock->getExplicitPackage())\r
- $this->addPackageToFile($element->docblock->package);\r
- if (!$element->getExtends()) {\r
- $this->roots[$this->curclass][] = $this->curfile;\r
- }\r
- }\r
- \r
- /**\r
- * While parsing, add a method to the list of parsed methods\r
- *\r
- * sets up the {@link $methodsbyfile} array using {@link $curfile} and\r
- * {@link $curclass}\r
- *\r
- * @param parserMethod &$element element is a {@link parserMethod}\r
- *\r
- * @return void\r
- */\r
- function addMethod(&$element)\r
- {\r
- if (!$this->curclass) return;\r
- $this->methodsbyfile[$this->curfile][$this->curclass][] = $element;\r
- }\r
- \r
- /**\r
- * While parsing, add a variable to the list of parsed variables\r
- *\r
- * sets up the {@link $varsbyfile} array using {@link $curfile} \r
- * and {@link $curclass}\r
- *\r
- * @param parserVar &$element element is a {@link parserVar}\r
- *\r
- * @return void\r
- */\r
- function addVar(&$element)\r
- {\r
- if (!$this->curclass) return;\r
- $this->varsbyfile[$this->curfile][$this->curclass][] = $element;\r
- }\r
- \r
- /**\r
- * While parsing, add a variable to the list of parsed variables\r
- *\r
- * sets up the {@link $constsbyfile} array using {@link $curfile} \r
- * and {@link $curclass}\r
- *\r
- * @param parserConst &$element element is a {@link parserConst}\r
- *\r
- * @return void\r
- */\r
- function addConst(&$element)\r
- {\r
- if (!$this->curclass) return;\r
- $this->constsbyfile[$this->curfile][$this->curclass][] = $element;\r
- }\r
- \r
- /**\r
- * Prepare to parse a new file\r
- *\r
- * sets {@link $curfile} to $file and {@link $curclass} \r
- * to false (no class being parsed)\r
- *\r
- * @param string $file file currently being parsed\r
- *\r
- * @return void\r
- */\r
- function nextFile($file)\r
- {\r
- $this->curfile = $file;\r
- $this->curclass = false;\r
- }\r
- \r
- /**\r
- * Mark a package as being used in a class\r
- *\r
- * {@source}\r
- *\r
- * @param string $package package name\r
- *\r
- * @return void\r
- */\r
- function addPackageToFile($package)\r
- {\r
- if (!isset($this->revcpbf[$this->curfile][$package]))\r
- $this->classpackagebyfile[$this->curfile][] = $package;\r
- $this->revcpbf[$this->curfile][$package] = 1;\r
- }\r
- \r
- /**\r
- * Find the parent class of $class, and set up structures to note this fact\r
- *\r
- * Modifies the {@link parserClass} element in {@link $classesbyfile} to use\r
- * the parent's package, and inherit methods/vars\r
- *\r
- * @param string $class child class to find parent class\r
- * @param string $file file child class is located in\r
- *\r
- * @return void\r
- * @uses $definitechild if a match is made between a parent class and parameter\r
- * $class in file $file, then definitechild is set here\r
- * @uses getParentClass() to find the parent class\r
- */\r
- function setClassParent($class,$file)\r
- {\r
- if (is_array($par = $this->getParentClass($class, $file))) {\r
- // (for debugging)\r
- // phpDocumentor_out("$file class $class extends "\r
- // . $par[1] ." file ". $par[0] . "\n");\r
-\r
- $this->classesbyfile[$file][$class]->setParent($par[1], $par[0], $this);\r
- $this->definitechild[$par[1]][$par[0]][$class] = $file;\r
- } else {\r
- $this->classesbyfile[$file][$class]->setParentNoClass($par);\r
- }\r
- }\r
- \r
- /**\r
- * Main processing engine for setting up class inheritance.\r
- *\r
- * This function uses {@link $roots} to traverse the inheritance tree via\r
- * {@link processChild()} and returns the data structures\r
- * phpDocumentor_IntermediateParser needs to convert parsed data\r
- * to output using {@link phpDocumentor_IntermediateParser::Convert()}\r
- *\r
- * @param phpDocumentor_IntermediateParser &$render the renderer object\r
- *\r
- * @return void\r
- * @uses processChild() set up inheritance\r
- * @todo CS Cleanup - rename to "inherit" for CamelCaps naming standard\r
- */\r
- function Inherit(&$render)\r
- {\r
- phpDocumentor_out("\nProcessing Class Inheritance\n\n");\r
- flush();\r
- phpDocumentor_out("\nProcessing Root Trees\n\n");\r
- flush();\r
- foreach ($this->roots as $class => $files) {\r
- for ($i=0; $i<count($files); $i++) {\r
- $this->processChild($render, $class, $files[$i]);\r
- }\r
- }\r
- if (0)\r
- foreach ($this->classesbyfile as $i => $j) {\r
- foreach ($j as $k => $m) {\r
- var_dump($i, $k);\r
- if ($i == 'iConverter') {\r
- var_dump($j);\r
- }\r
- }\r
- }\r
- phpDocumentor_out("\nProcessing leftover classes "\r
- . "(classes that extend root classes not found in the same package)\n");\r
- flush();\r
- foreach ($this->classesbyfile as $i => $j) {\r
- foreach ($j as $k => $m) {\r
- $this->processChild($render, $k, $i, true);\r
- }\r
- }\r
- phpDocumentor_out("done processing leftover classes\n");\r
- flush();\r
- $this->setupClassConflicts();\r
- }\r
- \r
- /**\r
- * Transfers actual conflicts from {@link $potentialClassconflicts} to\r
- * {@link $classconflicts}\r
- *\r
- * @return void\r
- * @access private\r
- * @uses $potentialclassconflicts transfers values to {@link $classconflicts}\r
- */\r
- function setupClassConflicts()\r
- {\r
- foreach ($this->potentialclassconflicts as $class => $paths) {\r
- if (count($paths) - 1) { //conflict\r
- $package = array();\r
- foreach ($paths as $path) {\r
- // create a list of conflicting classes in each package\r
- if (isset($this->classpathpackages[$class][$path]))\r
- $package[$this->classpathpackages[$class][$path][0]][] = $path;\r
- }\r
- foreach ($package as $pathpackages) {\r
- /*\r
- * if at least 2 functions exist in the same package, \r
- * delete all but the first one and add warnings\r
- */\r
- if (count($pathpackages) - 1) {\r
- for ($i=1; $i < count($pathpackages); $i++) {\r
- if (isset($this->classesbyfile[$pathpackages[$i]])) {\r
- addWarning(PDERROR_ELEMENT_IGNORED, \r
- 'class', $class, $pathpackages[$i]);\r
- $this->killClass($class, $pathpackages[$i]);\r
- $oth = array_flip($paths);\r
- unset($paths[$oth[$pathpackages[$i]]]);\r
- }\r
- }\r
- }\r
- }\r
- $this->classconflicts[$class] = $paths;\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * If a package contains two classes with the same name, this function finds\r
- * that conflict\r
- *\r
- * Returns the {@link $classconflicts} entry for class $class, minus its own path\r
- *\r
- * @param mixed $class the class name to search for\r
- *\r
- * @return mixed returns false if no conflicts, \r
- * or an array of paths containing conflicts\r
- */\r
- function getConflicts($class)\r
- {\r
- if (!isset($this->classconflicts[$class])) return false;\r
- $a = array();\r
- foreach ($this->classconflicts[$class] as $conflict) {\r
- $a[$this->classesbyfile[$conflict][$class]->docblock->package] \r
- = $this->classesbyfile[$conflict][$class];\r
- }\r
- return $a;\r
- }\r
- \r
- /**\r
- * sets up {@link $killclass} for use by Converter::checkKillClass()\r
- *\r
- * @param mixed $class the class\r
- * @param mixed $path the path\r
- *\r
- * @return void\r
- * @access private\r
- */\r
- function killClass($class,$path)\r
- {\r
- $this->killclass[$class][$path] = true;\r
- }\r
- \r
- /**\r
- * This function recursively climbs up the class tree, setting inherited\r
- * information like package and adds the elements to \r
- * {@link phpDocumentor_IntermediateParser}.\r
- *\r
- * Using structures defined in {@link Classes}, \r
- * the function first sets package information,\r
- * and then seeks out child classes.\r
- * It uses 3 tests to determine whether a class is a child class.\r
- * <ol>\r
- * <li>child class is in the same file as the parent class \r
- * and extends parent class\r
- * </li>\r
- * <li>child class is in a different file and specifies \r
- * the parent's @package in its docblock\r
- * </li>\r
- * <li>child class is in a different file and is in a \r
- * different @package, with one possible parent class\r
- * </li>\r
- * </ol>\r
- *\r
- * @param phpDocumentor_IntermediateParser &$render the renderer object\r
- * @param string $class class to process\r
- * @param string $file name of file $class \r
- * is located in\r
- * @param boolean $furb flag used privately\r
- * to control informational\r
- * output while parsing\r
- * (used when processing \r
- * leftover classes in \r
- * {@link Inherit()}\r
- *\r
- * @return void\r
- * @global string default package, usually "default"\r
- */\r
- function processChild(&$render,$class,$file,$furb = false)\r
- {\r
- global $phpDocumentor_DefaultPackageName;\r
- if (isset($this->classesbyfile[$file][$class]->processed))\r
- return;\r
- $this->potentialclassconflicts[$class][] = $file;\r
- if ($furb)\r
- phpDocumentor_out("Processing $class in file $file\n");\r
- flush();\r
- $this->classesbyfile[$file][$class]->processed = true;\r
-\r
- $db = $this->classesbyfile[$file][$class];\r
- $render->addUses($db, $file);\r
- if (!$render->parsePrivate) {\r
- /*\r
- * if this class has an @access private, \r
- * and parse private is disabled, remove it\r
- */\r
- if ($db->docblock->hasaccess) {\r
- $aaa = $db->docblock->getKeyword('access');\r
- if (is_object($aaa) && $aaa->getString() == 'private') {\r
- if (isset($this->varsbyfile[$file]) \r
- && isset($this->varsbyfile[$file][$class])) {\r
- unset($this->varsbyfile[$file][$class]);\r
- }\r
- if (isset($this->methodsbyfile[$file]) \r
- && isset($this->methodsbyfile[$file][$class])) {\r
- unset($this->methodsbyfile[$file][$class]);\r
- }\r
- if (isset($this->constsbyfile[$file]) \r
- && isset($this->constsbyfile[$file][$class])) {\r
- unset($this->constsbyfile[$file][$class]);\r
- }\r
- $this->classesbyfile[$file][$class]->ignore = true;\r
- // if this is a root class, remove it from the roots array\r
- if (isset($this->roots[$class])) {\r
- foreach ($this->roots[$class] as $i => $files) {\r
- // find the file key and unset\r
- if ($files == $file) \r
- unset($this->roots[$class][$i]);\r
- }\r
- }\r
- /*\r
- * if this is a child, remove it from the list \r
- * of child classes of its parent\r
- */\r
- if ($db->getExtends()) \r
- unset($this->classchildrenbyfile[$db->getExtends()][$file]);\r
- return;\r
- }\r
- }\r
- }\r
- if ($render->packageoutput) {\r
- if (!in_array($db->docblock->package, $render->packageoutput)) {\r
- if (isset($this->varsbyfile[$file]) \r
- && isset($this->varsbyfile[$file][$class])) {\r
- unset($this->varsbyfile[$file][$class]);\r
- }\r
- if (isset($this->methodsbyfile[$file]) \r
- && isset($this->methodsbyfile[$file][$class])) {\r
- unset($this->methodsbyfile[$file][$class]);\r
- }\r
- if (isset($this->constsbyfile[$file]) \r
- && isset($this->constsbyfile[$file][$class])) {\r
- unset($this->constsbyfile[$file][$class]);\r
- }\r
- $this->classesbyfile[$file][$class]->ignore = true;\r
- if (isset($this->roots[$class])) {\r
- foreach ($this->roots[$class] as $i => $files) {\r
- if ($files == $file) unset($this->roots[$class][$i]);\r
- }\r
- }\r
- if ($db->getExtends()) \r
- unset($this->classchildrenbyfile[$db->getExtends()][$file]);\r
- return;\r
- }\r
- }\r
- $this->setClassParent($class, $file);\r
- $db = $this->classesbyfile[$file][$class];\r
- if ($furb && !is_array($db->parent)) {\r
- // debug("furb adding $class $file to roots");\r
- $this->specialRoots[$db->parent][] = array($class, $file);\r
- }\r
- // fix for 591396\r
- if (!$db->docblock->getExplicitPackage()) {\r
- $a = $render->proceduralpages->pagepackages[$file];\r
- if ($a[0] != $phpDocumentor_DefaultPackageName) {\r
- // inherit page package\r
- $this->classesbyfile[$file][$class]->docblock->package = $a[0];\r
- }\r
- }\r
- if ($this->classesbyfile[$file][$class]->docblock->package \r
- == $render->proceduralpages->pagepackages[$file][0]) {\r
- if ($this->classesbyfile[$file][$class]->docblock->subpackage == '') {\r
- $this->classesbyfile[$file][$class]->docblock->subpackage \r
- = $render->proceduralpages->pagepackages[$file][1];\r
- }\r
- }\r
- $db = $this->classesbyfile[$file][$class];\r
- $render->addPackageParent($db);\r
- $render->addPageIfNecessary($file, $db);\r
- if ($access = $db->docblock->getKeyword('access')) {\r
- if (!is_string($access) && is_object($access)) \r
- $access = $access->getString();\r
- if (!is_string($access)) \r
- $access = 'public';\r
- if (($access == 'private') && (!$render->parsePrivate)) {\r
- if (isset($this->varsbyfile[$file]) \r
- && isset($this->varsbyfile[$file][$class])) {\r
- foreach ($this->varsbyfile[$file][$class] as $i => $vr) {\r
- $vr->docblock->addKeyword('access', 'private');\r
- $this->varsbyfile[$file][$class][$i] = $vr;\r
- }\r
- }\r
- if (isset($this->methodsbyfile[$file]) \r
- && isset($this->methodsbyfile[$file][$class])) {\r
- foreach ($this->methodsbyfile[$file][$class] as $i => $vr) {\r
- $vr->docblock->addKeyword('access', 'private');\r
- $this->methodsbyfile[$file][$class][$i] = $vr;\r
- }\r
- }\r
- if (isset($this->constsbyfile[$file]) \r
- && isset($this->constsbyfile[$file][$class])) {\r
- foreach ($this->constsbyfile[$file][$class] as $i => $vr) {\r
- $vr->docblock->addKeyword('access', 'private');\r
- $this->constsbyfile[$file][$class][$i] = $vr;\r
- }\r
- }\r
- }\r
- }\r
- $this->classpathpackages[$class][$file] \r
- = array($db->docblock->package,$db->docblock->subpackage);\r
- if ($db->docblock->getExplicitPackage()) {\r
- $render->proceduralpages->\r
- addClassPackageToFile($file, \r
- $db->docblock->package, $db->docblock->subpackage);\r
- }\r
- $render->addElementToPage($db, $file);\r
- if (isset($this->varsbyfile[$file]) \r
- && isset($this->varsbyfile[$file][$class])) {\r
- foreach ($this->varsbyfile[$file][$class] as $i => $vr) {\r
- $vr->docblock->package = $db->docblock->package;\r
- $vr->docblock->subpackage = $db->docblock->subpackage;\r
- $render->addElementToPage($vr, $file);\r
- $render->addUses($vr, $file);\r
- $this->varsbyfile[$file][$class][$i] = $vr;\r
- $this->vars[$db->docblock->package][$class][$vr->getName()] = $vr;\r
- }\r
- }\r
- if (isset($this->methodsbyfile[$file]) \r
- && isset($this->methodsbyfile[$file][$class])) {\r
- foreach ($this->methodsbyfile[$file][$class] as $i => $vr) {\r
- $vr->docblock->package = $db->docblock->package;\r
- $vr->docblock->subpackage = $db->docblock->subpackage;\r
- $render->addElementToPage($vr, $file);\r
- $render->addUses($vr, $file);\r
- $this->methodsbyfile[$file][$class][$i] = $vr;\r
- $this->methods[$db->docblock->package][$class][$vr->getName()] = $vr;\r
- }\r
- }\r
- if (isset($this->constsbyfile[$file]) \r
- && isset($this->constsbyfile[$file][$class])) {\r
- foreach ($this->constsbyfile[$file][$class] as $i => $vr) {\r
- $vr->docblock->package = $db->docblock->package;\r
- $vr->docblock->subpackage = $db->docblock->subpackage;\r
- $render->addElementToPage($vr, $file);\r
- $render->addUses($vr, $file);\r
- $this->constsbyfile[$file][$class][$i] = $vr;\r
- $this->methods[$db->docblock->package][$class][$vr->getName()] = $vr;\r
- }\r
- }\r
- $this->classpackages[$class][] \r
- = array($db->docblock->package,$db->docblock->subpackage);\r
- if (is_array($db->parent))\r
- $this->classparents[$db->docblock->package][$class] = $db->parent[1];\r
- else\r
- $this->classparents[$db->docblock->package][$class] = $db->getExtends();\r
- if (is_array($db->parent)) {\r
- $z = $this->getClass($db->parent[1], $db->parent[0]);\r
-\r
- $this->classchildren[$z->docblock->package][$db->parent[1]][] = $db;\r
- }\r
- if (isset($this->classchildrenbyfile[$class])) {\r
- foreach ($this->classchildrenbyfile[$class] as $childfile => $other) {\r
- // test 1, inherits in same file (must be same package)\r
- if ($childfile == $file) {\r
- foreach ($other as $child => $packages) {\r
- // debug("parent $class same file $child");\r
- $this->processChild($render, $child, $childfile);\r
- $x = $this->getClass($child, $childfile);\r
- if ($x->docblock->package \r
- != $GLOBALS['phpDocumentor_DefaultPackageName']) {\r
- // child package need root for class trees\r
- if ($x->docblock->package != $db->docblock->package) {\r
- // debug("adding $child in $childfile 1");\r
- $this->roots[$child][] = $childfile;\r
- }\r
- }\r
- }\r
- } else {\r
- // test 2, different file, same package\r
- foreach ($other as $child => $packages) {\r
- for ($j=0; $j<count($packages); $j++) {\r
- if ($this->classesbyfile[$file][$class]->\r
- docblock->package == $packages[$j]) {\r
- $this->processChild($render, $child, $childfile);\r
- // debug("$childfile diff file $child, parent $class,\r
- // same package ".$packages[$j]);\r
- } else {\r
- /*\r
- * test 3, different file, different package, \r
- * only 1 parent is possible\r
- */\r
- if (isset($this->classesbynamefile[$child])) {\r
- // 1 possible parent\r
- if (count($this->classesbynamefile[$class]) \r
- == 1) {\r
- // debug("$childfile diff file $child, \r
- // diff package, \r
- // 1 possible parent root $class");\r
- $this->processChild($render, \r
- $child, $childfile);\r
- $x = $this->getClass($child, $childfile);\r
- if ($x->docblock->package \r
- != $GLOBALS\r
- ['phpDocumentor_DefaultPackageName']) {\r
- // child package need root \r
- //for class trees\r
- if ($x->docblock->package \r
- != $db->docblock->package) {\r
- // debug("adding roots \r
- // $child in $childfile 2");\r
- $this->roots[$child][] = $childfile;\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * Get the parserClass representation of a class from its name and file\r
- *\r
- * @param string $class classname\r
- * @param string $file file classname is located in\r
- *\r
- * @return parserClass\r
- */\r
- function &getClass($class, $file)\r
- {\r
- // debug("getClass called with class $class file $file");\r
- return $this->classesbyfile[$file][$class];\r
- }\r
- \r
- /**\r
- * Used by {@link parserData::getClasses()} \r
- * to retrieve classes defined in file $path\r
- *\r
- * retrieves the array entry from {@link $classesbyfile} for $path\r
- *\r
- * @param string $path full path to filename\r
- *\r
- * @return mixed returns false if no classes defined in the file, \r
- * otherwise returns an array of {@link parserClass}es\r
- */\r
- function getClassesInPath($path)\r
- {\r
- if (!isset($this->classesbyfile[$path])) return false;\r
- return $this->classesbyfile[$path];\r
- }\r
- \r
- /**\r
- * called by {@link parserClass::hasMethods()}. Should not be directly called\r
- *\r
- * @param string $file file classname is located in\r
- * @param string $class classname\r
- *\r
- * @return bool\r
- * @access private\r
- */\r
- function hasMethods($file, $class)\r
- {\r
- return isset($this->methodsbyfile[$file][$class]);\r
- }\r
- \r
- /**\r
- * called by {@link parserClass::hasConsts()}. \r
- * Should not be directly called\r
- *\r
- * @param string $file file classname is located in\r
- * @param string $class classname\r
- *\r
- * @return bool\r
- * @access private\r
- */\r
- function hasConsts($file,$class)\r
- {\r
- return isset($this->constsbyfile[$file][$class]);\r
- }\r
- \r
- /**\r
- * called by {@link parserClass::hasVars()}. Should not be directly called\r
- *\r
- * @param string $file file classname is located in\r
- * @param string $class classname\r
- *\r
- * @return bool\r
- * @access private\r
- */\r
- function hasVars($file, $class)\r
- {\r
- return isset($this->varsbyfile[$file][$class]);\r
- }\r
- \r
- /**\r
- * called by {@link parserClass::hasMethod()}. Should not be directly called\r
- *\r
- * @param string $class classname\r
- * @param string $file file classname is located in\r
- * @param string $name method name\r
- *\r
- * @return bool\r
- * @access private\r
- */\r
- function hasMethod($class, $file, $name)\r
- {\r
- if (!$this->hasMethods($file, $class)) return false;\r
- for ($i=0; $i<count($this->methodsbyfile[$file][$class]); $i++) {\r
- if ($this->methodsbyfile[$file][$class][$i]->getName() == $name) \r
- return true;\r
- }\r
- return false;\r
- }\r
- \r
- /**\r
- * called by {@link parserClass::hasVar()}. Should not be directly called\r
- *\r
- * @param string $class classname\r
- * @param string $file file classname is located in\r
- * @param string $name var name\r
- *\r
- * @return bool\r
- * @access private\r
- */\r
- function hasVar($class, $file, $name)\r
- {\r
- if (!$this->hasVars($file, $class)) return false;\r
- for ($i=0; $i<count($this->varsbyfile[$file][$class]); $i++) {\r
- if ($this->varsbyfile[$file][$class][$i]->getName() == $name) \r
- return true;\r
- }\r
- return false;\r
- }\r
- \r
- /**\r
- * called by {@link parserClass::hasConst()}. Should not be directly called\r
- *\r
- * @param string $class classname\r
- * @param string $file file classname is located in\r
- * @param string $name constant name\r
- *\r
- * @return bool\r
- * @access private\r
- */\r
- function hasConst($class, $file, $name)\r
- {\r
- if (!$this->hasConsts($file, $class)) return false;\r
- for ($i=0; $i<count($this->constsbyfile[$file][$class]); $i++) {\r
- if ($this->constsbyfile[$file][$class][$i]->getName() == $name) \r
- return true;\r
- }\r
- return false;\r
- }\r
- \r
- /**\r
- * called by {@link parserClass::getMethods()}. Should not be directly called\r
- *\r
- * @param string $class classname\r
- * @param string $file file classname is located in\r
- *\r
- * @return mixed\r
- * @access private\r
- */\r
- function &getMethods($class, $file)\r
- {\r
- if (!isset($this->methodsbyfile[$file][$class])) {\r
- $flag = false;\r
- return $flag;\r
- }\r
- return $this->methodsbyfile[$file][$class];\r
- }\r
- \r
- /**\r
- * called by {@link parserClass::getVars()}. Should not be directly called\r
- *\r
- * @param string $class classname\r
- * @param string $file file classname is located in\r
- *\r
- * @return mixed\r
- * @access private\r
- */\r
- function &getVars($class, $file)\r
- {\r
- if (!isset($this->varsbyfile[$file][$class])) {\r
- $flag = false;\r
- return $flag;\r
- }\r
- return $this->varsbyfile[$file][$class];\r
- }\r
- \r
- /**\r
- * called by {@link parserClass::getConsts()}. Should not be directly called\r
- *\r
- * @param string $class classname\r
- * @param string $file file classname is located in\r
- *\r
- * @return mixed\r
- * @access private\r
- */\r
- function &getConsts($class, $file)\r
- {\r
- if (!isset($this->constsbyfile[$file][$class])) {\r
- $flag = false;\r
- return $flag;\r
- }\r
- return $this->constsbyfile[$file][$class];\r
- }\r
- \r
- /**\r
- * called by {@link parserClass::getMethod()}. Should not be directly called\r
- *\r
- * @param string $class classname\r
- * @param string $file file classname is located in\r
- * @param string $name method name\r
- *\r
- * @return mixed\r
- * @access private\r
- */\r
- function getMethod($class, $file, $name)\r
- {\r
- if (!$this->hasMethod($class, $file, $name)) return false;\r
- for ($i=0; $i<count($this->methodsbyfile[$file][$class]); $i++) {\r
- if ($this->methodsbyfile[$file][$class][$i]->getName() == $name) \r
- return $this->methodsbyfile[$file][$class][$i];\r
- }\r
- }\r
- \r
- /**\r
- * called by {@link parserClass::getVar()}. Should not be directly called\r
- *\r
- * @param string $class classname\r
- * @param string $file file classname is located in\r
- * @param string $name var name\r
- *\r
- * @return mixed\r
- * @access private\r
- */\r
- function getVar($class, $file, $name)\r
- {\r
- if (!$this->hasVar($class, $file, $name)) return false;\r
- for ($i=0; $i<count($this->varsbyfile[$file][$class]); $i++) {\r
- if ($this->varsbyfile[$file][$class][$i]->getName() == $name) \r
- return $this->varsbyfile[$file][$class][$i];\r
- }\r
- }\r
- \r
- /**\r
- * called by {@link parserClass::getConst()}. Should not be directly called\r
- *\r
- * @param string $class classname\r
- * @param string $file file classname is located in\r
- * @param string $name const name\r
- *\r
- * @return mixed\r
- * @access private\r
- */\r
- function getConst($class, $file, $name)\r
- {\r
- if (!$this->hasConst($class, $file, $name)) return false;\r
- for ($i=0; $i<count($this->constsbyfile[$file][$class]); $i++) {\r
- if ($this->constsbyfile[$file][$class][$i]->getName() == $name) \r
- return $this->constsbyfile[$file][$class][$i];\r
- }\r
- }\r
- \r
- /**\r
- * Search for a class in a package\r
- *\r
- * @param string $class classname\r
- * @param string $package package classname is in\r
- *\r
- * @return mixed returns false if no class in $package, \r
- * otherwise returns a {@link parserClass}\r
- */\r
- function &getClassByPackage($class, $package)\r
- {\r
- if (!isset($this->classesbynamefile[$class])) {\r
- // removed, too many warnings, not very useful\r
- // addWarning(PDERROR_CLASS_NOT_IN_PACKAGE,$class,$package); \r
-\r
- $flag = false;\r
- return $flag;\r
- }\r
- for ($i=0; $i < count($this->classesbynamefile[$class]); $i++) {\r
- $cls = \r
- $this->classesbyfile[$this->classesbynamefile[$class][$i]][$class];\r
- $pkg = $cls->getPackage();\r
- if ($pkg == $package)\r
- return $cls;\r
- }\r
- // addWarning(PDERROR_CLASS_NOT_IN_PACKAGE,$class,$package);\r
-\r
- $flag = false;\r
- return $flag;\r
- }\r
- \r
- /**\r
- * Find the parent class of a class in file $file\r
- * uses 3 tests to find the parent classname:\r
- * <ol>\r
- * <li>only one class with the parent classname</li>\r
- * <li>more than one class, but only one in the same file as the child</li>\r
- * <li>only one parent class in the same package as the child</li>\r
- * </ol>\r
- *\r
- * @param string $class classname\r
- * @param string $file file classname is located in\r
- *\r
- * @return mixed false if no parent class, \r
- * a string if no parent class found by that name,\r
- * and an array(file parentclass is in, parentclassname)\r
- */\r
- function getParentClass($class,$file)\r
- {\r
- if (!isset($this->classesbyfile[$file][$class])) {\r
- return false;\r
- }\r
- $element = $this->classesbyfile[$file][$class];\r
- if (!($ex = $element->getExtends())) return false;\r
- // first check to see if there is one and only one \r
- // class with the parent class's name\r
- if (isset($this->classesbynamefile[$ex])) {\r
- if (count($this->classesbynamefile[$ex]) == 1) {\r
- if ($this->classesbyfile\r
- [$this->classesbynamefile[$ex][0]][$ex]->ignore) {\r
- return $ex;\r
- }\r
- return array($this->classesbynamefile[$ex][0],$ex);\r
- } else {\r
- // next check to see if there is a parent class in the same file\r
- if (isset($this->classesbyfile[$file][$ex])) {\r
- if ($this->classesbyfile[$file][$ex]->ignore) {\r
- return $ex;\r
- }\r
- return array($file,$ex);\r
- }\r
- // next check to see if there is only one package \r
- // used in the file, try to resolve it that way\r
- if (isset($this->classpackagebyfile[$file])) {\r
- if (count($this->classpackagebyfile[$file]) == 1) {\r
- for ($i=0;$i<count($this->classesbynamefile[$ex]);$i++) {\r
- if ($this->classesbyfile\r
- [$this->classesbynamefile[$ex][$i]][$ex]->getPackage() \r
- == $this->classpackagebyfile[$file][0]) {\r
- if ($this->classesbyfile\r
- [$this->classesbynamefile[$ex][$i]][$ex]->ignore) \r
- return $ex;\r
- return array($this->classesbynamefile[$ex][$i],$ex);\r
- }\r
- }\r
- }\r
- }\r
- // name conflict\r
- addWarning(PDERROR_INHERITANCE_CONFLICT, $class, $file, $ex);\r
- return $ex;\r
- }\r
- } else {\r
- if (class_exists('ReflectionClass') && class_exists($ex)) {\r
- $r = new ReflectionClass($ex);\r
- if ($r->isInternal()) {\r
- return $ex; // no warning\r
- }\r
- }\r
- addWarning(PDERROR_PARENT_NOT_FOUND, $class, $ex);\r
- return $ex;\r
- }\r
- }\r
- \r
- /**\r
- * Get a list of all root classes indexed by package. Used to generate\r
- * class trees by {@link Converter}\r
- *\r
- * @param boolean $all [since phpDocumentor 1.3.0RC6] determines whether to\r
- * return class trees that extend non-parsed classes\r
- *\r
- * @return array array(package => array(rootclassname, rootclassname,...),...)\r
- */\r
- function getRoots($all = false)\r
- {\r
- $roots = array();\r
- $temproots = $this->roots;\r
- if (!$all) {\r
- foreach ($this->specialRoots as $package => $root) {\r
- foreach ($root as $parent => $info) {\r
- $temproots[$info[0]][] = $info[1];\r
- }\r
- }\r
- }\r
- foreach ($temproots as $class => $files) {\r
- if (count($files)) {\r
- foreach ($files as $i => $boofou) {\r
- $x = $this->getClass($class, $files[$i]);\r
-\r
- $roots[$x->getPackage()][] = $class;\r
- }\r
- }\r
- }\r
- foreach ($roots as $package => $root) {\r
- usort($roots[$package], "strnatcasecmp");\r
- }\r
- if ($all) {\r
- $specialRoots = array();\r
- foreach ($this->specialRoots as $parent => $classinfo) {\r
- if (count($classinfo)) {\r
- foreach ($classinfo as $i => $info) {\r
- $x = $this->getClass($info[0], $info[1]);\r
-\r
- $specialRoots[$x->getPackage()][$parent][] = $info[0];\r
- }\r
- }\r
- }\r
- foreach ($specialRoots as $package => $root) {\r
- uksort($specialRoots[$package], "strnatcasecmp");\r
- foreach ($specialRoots[$package] as $parent => $classes) {\r
- usort($specialRoots[$package][$parent], 'strnatcasecmp');\r
- }\r
- }\r
- return array('special' => $specialRoots, 'normal' => $roots);\r
- }\r
- return $roots;\r
- }\r
- \r
- /**\r
- * Get all classes confirmed in parsing \r
- * to be descended class $parclass in file $file\r
- *\r
- * @param string $parclass name of parent class\r
- * @param string $file file parent class is found in\r
- *\r
- * @return mixed either false if no children, or array of format\r
- * array(childname => childfile,childname2 => childfile2,...)\r
- * @see parserClass::getChildClassList()\r
- * @uses $definitechild\r
- */\r
- function getDefiniteChildren($parclass, $file)\r
- {\r
- if (isset($this->definitechild[$parclass][$file])) \r
- return $this->definitechild[$parclass][$file];\r
- return false;\r
- }\r
-}\r
-?>\r