+++ /dev/null
-<?php\r
-/**\r
- * Intermediate procedural page parsing structure.\r
- * This structure parses defines, functions, and global variables by file,\r
- * and then iterates over the elements to document conflicts.\r
- * \r
- * phpDocumentor :: automatic documentation generator\r
- * \r
- * PHP versions 4 and 5\r
- *\r
- * Copyright (c) 2002-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 Gregory Beaver <cellog@php.net>\r
- * @copyright 2002-2007 Gregory Beaver\r
- * @license http://www.opensource.org/licenses/lgpl-license.php LGPL\r
- * @version CVS: $Id: ProceduralPages.inc,v 1.8 2007/12/14 16:18:21 ashnazg Exp $\r
- * @link http://www.phpdoc.org\r
- * @link http://pear.php.net/PhpDocumentor\r
- * @since 1.1\r
- * @todo CS cleanup - change package to PhpDocumentor\r
- */\r
-\r
-/**\r
- * Intermediate procedural page parsing structure.\r
- * This structure parses defines, functions, and global variables by file,\r
- * and then iterates over the elements to document conflicts.\r
- *\r
- * @category ToolsAndUtilities\r
- * @package phpDocumentor\r
- * @author Greg Beaver <cellog@php.net>\r
- * @copyright 2002-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.1\r
- * @todo CS cleanup - change package to PhpDocumentor\r
- */\r
-class ProceduralPages\r
-{\r
- /**\r
- * file being parsed, used in every add function \r
- * to match up elements with the file that contains them\r
- *\r
- * @see addClass(), addMethod(), addVar(), nextFile()\r
- * @var string\r
- */\r
- var $curfile;\r
- /**\r
- * array of all procedural pages ordered by name\r
- * Format:\r
- * <pre>\r
- * array(\r
- * name => array(\r
- * fullpath => parserPage,\r
- * fullpath => parserPage2 [if there are name conflicts],\r
- * ...\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $pages = array();\r
- /**\r
- * array of all procedural pages ordered by name \r
- * that have been ignored via -po or @access private or @ignore\r
- * Format:\r
- * <pre>\r
- * array(\r
- * name => array(\r
- * fullpath => parserPage,\r
- * fullpath => parserPage2 [if there are name conflicts],\r
- * ...\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $ignorepages = array();\r
- /**\r
- * array of all procedural page names ordered by full path to the file\r
- * Format:\r
- * <pre>\r
- * array(\r
- * fullpath => name\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $pathpages = array();\r
- /**\r
- * array of parsed includes organized by the full path \r
- * of the file that contains the include.\r
- * Format:\r
- * <pre>\r
- * array(\r
- * full path => array(\r
- * includename => {@link parserInclude}\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $includesbyfile = array();\r
- /**\r
- * array of parsed functions organized by the full path \r
- * of the file that contains the function.\r
- * Format:\r
- * <pre>\r
- * array(\r
- * full path => array(\r
- * functionname => {@link parserFunction}\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $functionsbyfile = array();\r
- /**\r
- * array of parsed defines organized by the full path \r
- * of the file that contains the define.\r
- * Format:\r
- * <pre>\r
- * array(\r
- * full path => array(\r
- * definename => {@link parserDefine}\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $definesbyfile = array();\r
- /**\r
- * array of parsed global variables organized by the full path \r
- * of the file that contains the global variable definition.\r
- * Format:\r
- * <pre>\r
- * array(\r
- * full path => array(\r
- * globalname => {@link parserGlobal}\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $globalsbyfile = array();\r
- /**\r
- * array of file names organized by functions that are in the file.\r
- *\r
- * This structure is designed to handle name conflicts. Two files can contain\r
- * functions with the same name, and this array will record both filenames to\r
- * help control namespace errors\r
- * Format:\r
- * <pre>\r
- * array(\r
- * functionname => array(\r
- * full path of file containing functionname,\r
- * full path of file 2 containing functionname,\r
- * ...\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $functionsbynamefile = array();\r
- /**\r
- * array of file names organized by defines that are in the file.\r
- * This structure is designed to handle name conflicts. Two files \r
- * can contain defines with the same name, and this array will\r
- * record both filenames to help control namespace errors\r
- * Format:\r
- * <pre>\r
- * array(\r
- * definename => array(\r
- * full path of file containing definename,\r
- * full path of file 2 containing definename,\r
- * ...\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $definesbynamefile = array();\r
- /**\r
- * array of file names organized by global variables that are in the file.\r
- *\r
- * This structure is designed to handle name conflicts. Two files can \r
- * contain global variables with the same name, and this array will\r
- * record both filenames to help control namespace errors\r
- * Format:\r
- * <pre>\r
- * array(\r
- * global variablename => array(\r
- * full path of file containing global variablename,\r
- * full path of file 2 containing global variablename,\r
- * ...\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $globalsbynamefile = array();\r
- /**\r
- * array of packages ordered by full path\r
- * Format:\r
- * <pre>\r
- * array(\r
- * fullpath => array(\r
- * packagename,\r
- * subpackagename\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $pagepackages = array();\r
- /**\r
- * array of packages assigned to classes in a file, ordered by fullpath\r
- * Format:\r
- * <pre>\r
- * array(\r
- * fullpath => array(\r
- * packagename => array(\r
- * subpackagename => 1,\r
- * subpackagename => 1,\r
- * ..\r
- * ),\r
- * packagename2 => array(...\r
- * )\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $pageclasspackages = array();\r
- /**\r
- * Namespace conflicts within all documented packages of functions\r
- * Format:\r
- * <pre>\r
- * array(\r
- * functionname => array(\r
- * full path,\r
- * full path,\r
- * ...\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $functionconflicts = array();\r
- /**\r
- * Namespace conflicts within all documented pages\r
- * Format:\r
- * <pre>\r
- * array(\r
- * pagename => array(\r
- * fullpath,\r
- * fullpath,\r
- * ...\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $pageconflicts = array();\r
- /**\r
- * Namespace conflicts within all documented packages of functions\r
- * Format:\r
- * <pre>\r
- * array(\r
- * functionname => array(\r
- * full path,\r
- * full path,\r
- * ...\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $defineconflicts = array();\r
- /**\r
- * Namespace conflicts within all documented packages of functions\r
- * Format:\r
- * <pre>\r
- * array(\r
- * functionname => array(\r
- * full path,\r
- * full path,\r
- * ...\r
- * )\r
- * )\r
- * </pre>\r
- *\r
- * @var array\r
- */\r
- var $globalconflicts = array();\r
- /**\r
- * @access private\r
- * @var array\r
- */\r
- var $revcpbf = array();\r
- /**\r
- * @access private\r
- * @var boolean\r
- */\r
- var $packagesetup = false;\r
-\r
- /**\r
- * sets up the {@link $pages} array\r
- *\r
- * @param parserPage &$element the parser page element\r
- *\r
- * @return void\r
- */\r
- function addPage(&$element)\r
- {\r
- $this->curfile\r
- = $element->getPath();\r
- $this->pages[$element->getFile()][$element->getPath()]\r
- = $element;\r
- $this->pathpages[$this->curfile]\r
- = $element->getFile();\r
- $this->addPagePackage($this->curfile, \r
- $element->package, $element->subpackage);\r
- }\r
- \r
- /**\r
- * moves a page from the {@link $pages} array to the {@link $ignorepages} array\r
- *\r
- * @param parserPage &$element the parser page element\r
- *\r
- * @return void\r
- */\r
- function ignorePage(&$element)\r
- {\r
- $this->ignorepages[$element->getFile()][$element->getPath()]\r
- = $this->pages[$element->getFile()][$element->getPath()];\r
- unset($this->pages[$element->getFile()][$element->getPath()]);\r
- }\r
-\r
- /**\r
- * gathers path-related info about a given element\r
- *\r
- * @param string $path path to the element\r
- * @param mixed &$c ???\r
- *\r
- * @return array|bool an array of path info,\r
- * or FALSE \r
- * @todo figure out what &$c is and update the param tag\r
- */\r
- function getPathInfo($path, &$c)\r
- {\r
- $path = str_replace('/', SMART_PATH_DELIMITER, $path);\r
- $info = array();\r
- if (!isset($this->pathpages[$path])) {\r
- return false;\r
- }\r
-\r
- $p = $this->pages[$this->pathpages[$path]][$path];\r
- // fixes [ 1391432 ] Too many underscores in include links.\r
- $p->name = $p->origName;\r
- $p->name = $c->getPageName($p);\r
-\r
- $info['package'] = $p->package;\r
- $info['subpackage'] = $p->subpackage;\r
- $info['name'] = $p->getFile();\r
- $info['source_loc'] = $p->getSourceLocation($c);\r
-\r
- $x = new pageLink;\r
- $x->addLink($p->path, $p->name, $p->file, $p->package, $p->subpackage);\r
-\r
- $info['docs'] = $c->returnSee($x);\r
- $p->name = $p->origName;\r
-\r
- return $info;\r
- }\r
- \r
- /**\r
- * Change a page's name from its file to alias $name\r
- *\r
- * This function is used to handle a @name tag in a page-level DocBlock\r
- *\r
- * @param string $name the alias\r
- *\r
- * @return void\r
- */\r
- function setName($name)\r
- {\r
- if ($this->pages[$name][$this->curfile]->file == $name) {\r
- addWarning(PDERROR_NAME_ALIAS_SAME_AS_TARGET,'');\r
-\r
- } else {\r
- $this->pages[$name][$this->curfile]\r
- = $this->pages[$this->pathpages[$this->curfile]][$this->curfile];\r
- $this->pages[$name][$this->curfile]->file\r
- = $name;\r
-\r
- unset($this->pages[$this->pathpages[$this->curfile]][$this->curfile]);\r
-\r
- $this->pathpages[$this->curfile] = $name;\r
- }\r
- }\r
- \r
- /**\r
- * Changes the package of the page represented by $path\r
- *\r
- * changes package in both the {@link $pages} array \r
- * and the {@link pagepackages} array\r
- *\r
- * @param string $path full path\r
- * @param string $package the package name\r
- * @param string $subpackage the subpackage name\r
- *\r
- * @return void\r
- */\r
- function addPagePackage($path, $package, $subpackage)\r
- {\r
- $this->pages[$this->pathpages[$path]][$path]->package\r
- = $package;\r
- $this->pages[$this->pathpages[$path]][$path]->subpackage\r
- = $subpackage;\r
- $this->pagepackages[$path]\r
- = array($package, $subpackage);\r
-\r
- if (isset($this->includesbyfile[$path])) {\r
- foreach ($this->includesbyfile[$path] as $i => $el) {\r
- $el->package = $package;\r
- $el->subpackage = $subpackage;\r
- $this->includesbyfile[$path][$i] = $el;\r
- }\r
- }\r
- if (isset($this->functionsbyfile[$path])) {\r
- foreach ($this->functionsbyfile[$path] as $i => $el) {\r
- $el->package = $package;\r
- $el->subpackage = $subpackage;\r
- $this->functionsbyfile[$path][$i] = $el;\r
- }\r
- }\r
- if (isset($this->definesbyfile[$path])) {\r
- foreach ($this->definesbyfile[$path] as $i => $el) {\r
- $el->package = $package;\r
- $el->subpackage = $subpackage;\r
- $this->definesbyfile[$path][$i] = $el;\r
- }\r
- }\r
- if (isset($this->globalsbyfile[$path])) {\r
- foreach ($this->globalsbyfile[$path] as $i => $el) {\r
- $el->package = $package;\r
- $el->subpackage = $subpackage;\r
- $this->globalsbyfile[$path][$i] = $el;\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * sets up the {@link $includesbyfile} array using {@link $curfile}\r
- *\r
- * @param parserInclude &$element the "include" element object\r
- *\r
- * @return void\r
- */\r
- function addInclude(&$element)\r
- {\r
- $this->includesbyfile[$this->curfile][] = $element;\r
- }\r
-\r
- /**\r
- * sets up the {@link $functionsbyfile} array using {@link $curfile}\r
- *\r
- * @param parserFunction &$element the "function" object\r
- *\r
- * @return void\r
- */\r
- function addFunction(&$element)\r
- {\r
- if (isset($this->functionsbyfile[$this->curfile])) {\r
- foreach ($this->functionsbyfile[$this->curfile] as $i => $function) {\r
- if ($function->getName() == $element->getName()) {\r
- addWarning(PDERROR_ELEMENT_IGNORED, 'function',\r
- $element->getName(), $this->curfile);\r
- return;\r
- }\r
- }\r
- }\r
- $this->functionsbyfile[$this->curfile][] = $element;\r
- $this->functionsbynamefile[$element->getName()][] = $this->curfile;\r
- }\r
-\r
- /**\r
- * sets up the {@link $globalsbyfile} array using {@link $curfile}\r
- *\r
- * @param parserGlobal &$element the "global" element\r
- *\r
- * @return void\r
- */\r
- function addGlobal(&$element)\r
- {\r
- if (isset($this->globalsbyfile[$this->curfile])) {\r
- foreach ($this->globalsbyfile[$this->curfile] as $i => $global) {\r
- if ($global->getName() == $element->getName()) {\r
- addWarning(PDERROR_ELEMENT_IGNORED, 'global variable',\r
- $element->getName(), $this->curfile);\r
- return;\r
- }\r
- }\r
- }\r
- $this->globalsbyfile[$this->curfile][] = $element;\r
- $this->globalsbynamefile[$element->getName()][] = $this->curfile;\r
- }\r
-\r
- /**\r
- * sets up the {@link $definesbyfile} array using {@link $curfile}\r
- *\r
- * @param parserDefine &$element the "define" element\r
- *\r
- * @return void\r
- */\r
- function addDefine(&$element)\r
- {\r
- if (isset($this->definesbyfile[$this->curfile])) {\r
- foreach ($this->definesbyfile[$this->curfile] as $i => $define) {\r
- if ($define->getName() == $element->getName()) {\r
- addWarning(PDERROR_ELEMENT_IGNORED, 'define',\r
- $element->getName(), $this->curfile);\r
- return;\r
- }\r
- }\r
- }\r
- $this->definesbyfile[$this->curfile][] = $element;\r
- $this->definesbynamefile[$element->getName()][] = $this->curfile;\r
- }\r
- \r
- /**\r
- * Used to align an element with the package of its parent page \r
- * prior to Conversion.\r
- *\r
- * @param parserElement &$element the element to align\r
- *\r
- * @return void\r
- */\r
- function replaceElement(&$element)\r
- {\r
- if ($element->type == 'define') {\r
- foreach ($this->definesbyfile[$element->getPath()] as $i => $el) {\r
- if ($el->getName() == $element->getName()) {\r
- $this->definesbyfile[$element->getPath()][$i] = &$element;\r
- }\r
- }\r
- } elseif ($element->type == 'global') {\r
- foreach ($this->globalsbyfile[$element->getPath()] as $i => $el) {\r
- if ($el->getName() == $element->getName()) {\r
- $this->globalsbyfile[$element->getPath()][$i] = &$element;\r
- }\r
- }\r
- } elseif ($element->type == 'include') {\r
- foreach ($this->includesbyfile[$element->getPath()] as $i => $el) {\r
- if ($el->getName() == $element->getName()) {\r
- $this->includesbyfile[$element->getPath()][$i] = &$element;\r
- }\r
- }\r
- } elseif ($element->type == 'function') {\r
- foreach ($this->functionsbyfile[$element->getPath()] as $i => $el) {\r
- if ($el->getName() == $element->getName()) {\r
- $this->functionsbyfile[$element->getPath()][$i] = &$element;\r
- }\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * adds a package from a class to the current file\r
- *\r
- * @param string $file full path to the file that contains the class\r
- * @param string $package package name\r
- * @param string $subpackage subpackage name\r
- *\r
- * @return void\r
- */\r
- function addClassPackageToFile($file, $package, $subpackage)\r
- {\r
- if (!isset($this->revcpbf[$file][$package][$subpackage])) {\r
- $this->pageclasspackages[$file][$package][$subpackage] = 1;\r
- }\r
- $this->revcpbf[$file][$package][$subpackage] = 1;\r
- }\r
- \r
- /**\r
- * if there is one class package in a file, \r
- * the parent path inherits the package if its package is default.\r
- * helps with -po to avoid dumb bugs\r
- *\r
- * @return void\r
- */\r
- function setupPagePackages()\r
- {\r
- if ($this->packagesetup) {\r
- return;\r
- }\r
- foreach ($this->pageclasspackages as $fullpath => $packages) {\r
- if (isset($this->pagepackages[$fullpath])) {\r
- if ($this->pagepackages[$fullpath][0] \r
- == $GLOBALS['phpDocumentor_DefaultPackageName']\r
- ) {\r
- if (count($packages) == 1) {\r
- list($package, $subpackage) = each($packages);\r
- if (count($subpackage) == 1) {\r
- list($subpackage,) = each($subpackage);\r
- } else {\r
- $subpackage = '';\r
- }\r
- $this->addPagePackage($fullpath, $package, $subpackage);\r
- }\r
- }\r
- }\r
- }\r
- $this->packagesetup = true;\r
- }\r
- \r
- /**\r
- * extracts function, define, and global variable name conflicts within the \r
- * same package and between different packages. No two elements with the same\r
- * name are allowed in the same package, to keep automatic linking possible.\r
- *\r
- * @param mixed &$render the renderer object\r
- *\r
- * @return void\r
- * @access private\r
- * @todo functions, defines, and globals are coded,\r
- * but pages section is empty... does it need to be coded?\r
- */\r
- function setupConflicts(&$render)\r
- {\r
- foreach ($this->functionsbynamefile as $function => $paths) {\r
- if (count($paths) - 1) {\r
- //conflict\r
- $package = array();\r
- foreach ($paths as $path) {\r
- // create a list of conflicting functions in each package\r
- $package[$this->pagepackages[$path][0]][] = $path;\r
- }\r
- foreach ($package as $pathpackages) {\r
- // if at least 2 functions exist in the same package, \r
- // delete all but the first one and add warnings\r
- if (count($pathpackages) - 1) {\r
- for ($i=1; $i < count($pathpackages); $i++) {\r
- addWarning(PDERROR_ELEMENT_IGNORED, 'function',\r
- $function, $pathpackages[$i]);\r
- foreach ($this->functionsbyfile[$pathpackages[$i]] \r
- as $j => $blah\r
- ) {\r
- if ($this->functionsbyfile[$pathpackages[$i]][$j]\r
- ->getName() == $function\r
- ) {\r
- unset($this\r
- ->functionsbyfile[$pathpackages[$i]][$j]);\r
- }\r
- }\r
- $oth = array_flip($paths);\r
- unset($paths[$oth[$pathpackages[$i]]]);\r
- }\r
- }\r
- }\r
- $this->functionconflicts[$function] = $paths;\r
- }\r
- }\r
-\r
- foreach ($this->definesbynamefile as $define => $paths) {\r
- if (count($paths) - 1) { \r
- //conflict\r
- $package = array();\r
- foreach ($paths as $path) {\r
- // create a list of conflicting functions in each package\r
- $package[$this->pagepackages[$path][0]][] = $path;\r
- }\r
- foreach ($package as $pathpackages) {\r
- // if at least 2 functions exist in the same package, \r
- // delete all but the first one and add warnings\r
- if (count($pathpackages) - 1) {\r
- for ($i=1; $i < count($pathpackages); $i++) {\r
- addWarning(PDERROR_ELEMENT_IGNORED, 'define',\r
- $define, $pathpackages[$i]);\r
- foreach ($this->definesbyfile[$pathpackages[$i]]\r
- as $j => $blah\r
- ) {\r
- if ($this->definesbyfile[$pathpackages[$i]][$j]\r
- ->getName() == $define\r
- ) {\r
- unset($this\r
- ->definesbyfile[$pathpackages[$i]][$j]);\r
- }\r
- }\r
- $oth = array_flip($paths);\r
- unset($paths[$oth[$pathpackages[$i]]]);\r
- }\r
- }\r
- }\r
- $this->defineconflicts[$define] = $paths;\r
- }\r
- }\r
-\r
- foreach ($this->globalsbynamefile as $global => $paths) {\r
- if (count($paths) - 1) { \r
- //conflict\r
- $package = array();\r
- foreach ($paths as $path) {\r
- // create a list of conflicting functions in each package\r
- $package[$this->pagepackages[$path][0]][] = $path;\r
- }\r
- foreach ($package as $pathpackages) {\r
- // if at least 2 functions exist in the same package, \r
- // delete all but the first one and add warnings\r
- if (count($pathpackages) - 1) {\r
- for ($i=1; $i < count($pathpackages); $i++) {\r
- addWarning(PDERROR_ELEMENT_IGNORED, 'global variable',\r
- $global, $pathpackages[$i]);\r
- foreach ($this->globalsbyfile[$pathpackages[$i]] \r
- as $j => $blah\r
- ) {\r
- if ($this->globalsbyfile[$pathpackages[$i]][$j]\r
- ->getName() == $global\r
- ) {\r
- unset($this\r
- ->globalsbyfile[$pathpackages[$i]][$j]);\r
- }\r
- }\r
- $oth = array_flip($paths);\r
- unset($paths[$oth[$pathpackages[$i]]]);\r
- }\r
- }\r
- }\r
- $this->globalconflicts[$global] = $paths;\r
- }\r
- }\r
- \r
- /*\r
- * @todo does this section still need to be coded???\r
- */\r
- foreach ($this->pages as $name => $pages) {\r
- if (count($pages) - 1) { \r
- // possible conflict\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * called by {@link parserFunction::getConflicts()} to get \r
- * inter-package conflicts, should not be called directly\r
- *\r
- * @param string $name the function name to check\r
- *\r
- * @access private\r
- * @return array|bool Format: (package => {@link parserFunction} \r
- * of conflicting function)\r
- * or FALSE if the function is not recorded as a conflict\r
- */\r
- function getFuncConflicts($name)\r
- {\r
- if (!isset($this->functionconflicts[$name])) {\r
- return false;\r
- }\r
- $a = array();\r
- foreach ($this->functionconflicts[$name] as $conflict) {\r
- foreach ($this->functionsbyfile[$conflict] as $i => $func) {\r
- if ($func->getName() == $name) {\r
- $a[$this->functionsbyfile[$conflict][$i]->docblock->package] \r
- = $this->functionsbyfile[$conflict][$i];\r
- }\r
- }\r
- }\r
- return $a;\r
- }\r
- \r
- /**\r
- * called by {@link parserGlobal::getConflicts()} \r
- * to get inter-package conflicts, should not be called directly\r
- *\r
- * @param string $name the global name to check\r
- *\r
- * @access private\r
- * @return array|bool Format: (package => {@link parserGlobal} \r
- * of conflicting global variable)\r
- * or FALSE if the global is not recorded as a conflict\r
- */\r
- function getGlobalConflicts($name)\r
- {\r
- if (!isset($this->globalconflicts[$name])) {\r
- return false;\r
- }\r
- $a = array();\r
- foreach ($this->globalconflicts[$name] as $conflict) {\r
- foreach ($this->globalsbyfile[$conflict] as $i => $func) {\r
- if ($func->getName() == $name) {\r
- $a[$this->globalsbyfile[$conflict][$i]->docblock->package] \r
- = $this->globalsbyfile[$conflict][$i];\r
- }\r
- }\r
- }\r
- return $a;\r
- }\r
- \r
- /**\r
- * called by {@link parserDefine::getConflicts()} \r
- * to get inter-package conflicts, should not be called directly\r
- *\r
- * @param string $name the define name to check\r
- *\r
- * @access private\r
- * @return array|bool Format: (package => {@link parserDefine} \r
- * of conflicting define)\r
- * or FALSE if the define is not recorded as a conflict\r
- */\r
- function getDefineConflicts($name)\r
- {\r
- if (!isset($this->defineconflicts[$name])) {\r
- return false;\r
- }\r
- $a = array();\r
- foreach ($this->defineconflicts[$name] as $conflict) {\r
- foreach ($this->definesbyfile[$conflict] as $i => $func) {\r
- if ($func->getName() == $name) {\r
- $a[$this->definesbyfile[$conflict][$i]->docblock->package] \r
- = $this->definesbyfile[$conflict][$i];\r
- }\r
- }\r
- }\r
- return $a;\r
- }\r
- \r
- /**\r
- * Adjusts packages of all pages and removes name conflicts within a package\r
- *\r
- * Automatic linking requires that each linkable name have exactly one element \r
- * associated with it. In other words, there cannot be two functions named \r
- * foo() in the same package.\r
- *\r
- * This also adheres to php rules with one exception:\r
- *\r
- * <code>\r
- * if ($test == 3) {\r
- * define('whatever', 'this thing');\r
- * } else {\r
- * define('whatever', 'this other thing');\r
- * }\r
- * </code>\r
- *\r
- * phpDocumentor is not aware of conditional control structures because it \r
- * would slow things down considerably. So, what phpDocumentor does is \r
- * automatically ignore the second define and raise a warning. The warning can\r
- * be eliminated with an @ignore tag on the second element like so:\r
- *\r
- * <code>\r
- * if ($test == 3) {\r
- * define('whatever', 'this thing');\r
- * } else {\r
- * /**\r
- * * @ignore\r
- * {@*}\r
- * define('whatever', 'this other thing');\r
- * }\r
- * </code>\r
- *\r
- * If there are two files that contain the same procedural elements in the \r
- * same package (for example, a common configuration file common.php), they \r
- * will also be ignored as if they were in the same file. The reasoning\r
- * behind this is simple. A package is an indivisible set of files and \r
- * classes that a user will include in their code. Name conflicts must be \r
- * avoided to allow successful execution.\r
- *\r
- * This function also plays the all-important role of calling \r
- * {@link phpDocumentor_IntermediateParser::addElementToPage()} in order to add \r
- * processed elements to their pages for Conversion.\r
- *\r
- * @param phpDocumentor_IntermediateParser &$render the parser\r
- *\r
- * @return void\r
- */\r
- function setupPages(&$render)\r
- {\r
- global $_phpDocumentor_setting;\r
- phpDocumentor_out("\nProcessing Procedural Page Element Name Conflicts\n\n");\r
- flush();\r
- $this->setupPagePackages();\r
- $this->setupConflicts($render);\r
- // phpDocumentor_out("\nProcessing Procedural Pages\n\n");\r
- foreach ($this->pathpages as $path => $name) {\r
- // phpDocumentor_out("Processing $path\n");\r
- $a = $this->pagepackages[$path];\r
- $b = &$this->pages[$name][$path];\r
- $render->addPage($b, $path);\r
- $render->addUses($b, $path);\r
- if (isset($this->includesbyfile[$path])) {\r
- foreach ($this->includesbyfile[$path] as $include) {\r
- $include->docblock->package = $a[0];\r
- $include->docblock->subpackage = $a[1];\r
- $render->addElementToPage($include, $path);\r
- }\r
- }\r
- \r
- if (isset($this->functionsbyfile[$path])) {\r
- foreach ($this->functionsbyfile[$path] as $function) {\r
- $function->docblock->package = $a[0];\r
- $function->docblock->subpackage = $a[1];\r
- $render->addElementToPage($function, $path);\r
- $render->addUses($function, $path);\r
- }\r
- }\r
- \r
- if (isset($this->definesbyfile[$path])) {\r
- foreach ($this->definesbyfile[$path] as $define) {\r
- $define->docblock->package = $a[0];\r
- $define->docblock->subpackage = $a[1];\r
- $render->addElementToPage($define, $path);\r
- $render->addUses($define, $path);\r
- }\r
- }\r
- \r
- if (isset($this->globalsbyfile[$path])) {\r
- foreach ($this->globalsbyfile[$path] as $global) {\r
- $global->docblock->package = $a[0];\r
- $global->docblock->subpackage = $a[1];\r
- $render->addElementToPage($global, $path);\r
- $render->addUses($global, $path);\r
- }\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * sets the parser base\r
- *\r
- * @param mixed $pbase the parser base\r
- *\r
- * @return void\r
- */\r
- function setParseBase($pbase)\r
- {\r
- $this->_parsedbase = $pbase;\r
- }\r
- \r
- /**\r
- * checks to see if the parsed file matches the given path\r
- *\r
- * @param string $path the path to look for\r
- * @param string $infile the file to check\r
- *\r
- * @return parserPage|bool matched parserPage if found,\r
- * or FALSE if not found\r
- */\r
- function pathMatchesParsedFile($path, $infile)\r
- {\r
- $test = $this->getRealPath($path, $infile);\r
- if (is_string($test)) {\r
- if (isset($this->pathpages[$test])) {\r
- return $this->pages[$this->pathpages[$test]][$test];\r
- }\r
- if (PHPDOCUMENTOR_WINDOWS) {\r
- $test = str_replace('/', '\\', $test);\r
- }\r
- if (isset($this->pathpages[$test])) {\r
- $a = $this->pages[$this->pathpages[$test]][$test];\r
- if (is_array($a->packageOutput) \r
- && !in_array($a->package, $a->packageOutput)\r
- ) {\r
- return false;\r
- }\r
- return $this->pages[$this->pathpages[$test]][$test];\r
- }\r
- } else {\r
- foreach ($test as $file) {\r
- if (isset($this->pathpages[$file])) {\r
- return $this->pages[$this->pathpages[$file]][$file];\r
- }\r
- if (PHPDOCUMENTOR_WINDOWS) {\r
- $file = str_replace('/', '\\', $file);\r
- }\r
- if (isset($this->pathpages[$file])) {\r
- $a = $this->pages[$this->pathpages[$file]][$file];\r
- if (is_array($a->packageOutput) \r
- && !in_array($a->package, $a->packageOutput)\r
- ) {\r
- return false;\r
- }\r
- return $this->pages[$this->pathpages[$file]][$file];\r
- }\r
- }\r
- }\r
- return false;\r
- }\r
- \r
- /**\r
- * Ensures the path to the file is an absolute path\r
- * \r
- * @param string $path path to the file\r
- * @param string $file the file name\r
- *\r
- * @return array|string returns an array of possible file locations or\r
- * a string if there is an exact match\r
- */\r
- function getRealPath($path, $file)\r
- {\r
- $curdir = str_replace('\\', '/', dirname($file));\r
- $path = str_replace('\\', '/', $path);\r
- if (strpos($path, ':') !== false) {\r
- // windows, and we have a drive letter\r
- return $path;\r
- } elseif (strpos($path, '/') === 0) {\r
- return $path;\r
- }\r
- // not an absolute path\r
- $path = explode('/', $path);\r
- if ($path[0] == '.') {\r
- $path[0] = dirname($file);\r
- return join($path, '/');\r
- } elseif ($path[0] == '..') {\r
- $dirfile = explode('/', dirname(str_replace('\\', '/', $file)));\r
- // remove the current directory\r
- array_pop($dirfile); \r
- if (!count($dirfile)) {\r
- // we were at a top-level dir!\r
- return false;\r
- }\r
- // replace .. with parent dirname\r
- $path[0] = join($dirfile, '/');\r
- return join($path, '/');\r
- } else {\r
- $path = join($path, '/');\r
- return array($curdir . PATH_DELIMITER . $path,\r
- str_replace('\\', '/', PHPDOCUMENTOR_BASE)\r
- . PATH_DELIMITER . $path);\r
- }\r
- }\r
-}\r
-?>\r