Source for file InlineTags.inc
Documentation is available at InlineTags.inc
* All abstract representations of inline tags are in this file
* phpDocumentor :: automatic documentation generator
* Copyright (c) 2002-2008 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
* @category ToolsAndUtilities
* @author Gregory Beaver <cellog@php.net>
* @copyright 2002-2008 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* @since separate file since 1.2
* @todo CS cleanup - change package to PhpDocumentor
* Use this element to represent an {@}inline tag} like {@}link}
* @category ToolsAndUtilities
* @author Gregory Beaver <cellog@php.net>
* @copyright 2002-2008 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 1.5.0a1
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* @see parserStringWithInlineTags
* @tutorial inlinetags.pkg
* @todo CS cleanup - change package to PhpDocumentor
* @todo CS cleanup - change classname to PhpDocumentor_*
* Type is used by many functions to skip the hassle of
* if phpDocumentor_get_class($blah) == 'parserBlah'
* the name of the inline tag (like link)
* @param string $type tag type (example: link)
* @param string $value tag value (example: what to link to)
* @return integer length of the tag
* @todo CS cleanup - rename to strLen for camelCase rule
* always gets an empty string
* @return string always '', used by {@link Parser::handleDocBlock()} to
* calculate the short description of a DocBlock
* @see parserStringWithInlineTags::getString()
* @see parserStringWithInlineTags::trimmedStrlen()
* represents inline links
* @category ToolsAndUtilities
* @author Gregory Beaver <cellog@php.net>
* @copyright 2002-2008 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 1.5.0a1
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* @see parserStringWithInlineTags
* @tutorial tags.inlinelink.pkg
* @todo CS cleanup - change package to PhpDocumentor
* @todo CS cleanup - change classname to PhpDocumentor_*
* text to display in the link, can be different from the link for standard
* @param string $link stored in $value, see {@link parserBase::$value}
* @param string $text see {@link $linktext}
* calls the output conversion
* @param Converter &$c converter used to change the abstract link
* @return false|stringreturns the converted link or false
* if not converted successfully
* @todo CS cleanup - rename to convert for camelCase rule
foreach ($this->value as $text) {
* convert part of the tag
* @param Converter &$c the output converter
* @param string $value the tag value
* @todo CS cleanup - rename to convertPart for camelCase rule
if (strpos($value, '://') || (strpos($value, 'mailto:') === 0 )) {
$text = join(' ', $value);
|| (isset ($v[1 ]) && strlen($v[1 ])
&& $v[1 ] != '###commanana####'
$v[0 ] = $vsave . ' ' . $v[0 ];
$value = $c->getLink ($v[0 ]);
$descrip = join($v, ' ');
$descrip = str_replace('###commanana####', ',', $descrip);
$value = $c->getLink ($value);
return $c->returnLink ($value, $descrip ? $descrip :
$descrip = $c->type_adjust ($savevalue);
return $c->returnSee ($value, $descrip);
* Represents inline links to external tutorial documentation
* @category ToolsAndUtilities
* @author Gregory Beaver <cellog@php.net>
* @copyright 2002-2008 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 1.5.0a1
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* @see parserStringWithInlineTags
* @tutorial tags.inlinetutorial.pkg
* @todo CS cleanup - change package to PhpDocumentor
* @todo CS cleanup - change classname to PhpDocumentor_*
* @param string $link stored in $value, see {@link parserBase::$value}
* @param string $text see {@link $linktext}
* convert part of the tag
* @param Converter &$c converter used to change the abstract link
* @return mixed returns the converted link
* or false if not converted successfully
* @todo CS cleanup - rename to convert for camelCase rule
$value = $c->getTutorialLink ($v[0 ]);
$descrip = join($v, ' ');
$value = $c->getTutorialLink ($this->value);
foreach ($vals as $val) {
$value[] = $c->getTutorialLink ($v[0 ]);
$descrip[] = join($v, ' ');
$value[] = $c->getTutorialLink ($val);
return $c->returnSee ($value, $descrip);
* getLink parsed a comma-delimited list of linked thingies,
foreach ($value as $i => $bub) {
$a .= $c->returnSee ($value[$i], $descrip[$i]);
* represents inline source tag, used for function/method source
* @category ToolsAndUtilities
* @author Gregory Beaver <cellog@php.net>
* @copyright 2002-2008 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 1.5.0a1
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* @see parserStringWithInlineTags
* @tutorial tags.inlinesource.pkg
* @todo CS cleanup - change package to PhpDocumentor
* @todo CS cleanup - change classname to PhpDocumentor_*
* First line of source code to display
* @var '*'|integerIf '*' then the whole source will be used, otherwise
* the {@link $start} to $end line numbers will be displayed
* tokenized source organized by line numbers for php 4.3.0+, the old
* {@}source} tag used a string
/**#@+ @access private */
* @param string $value format "start [end]",
* where start and end are line numbers
* with the end line number optional
$this->start = (int) $match[1 ];
$this->start = (int) $match[1 ];
$this->end = (int) $match[2 ];
* only used to determine blank lines. {@}source} will not be blank, probably
* sets the source tag's value
* @param string|array$source source code
* @param string|bool $class class name if this is a method,
* if this is a method this will be true
$source = strstr($source, 'function');
* @param Converter &$c the output converter object
* @uses stringConvert() in PHP 4.2.3-, this method is used to convert
* @uses arrayConvert() in PHP 4.3.0+, this method is used to convert
* @todo CS cleanup - rename to convert for camelCase rule
* converter helper used in PHP 4.3.0+
* @param Converter &$c the output converter object
* @uses phpDocumentor_HighlightParser Parses the tokenized source
$start = $this->start - 1;
return $c->ProgramExample ($source, true , true , $this->_class, $start);
* converter helper used in PHP 4.2.3-
* @param Converter &$c the output converter object
* @uses Converter::unmangle() remove the extraneous stuff from
* {@link highlight_string()}
* @deprecated in favor of PHP 4.3.0+ {@link arrayConvert()}
$source = '<code>' . substr($source, strlen('<code><font color="#000000">
<font color="#0000CC"><?php </font>') - 1 );
$source = str_replace('} </font><font color="#0000CC">?></font>',
'}</font></code>', $source);
if ($this->start || ($this->end != '*')) {
$source = explode('<br />', $source);
$source = implode($source, '<br />');
$source = " <code>$source";
$source = " $source</code>";
$source = $c->unmangle ($source, $this->source);
* Represents the example inline tag, used to display an example file
* inside a docblock or tutorial
* @category ToolsAndUtilities
* @author Gregory Beaver <cellog@php.net>
* @copyright 2002-2008 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 1.5.0a1
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* @see parserStringWithInlineTags
* @tutorial tags.inlineexample.pkg
* @todo CS cleanup - change package to PhpDocumentor
* @todo CS cleanup - change classname to PhpDocumentor_*
* @param string $value format "filepath[ start [end]]"
* where start and end are line numbers
* with the end line number optional
* @param string $current_path full path to the current file,
* used to check relative directory locations
* @param bool $isTutorial if true, then this is in a tutorial
* @todo replace tokenizer_ext constant with TOKENIZER_EXT for CS rule
$tagValue = trim($value);
$path = $isAbsPath = $pathOnly = $fileName = $fileExt
= $original_path = $title = false;
// make sure the format is stuff.ext startline[ endline]
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
if (strlen($match[1 ]) === 0 ) {
// Murphy: Some funny path was given
$original_path = $tagValue; // used for error output
$this->start = (int) $lines[0 ];
$this->end = (int) $lines[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;
// split the path on the last directory, find the filename
$splitPos = strrpos($pathTmp, '/');
$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.
// 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'])) {
$tmp = realpath($_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.
* @param string|array$source source code
* @param string|bool $class class name if this is a method,
* if this is a method this will be true
* converter helper for PHP 4.3.0+
* @param Converter &$c output converter
* @uses phpDocumentor_HighlightParser Parses the tokenized source
$start = $this->start - 1;
return $c->exampleProgramExample ($source, true , true , $this->_class, $start);
* Return the source for the example file, enclosed in
* a <programlisting> tag to use in a tutorial
$source = join("\n", $source);
"<programlisting role=\"php\">
"\n]]>\n</programlisting>";
* Represents the inheritdoc inline tag, used by classes/methods/vars to inherit
* documentation from the parent class if possible
* @category ToolsAndUtilities
* @author Gregory Beaver <cellog@php.net>
* @copyright 2002-2008 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 1.5.0a1
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* @see parserStringWithInlineTags
* @tutorial tags.inlineinheritdoc.pkg
* @todo CS cleanup - change package to PhpDocumentor
* @todo CS cleanup - change classname to PhpDocumentor_*
* Does nothing, overrides parent constructor
* only sets a warning and returns empty
* @todo CS cleanup - rename to convert for camelCase rule
* Represents the inline {@}id} tag for tutorials
* @category ToolsAndUtilities
* @author Gregory Beaver <cellog@php.net>
* @copyright 2002-2008 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 1.5.0a1
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* @see parserStringWithInlineTags
* @tutorial tags.inlineid.pkg
* @todo CS cleanup - change package to PhpDocumentor
* @todo CS cleanup - change classname to PhpDocumentor_*
* subpackage of the {@}id}
* full name of the tutorial
* section/subsection name
* @param string $category category name
* @param string $package package name
* @param string $subpackage subpackage name
* @param string $tutorial tutorial name
* @param string $id section/subsection name
* @param Converter &$c output converter
* @uses Converter::getTutorialId() retrieve converter-specific ID
* @todo CS cleanup - rename to convert for camelCase rule
* Represents {@}toc} for table of contents generation in tutorials
* @category ToolsAndUtilities
* @author Gregory Beaver <cellog@php.net>
* @copyright 2002-2008 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 1.5.0a1
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
* @see parserStringWithInlineTags
* @tutorial tags.inlinetoc.pkg
* @todo CS cleanup - change package to PhpDocumentor
* @todo CS cleanup - change classname to PhpDocumentor_*
* 'link' => returnsee link,
* 'title' => from title tag
* full path to tutorial, used in conversion
* @param array $toc format:
* 'tag' => {@link parserXMLDocBookTag},
* 'id' => {@link parserIdInlineTag},
* 'title' => {@link parserXMLDocBookTag title}
* @param string $path the path
* 'tagname' => string name of tag,
* 'link' => {@link tutorialLink} to the tutorial,
* 'id' => converter specific tutorial ID from
* {@link Converter::getTutorialId()}
* 'title' => title of the tutorial)
* and returns the results as the table of contents
* @param Converter &$c converter object
* @uses Converter::getTutorialId() retrieve the tutorial ID for
* @uses Converter::formatTutorialTOC() passes an array of format:
* @todo CS cleanup - rename to convert for camelCase rule
if (isset ($this->toc) && is_array($this->toc)) {
foreach ($this->toc as $i => $toc) {
if (isset ($toc['title'])) {
$toc['tag']->setTitle ($toc['title']);
$newtoc[$i]['tagname'] = $toc['tag']->name;
if (!isset ($toc['title'])) {
$title = 'section '. $toc['id']->id;
$title = $toc['title']->Convert ($c);
$l->addLink ($toc['id']->id , $this->_path, basename($this->_path),
$toc['id']->package , $toc['id']->subpackage , strip_tags($title));
$newtoc[$i]['link'] = $c->returnSee ($l);
$newtoc[$i]['id'] = $c->getTutorialId ($toc['id']->package ,
$toc['id']->subpackage , basename($this->_path),
$toc['id']->id , $toc['id']->category );
$newtoc[$i]['title'] = $title;
return $c->formatTutorialTOC ($newtoc);
Documentation generated on Mon, 11 Mar 2019 15:50:27 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|