Source for file ParserData.inc
Documentation is available at ParserData.inc
* phpDocumentor :: automatic documentation generator
* Copyright (c) 2002-2006 Gregory Beaver
* This library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* @copyright 2002-2006 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version CVS: $Id: ParserData.inc,v 1.6 2006/10/23 04:02:46 cellog Exp $
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* Contains information about a PHP file, used to group procedural elements
* @version $Id: ParserData.inc,v 1.6 2006/10/23 04:02:46 cellog Exp $
* Type is used by many functions to skip the hassle of if
* <code>phpDocumentor_get_class($blah) == 'parserBlah'</code>
* not implemented in this version, will be used to link xml output pages
* relative source location
* phpdoc-safe name (only letters, numbers and _)
* original phpdoc-safe name (only letters, numbers and _)
* This fixes [ 1391432 ] Too many underscores in include links.
* file modification date, will be used for makefiles
* @var string full path this page represents
* Tokenized source code of the file
* Used to limit output, contains contents of --packageoutput commandline.
* Does not increase parsing time. Use --ignore for that
* @see phpDocumentor_IntermediateParser::$packageoutput, Converter::$package_output
* @var mixed either false or an array of packages
* sets package to default package
* @global string default package name
$this->package = $GLOBALS['phpDocumentor_DefaultPackageName'];
* @return string always "page"
* Sets the source code of the file for highlighting.
* PHP 4.3.0+ passes an array of tokenizer tokens by line number. PHP
* 4.2.3- passes a string to be passed to {@link highlight_string()}
* Sets the name to display in documentation (can be an alias set with @name)
* @return string filename.ext or @name alias
if (!isset ($this->file)) return false;
* @param string $path full path to file
// look for special windows case
* @return string fully delimited path (OS-dependent format)
if (!isset ($this->path)) return false;
* @param array $packages array of packages to display in documentation (package1,package2,...)
* @see phpDocumentor_IntermediateParser::$packageoutput
* @return array array of packages (package1,package2,...)
* @see phpDocumentor_IntermediateParser::$packageoutput
* @param string $name phpdoc-safe name (only _, numbers and letters) set by Parser::parse()
* @return string phpdoc-safe name (only _, numbers and letters)
if (!isset ($this->name)) return false;
* @param string $source path of this file relative to program root
* @param boolean if this parameter is true, it will truncate the source location to the
* @return string path of this file relative to program root
global $_phpDocumentor_options;
* Not implemented in this version
* @return boolean tell the parser whether to parse the file, otherwise
* this function will retrieve the parsed data from external file
* Contains an in-memory representation of all documentable elements
* ({@link parserPage}, {@link parserFunction}, {@link parserDefine},
* {@link parserInclude}, {@link parserClass}, {@link parserMethod},
* {@link parserVar}) and their DocBlocks ({@link parserDocBlock}).
* This class works in coordination with {@link phpDocumentor_IntermediateParser}
* to take output from {@link Parser::handleEvent()} and create indexes, links,
* and other assorted things (all documented in phpDocumentor_IntermediateParser
* @version $Id: ParserData.inc,v 1.6 2006/10/23 04:02:46 cellog Exp $
* {@link parserPage} element that is this parserData's parent, or false if
* array of parsed elements
var $_hasclasses = false;
var $_hasinterfaces = false;
* array of parsed elements with @access private
* array of parsed class elements
* @var parserTutorial|false
* array of parsed class elements with @access private
* array of links descended from {@link abstractLink}
* @see pageLink, defineLink, classLink, functionLink, methodLink, varLink
* used by {@link phpDocumentor_IntermediateParser::handleDocBlock()} to
* determine whether a docblock is a page-level docblock or not. $clean is
* true as long as only 0 or 1 docblock has been parsed, and no element
* other than parserPage has been parsed
* DocBlock ({@link parserDocBlock}) for this page, or false if not set
* Flag used to determine whether a page-level docblock is present
var $_explicitdocblock = false;
* Type is used by many functions to skip the hassle of if
* <code>phpDocumentor_get_class($blah) == 'parserBlah'</code>
* always 'page', used in element indexing and conversion functions found in
* @param parserElement add a parsed element to the {@link $elements} array,
* also sets {@link $clean} to false
$element->setPath($this->parent->path);
if ($element->getType() == 'class' || $element->getType() == 'method' || $element->getType() == 'var'
|| $element->getType() == 'const')
if ($element->getType() == 'class') {
if ($element->isInterface()) {
$this->_hasinterfaces = true;
$this->_hasclasses = true;
* Does this package have interfaces?
return $this->_hasinterfaces;
* Does this package have classes?
return $this->_hasclasses;
$this->tutorial->addLink('',$t->path,$t->name,$t->package,$t->subpackage,$t->getTitle($c));
* If this file has a tutorial associated with it, returns a link to the
* If the page-level DocBlock was present in the source, returns true
return $this->_explicitdocblock;
* Tells this page that its DocBlock was not implicit
$this->_explicitdocblock = true;
* @param parserElement element to add a new link (descended from
* {@link abstractLink})to the {@link $links} array
* @param string classname for elements that are class-based (this may be
* deprecated in the future, as the classname should be
* contained within the element. if $element is a page, this
* parameter is a package name
* @param string subpackage name for page elements
function addLink(&$element,$classorpackage = '', $subpackage = '')
$x->addLink($this->parent->path, $this->parent->name, $element->name, $element->docblock->package, $element->docblock->subpackage);
$x->addLink($this->parent->path, $this->parent->name, $element->name, $element->docblock->package, $element->docblock->subpackage);
$x->addLink($this->parent->path, $this->parent->name, $element->name, $element->docblock->package, $element->docblock->subpackage);
$x->addLink($this->parent->path, $this->parent->name, $element->name, $element->docblock->package, $element->docblock->subpackage);
$x->addLink($classorpackage, $this->parent->path, $this->parent->name, $element->name, $element->docblock->package, $element->docblock->subpackage);
$x->addLink($classorpackage, $this->parent->path, $this->parent->name, $element->name, $element->docblock->package, $element->docblock->subpackage);
if (empty($classorpackage)) $classorpackage = $GLOBALS['phpDocumentor_DefaultPackageName'];
$x->addLink($element->path,$element->name,$element->file,$classorpackage, $subpackage);
function &getLink(&$c, $text = false)
* returns a list of all classes declared in a file
* @return array Format: array(packagename => parserClass,packagename => parserClass,...)
$r = $c->classes->getClassesInPath($this->parent->path);
foreach($r as $class => $obj)
$rr[$obj->docblock->package][] = $obj;
* Get the output-safe filename (. changed to _)
return $this->parent->getName();
* @param parserPage parent element of this parsed data
* @return bool returns the value of {@link $clean}
* Base class for all elements
* @version $Id: ParserData.inc,v 1.6 2006/10/23 04:02:46 cellog Exp $
* Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
* set to different things by its descendants
* @return string returns value of {@link $type}
* @param mixed set the value of this element
* @return mixed get the value of this element (element-dependent)
* Used to represent strings that contain inline tags, so that they can be properly parsed at link time
* @version $Id: ParserData.inc,v 1.6 2006/10/23 04:02:46 cellog Exp $
* Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
* array of strings and {@link parserInlineTag}s
* array(string1,string2,parserInlineTag1,string3,parserInlineTag2,...)
* equivalent to the . operator ($a = $b . $c)
* @param mixed either a string or a {@link parserInlineTag}
function add($stringOrInlineTag)
$this->value[] = $stringOrInlineTag;
$this->value[] = $stringOrInlineTag;
$this->value[] = $stringOrInlineTag;
* Determine whether the string contains any inline tags
* @tutorial inlinetags.pkg
if (is_a($this->value[$i],'parserinlinetag')) return true;
* Pass source code to any {@}source} tags contained within the string
* @param string|arraysource code ready to be highlighted
$this->value[$i]->setSource($source);
* equivalent to trim(strlen($string))
* @return integer length of the string this object represents
$a += $this->value[$i]->Strlen();
* return the string unconverted (all inline tags are taken out - this
* should only be used in pre-parsing to see if any other text
* @uses parserInlineTag::getString() removes inline tag length, as it is
* indeterminate until conversion.
* @return string trimmed value
$a .= $this->value[$i]->getString();
if ($trim) $a = trim($a);
* Use to convert the string to a real string with all inline tags parsed and linked
* @see Converter::returnSee()
* @param boolean true if one needs to postprocess
* @param boolean false if the output should not be trimmed
function Convert(&$converter,$postprocess = true, $trim = true)
if ($converter->name == $this->cache['name'] && $converter->outputformat == $this->cache['output'] && $converter->checkState($this->cache['state']) && $this->cache['postprocess'] === $postprocess) return $this->cache['contents'];
if ($converter->name != $this->cache['name']) {
if ($postprocess) $a .= $converter->postProcess($this->value[$i]);
else $a .= $this->value[$i];
$a .= $this->value[$i]->Convert($converter, $postprocess);
$this->cache = array('name' => $converter->name,'output' => $converter->outputformat, 'contents' => $a, 'state' => $converter->getState(), 'postprocess' => $postprocess);
|