Source for file DocBlockTags.inc
Documentation is available at DocBlockTags.inc
* All abstract representations of DocBlock tags are defined
* by the classes in this file
* 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
* @subpackage DocBlockTags
* @copyright 2002-2006 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version CVS: $Id: DocBlockTags.inc,v 1.8 2006/10/24 04:18:14 cellog Exp $
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* @see parserDocBlock, parserInclude, parserPage, parserClass
* @see parserDefine, parserFunction, parserMethod, parserVar
* @since separate file since version 1.2
* used to represent standard tags like @access, etc.
* This class is aware of inline tags, and will automatically handle them
* using inherited functions
* @subpackage DocBlockTags
* @version $Id: DocBlockTags.inc,v 1.8 2006/10/24 04:18:14 cellog Exp $
* Type is used by many functions to skip the hassle of if phpDocumentor_get_class($blah) == 'parserBlah'
* tag name (see, access, etc.)
* @param string $keyword tag name
* @param parserStringWithInlineTags $value
* @param boolean whether to parse the $value for html tags
function parserTag($keyword, $value, $noparse = false)
$parser->subscribe('*',$this);
$parser->parse($value->value,true,'parserstringwithinlinetags');
} else $this->value = $value;
$a = $val->Convert($converter);
foreach($this->value as $val)
// this is only true if we processed the description in
$result .= $converter->EncloseParagraph($val->Convert($converter));
$result .= $val->Convert($converter);
$a = $this->value->Convert($converter);
* Gets a count of the number of paragraphs in this
* Useful in determining whether to enclose the
* tag in a paragraph or not.
function _valueParagraphCount()
* Called by the {@link parserDescParser} when processing a description.
* @param integer not used
* @param array array of {@link parserStringWithInlineTags} representing
* paragraphs in the tag description
* @see parserTag::parserTag()
* @return string returns the text minus any inline tags
* @see parserStringWithInlineTags::getString()
foreach($this->value as $val)
$result .= $val->getString();
} else return $this->value->getString();
* This class represents the @name tag
* @tutorial tags.name.pkg
* @subpackage DocBlockTags
* @see parserStringWithInlineTags::Convert()
* @return string converted value of the tag
* This class represents the @access tag
* @tutorial tags.access.pkg
* @subpackage DocBlockTags
* set to true if the returned tag has a value type of private, protected
* or public, false otherwise
* checks $value to make sure it is private, protected or public, otherwise
* it's not a valid @access tag
* @param parserStringWithInlineTags $value
$value = $value->getString();
* @see parserStringWithInlineTags::Convert()
* @return string converted value of the tag
* No inline tags are possible, returns 'public', 'protected' or 'private'
* @return string returns the text minus any inline tags
* @tutorial tags.return.pkg
* @subpackage DocBlockTags
* @version $Id: DocBlockTags.inc,v 1.8 2006/10/24 04:18:14 cellog Exp $
* the type a function returns
* contains a link to the documentation for a class passed as a type in @return, @var or @param
* /** @return myclass blahblahblah
* In this case, $converted_returnType will contain a link to myclass instead of the string 'myclass'
* @var mixed either the same as $returnType or a link to the docs for a class
* @param parserStringWithInlineTags
* sets up $converted_returnType
* @see parserStringWithInlineTags::Convert(), $converted_returnType
* @return string converted value of the tag
foreach($types as $returntype)
$a = $converter->getLink($returntype);
if (!empty($my_types)) $my_types .= '|';
$my_types .= $converter->returnSee($a,$converter->type_adjust($returntype));
if (!empty($my_types)) $my_types .= '|';
$my_types .= $converter->type_adjust($returntype);
* @subpackage DocBlockTags
* @version $Id: DocBlockTags.inc,v 1.8 2006/10/24 04:18:14 cellog Exp $
* @tutorial tags.param.pkg
* @subpackage DocBlockTags
* Represents "@staticvar"
* @tutorial tags.staticvar.pkg
* @subpackage DocBlockTags
* @tutorial tags.link.pkg
* @subpackage DocBlockTags
* @version $Id: DocBlockTags.inc,v 1.8 2006/10/24 04:18:14 cellog Exp $
$start = $val = $link->getString();
* @subpackage DocBlockTags
* @version $Id: DocBlockTags.inc,v 1.8 2006/10/24 04:18:14 cellog Exp $
* @param string element to link to
* @see parserStringWithInlineTags::Convert()
if ($this->value->hasInlineTag())
$a = $converter->getLink(trim($this->value->Convert($converter)));
return $converter->returnLink($a,str_replace('PHP_MANUAL#','',$this->value->Convert($converter)));
if (is_object($a)) return $converter->returnSee($a);
// getLink parsed a comma-delimited list of linked thingies, add the commas back in
foreach($a as $i => $bub)
if (!empty($b)) $b .= ', ';
if (is_object($a[$i])) $b .= $converter->returnSee($a[$i]);
* Link to a license, instead of including lines and lines of license information
* @tutorial tags.license.pkg
* @subpackage DocBlockTags
$a = explode(' ',$link->getString());
if (empty($license)) $license = $url;
* This is exactly like @see except that the element used has a @useby link to this element added to its docblock
* @subpackage DocBlockTags
* @tutorial tags.uses.pkg
* @param string element to link to
* @param parserStringWithInlineTags description of how the element is used
if ($seeel->hasInlineTag()) {
$this->_description = $description;
* Return a link to documentation for other element, and description of how
* Works exactly like {@link parent::Convert()} except that it also includes
* a description of how the element used is used.
$this->value = $this->_description;
* Get the text of the link to the element that is being used
return $this->value->getString();
* Get the description of how the element used is being used.
* @return parserStringWithInlineTags
return $this->_description;
* This is a virtual tag, it is created by @uses to cross-reference the used element
* This is exactly like @uses.
* @subpackage DocBlockTags
* @param abstractLink link of element that uses this element
* @param string description of how the element is used
$this->value = $description;
$see = $c->returnSee($this->_link);
* This is exactly like @see except that it only links to tutorials
* @tutorial phpDocumentor/tutorials.pkg
* @tutorial tags.tutorial.pkg
* @subpackage DocBlockTags
* @see parserStringWithInlineTags::Convert()
$a = $converter->getTutorialLink(trim($this->value->Convert($converter)));
if (is_object($a)) return $converter->returnSee($a);
// getLink parsed a comma-delimited list of linked thingies, add the commas back in
foreach($a as $i => $bub)
if (!empty($b)) $b .= ', ';
if (is_object($a[$i])) $b .= $converter->returnSee($a[$i]);
* represents "@filesource"
* Use this to create a link to a highlighted phpxref-style source file listing
* @subpackage DocBlockTags
* @tutorial tags.filesource.pkg
* Flag variable, controls double writes of file for each converter
var $_converted = array();
* Set {@link $source} to $value, and set up path
* @param array output from {@link phpDocumentorTWordParser::getFileSource()}
* Return a link to the highlighted source and generate the source
* @uses ConvertSource() generate source code and write it out
* @return string output from {@link getSourceLink()}
* @uses phpDocumentor_HighlightParser highlights source code
$return = $parser->parse($this->source,$c, false, false, false, $this->path);
* @param string highlighted source code
* @uses Converter::writeSource() export highlighted file source
$c->writeSource($this->path, $source);
* @uses Converter::getSourceLink()
* @return output from getSourceLink()
return $c->getSourceLink($this->path);
* @subpackage DocBlockTags
* @tutorial tags.example.pkg
* Reads and parses the example file indicated
* The example tag takes one parameter: the full path to a php file that
* should be parsed and included as an example.
* @uses phpDocumentorTWordParser::getFileSource() uses to parse an example
* and retrieve all tokens by line number
* @param parserStringWithInlineTags
* @param string path of file containing this @example tag
parent::parserTag('example', $value);
// code thanks to Sam Blum, modified by Greg Beaver
$tagValue = $value->getString();
$path = $isAbsPath = $pathOnly = $fileName = $fileExt = $original_path = $title = FALSE;
// make sure the format is stuff.ext description
if (!preg_match('`(.*)\.(\w*)\s(.*)`', $tagValue, $match))
// or format is stuff.ext
if (!preg_match('`(.*)\.(\w*)\s*$`', $tagValue, $match))
// Murphy: Some funny path was given
$original_path = $tagValue; // used for error output
// Murphy: Some funny path was given
$original_path = $tagValue; // used for error output
$title = trim($match[3]);
$pathTmp = str_replace('\\', '/', $match[1]); // Replace windows '\' the path.
// Is there a path and a file or is it just a file?
if (strpos($pathTmp,'/') === false)
$fileName = $pathTmp . '.'. $fileExt;
$splitPos = strrpos($pathTmp,'/'); // split the path on the last directory, find the filename
$pathOnly = substr($match[1], 0, $splitPos+ 1);
$fileName = substr($match[1], $splitPos+ 1) . '.'. $fileExt;
// Is the path absolute? (i.e. does it start like an absolute path?)
if (('/' === $pathTmp[0]) || preg_match('`^\w*:`i', $pathTmp))
{ // works for both windows 'C:' and URLs like 'http://'
$isAbsPath = true; // Yes
$original_path = $pathOnly . $fileName;
// Now look for the file starting with abs. path.
$tmp = realpath($original_path); // remove any weirdities like /../file.ext
// Alway break if abs. path was detected; even if file was not found.
// Search for the example file some standard places
// 1) Look if the ini-var examplesdir is set and look there ...
if (isset ($_phpDocumentor_setting['examplesdir']))
$path = $tmp; // Yo! found it :)
// 2) Then try to look for an 'example/'-dir below the *currently* parsed file ...
if (!empty($current_path))
$path = $tmp; // Yo! found it :)
// 3) Then try to look for the example file below the subdir PHPDOCUMENTOR_BASE/examples/ ...
$path = $tmp; // Yo! found it :)
$path = $tmp; // Yo! found it :)
// If we reach this point, nothing was found and $path is false.
$this->_title = 'example not found';
$this->_title = ($title) ? $title : 'example';
// make a unique html-filename but avoid it to get too long.
$uniqueFileName = str_replace(array(':', DIRECTORY_SEPARATOR,'/'), array('_', '_', '_'), $path);
$uniqueFileName = substr($uniqueFileName,- 50) . '_' . md5($path);
$this->path = $uniqueFileName;
$this->source = $obj->getFileSource();
$this->origsource = $example;
* @uses phpDocumentor_HighlightParser highlights source code
null, null, null, $this->origsource));
$return = $parser->parse($this->source,$c);
* @param string parsed example source
* @uses Converter::writeExample() writes final example out
$c->writeExample($this->_title, $this->path, $source);
* Retrieve a converter-specific link to the example
* @uses Converter::getExampleLink() retrieve the link to the example
if (!$this->path) return $this->_title;
return $c->getExampleLink($this->path, $this->_title);
|