home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / PhpDocumentor / phpDocumentor / ParserData.inc < prev    next >
Encoding:
Text File  |  2008-07-02  |  26.5 KB  |  971 lines

  1. <?php
  2. /**
  3.  * Parser Data Structures
  4.  * 
  5.  * phpDocumentor :: automatic documentation generator
  6.  * 
  7.  * PHP versions 4 and 5
  8.  *
  9.  * Copyright (c) 2002-2008 Gregory Beaver
  10.  * 
  11.  * LICENSE:
  12.  * 
  13.  * This library is free software; you can redistribute it
  14.  * and/or modify it under the terms of the GNU Lesser General
  15.  * Public License as published by the Free Software Foundation;
  16.  * either version 2.1 of the License, or (at your option) any
  17.  * later version.
  18.  * 
  19.  * This library is distributed in the hope that it will be useful,
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  22.  * Lesser General Public License for more details.
  23.  * 
  24.  * You should have received a copy of the GNU Lesser General Public
  25.  * License along with this library; if not, write to the Free Software
  26.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27.  *
  28.  * @category   ToolsAndUtilities
  29.  * @package    phpDocumentor
  30.  * @subpackage ParserData
  31.  * @author     Gregory Beaver <cellog@php.net>
  32.  * @copyright  2002-2008 Gregory Beaver
  33.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  34.  * @version    CVS: $Id: ParserData.inc,v 1.9 2008/02/26 12:15:56 ashnazg Exp $
  35.  * @link       http://www.phpdoc.org
  36.  * @link       http://pear.php.net/PhpDocumentor
  37.  * @since      1.0rc1
  38.  * @todo       CS cleanup - change package to PhpDocumentor
  39.  */
  40.  
  41. /**
  42.  * Contains information about a PHP file, used to group procedural elements
  43.  * together.
  44.  *
  45.  * @category   ToolsAndUtilities
  46.  * @package    phpDocumentor
  47.  * @subpackage ParserData
  48.  * @author     Gregory Beaver <cellog@php.net>
  49.  * @copyright  2002-2008 Gregory Beaver
  50.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  51.  * @version    Release: 1.4.2
  52.  * @filesource
  53.  * @link       http://www.phpdoc.org
  54.  * @link       http://pear.php.net/PhpDocumentor
  55.  * @since      1.0rc1
  56.  * @todo       CS cleanup - change package to PhpDocumentor
  57.  * @todo       CS cleanup - change classname to PhpDocumentor_*
  58.  */
  59. class parserPage
  60. {
  61.     /**
  62.      * Type is used by many functions to skip the hassle of if
  63.      * <code>phpDocumentor_get_class($blah) == 'parserBlah'</code>
  64.      * @var string
  65.      */
  66.     var $type = 'page';
  67.     /**
  68.      * not implemented in this version, will be used to link xml output pages
  69.      * @var string
  70.      */
  71.     var $id = '';
  72.     /**
  73.      * filename.ext (no path)
  74.      * @var string
  75.      */
  76.     var $file = '';
  77.     /**
  78.      * relative source location
  79.      * @var string
  80.      */
  81.     var $sourceLocation = '';
  82.     /**
  83.      * phpdoc-safe name (only letters, numbers and _)
  84.      * @var string
  85.      */
  86.     var $name = '';
  87.     /**
  88.      * original phpdoc-safe name (only letters, numbers and _)
  89.      * 
  90.      * This fixes [ 1391432 ] Too many underscores in include links.
  91.      * @var string
  92.      */
  93.     var $origName = '';
  94.     /**
  95.      * @var string
  96.      */
  97.     var $category = 'default';
  98.     /**
  99.      * @var string
  100.      */
  101.     var $package = 'default';
  102.     /**
  103.      * @var string
  104.      */
  105.     var $subpackage = '';
  106.     /**
  107.      * @var string
  108.      */
  109.     var $parserVersion = PHPDOCUMENTOR_VER;
  110.     /**
  111.      * not implemented yet
  112.      * file modification date, will be used for makefiles
  113.      * @var string
  114.      */
  115.     var $modDate = '';
  116.     /**
  117.      * @var string full path this page represents
  118.      */
  119.     var $path = '';
  120.     /**
  121.      * Tokenized source code of the file
  122.      * @var array
  123.      */
  124.     var $source = array();
  125.     /**
  126.      * Used to limit output, contains contents of --packageoutput commandline.
  127.      * Does not increase parsing time.  Use --ignore for that
  128.      * @see phpDocumentor_IntermediateParser::$packageoutput, 
  129.      *      Converter::$package_output
  130.      * @var mixed either false or an array of packages
  131.      */
  132.     var $packageOutput = false;
  133.     
  134.     /**
  135.      * sets package to default package
  136.      *
  137.      * @global string default package name
  138.      */
  139.     function parserPage()
  140.     {
  141.         global $phpDocumentor_DefaultPackageName;
  142.         $this->package = $GLOBALS['phpDocumentor_DefaultPackageName'];
  143.     }
  144.     
  145.     /**
  146.      * gets the tag type
  147.      *
  148.      * @return string always "page"
  149.      */
  150.     function getType()
  151.     {
  152.         return 'page';
  153.     }
  154.     
  155.     /**
  156.      * Sets the source code of the file for highlighting.
  157.      *
  158.      * PHP 4.3.0+ passes an array of tokenizer tokens by line number.  PHP
  159.      * 4.2.3- passes a string to be passed to {@link highlight_string()}
  160.      *
  161.      * @param string|array $source the token array/string
  162.      *
  163.      * @return void
  164.      */
  165.     function setSource($source)
  166.     {
  167.         $this->source = $source;
  168.     }
  169.     
  170.     /**
  171.      * Sets the name to display in documentation (can be an alias set with @name)
  172.      *
  173.      * @param string $file the file name
  174.      *
  175.      * @return void
  176.      */
  177.     function setFile($file)
  178.     {
  179.         $this->file = $file;
  180.     }
  181.     
  182.     /**
  183.      * gets the file name
  184.      *
  185.      * @return string|bool filename.ext or @name alias,
  186.      *                     or FALSE if it's not set
  187.      */
  188.     function getFile()
  189.     {
  190.         if (!isset($this->file)) {
  191.             return false;
  192.         }
  193.         return $this->file;
  194.     }
  195.     
  196.     /**
  197.      * sets the path to the file
  198.      *
  199.      * @param string $path full path to file
  200.      *
  201.      * @return void
  202.      */
  203.     function setPath($path)
  204.     {
  205.         // look for special windows case
  206.         if (SMART_PATH_DELIMITER === '\\') {
  207.             $this->path = strtr($path, '/', '\\');
  208.         } else {
  209.             $this->path = $path;
  210.         }
  211.     }
  212.     
  213.     /**
  214.      * gets the path
  215.      *
  216.      * @return string fully delimited path (OS-dependent format),
  217.      *                or FALSE if it's not set
  218.      */
  219.     function getPath()
  220.     {
  221.         if (!isset($this->path)) {
  222.             return false;
  223.         }
  224.         return $this->path;
  225.     }
  226.     
  227.     /**
  228.      * loads the package output array
  229.      *
  230.      * @param array $packages array of packages to display in documentation 
  231.      *                        (package1,package2,...)
  232.      *
  233.      * @return void
  234.      * @see phpDocumentor_IntermediateParser::$packageoutput
  235.      */
  236.     function setPackageOutput($packages)
  237.     {
  238.         $this->packageOutput = $packages;
  239.     }
  240.     
  241.     /**
  242.      * gets the package output array
  243.      *
  244.      * @return array array of packages (package1,package2,...)
  245.      * @see phpDocumentor_IntermediateParser::$packageoutput
  246.      */
  247.     function getPackageOutput()
  248.     {
  249.         return $this->packageOutput;
  250.     }
  251.     
  252.     /**
  253.      * sets the name
  254.      *
  255.      * @param string $name phpdoc-safe name (only _, numbers and letters) 
  256.      *                     set by Parser::parse()
  257.      *
  258.      * @return void
  259.      * @see Parser::parse()
  260.      */
  261.     function setName($name)
  262.     {
  263.         $this->origName = $name;
  264.         $this->name     = $name;
  265.     }
  266.     
  267.     /**
  268.      * gets the name
  269.      *
  270.      * @return string phpdoc-safe name (only _, numbers and letters),
  271.      *                or FALSE if it's not set
  272.      */
  273.     function getName()
  274.     {
  275.         if (!isset($this->name)) {
  276.             return false;
  277.         }
  278.         return $this->name;
  279.     }
  280.     
  281.     /**
  282.      * sets the source location
  283.      *
  284.      * @param string $source path of this file relative to program root
  285.      *
  286.      * @return void
  287.      */
  288.     function setSourceLocation($source)
  289.     {
  290.         $this->sourceLocation = $source;
  291.     }
  292.     
  293.     /**
  294.      * gets the source location
  295.      *
  296.      * @param Converter $c       the output converter
  297.      * @param bool      $pearize if this parameter is true, 
  298.      *                           it will truncate the source location 
  299.      *                           to the subdirectory of pear
  300.      *
  301.      * @return string path of this file relative to program root
  302.      * @todo determine if the str_replace in the 'pear/' ELSE branch should be
  303.      *       removed (see Documentation/tests/bug1574043.php).  It does NOT exist
  304.      *       in the similar function parserClass->getSourceLocation() in
  305.      *       ParserElements.inc.
  306.      */
  307.     function getSourceLocation ($c, $pearize = false)
  308.     {
  309.         global $_phpDocumentor_options;
  310.         if (!isset($this->sourceLocation)) {
  311.             $sl = false;   
  312.         } else {
  313.             $sl = $this->sourceLocation;
  314.             if ($pearize) {
  315.                 if (strpos($sl, 'pear/')) {
  316.                     $sl = substr($sl, strpos($sl, 'pear/') + 5);
  317.                 } else {
  318.                     $sl = str_replace($_phpDocumentor_options['Program_Root'] 
  319.                         . PATH_DELIMITER, '', $sl);
  320.                 }
  321.             }
  322.         }
  323.         return $sl;
  324.     }
  325.  
  326.     /**
  327.      * Not implemented in this version
  328.      *
  329.      * @return bool tell the parser whether to parse the file,
  330.      *              otherwise this function will retrieve the parsed data 
  331.      *              from external file
  332.      */
  333.     function getParseData()
  334.     {
  335.         return true;
  336.     }
  337. }
  338.  
  339. /**
  340.  * Contains an in-memory representation of all documentable elements
  341.  * ({@link parserPage}, {@link parserFunction}, {@link parserDefine},
  342.  * {@link parserInclude}, {@link parserClass}, {@link parserMethod},
  343.  * {@link parserVar}) and their DocBlocks ({@link parserDocBlock}).
  344.  *
  345.  * This class works in coordination with {@link phpDocumentor_IntermediateParser}
  346.  * to take output from {@link Parser::handleEvent()} and create indexes, links,
  347.  * and other assorted things (all documented in phpDocumentor_IntermediateParser
  348.  * and {@link Converter})
  349.  *
  350.  * @category   ToolsAndUtilities
  351.  * @package    phpDocumentor
  352.  * @subpackage ParserData
  353.  * @author     Gregory Beaver <cellog@php.net>
  354.  * @copyright  2002-2008 Gregory Beaver
  355.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  356.  * @version    Release: 1.4.2
  357.  * @filesource
  358.  * @link       http://www.phpdoc.org
  359.  * @link       http://pear.php.net/PhpDocumentor
  360.  * @since      1.0rc1
  361.  * @todo       CS cleanup - change package to PhpDocumentor
  362.  */
  363. class parserData
  364. {
  365.     /**
  366.      * {@link parserPage} element that is this parserData's parent, or false if
  367.      * not set.
  368.      * @var false|parserPage
  369.      */
  370.     var $parent = false;
  371.     /**
  372.      * array of parsed elements
  373.      * @var array
  374.      */
  375.     var $elements = array();
  376.     /**
  377.      * @var boolean
  378.      * @access private
  379.      */
  380.     var $_hasclasses = false;
  381.     /**
  382.      * @var boolean
  383.      * @access private
  384.      */
  385.     var $_hasinterfaces = false;
  386.     /**
  387.      * array of parsed elements with @access private
  388.      * @var array
  389.      */
  390.     var $privateelements = array();
  391.     /**
  392.      * array of parsed class elements
  393.      * @var array
  394.      */
  395.     var $classelements = array();
  396.     
  397.     /**
  398.      * @var parserTutorial|false
  399.      */
  400.     var $tutorial = false;
  401.     /**
  402.      * array of parsed class elements with @access private
  403.      * @var array
  404.      */
  405.     var $privateclasselements = array();
  406.     /**
  407.      * array of links descended from {@link abstractLink}
  408.      * @var array
  409.      * @see pageLink, defineLink, classLink, functionLink, methodLink, varLink
  410.      */
  411.     var $links = array();
  412.     /**
  413.      * used by {@link phpDocumentor_IntermediateParser::handleDocBlock()} to
  414.      * determine whether a docblock is a page-level docblock or not.  $clean is
  415.      * true as long as only 0 or 1 docblock has been parsed, and no element
  416.      * other than parserPage has been parsed
  417.      * @var boolean
  418.      */
  419.     var $clean = true;
  420.     /**
  421.      * DocBlock ({@link parserDocBlock}) for this page, or false if not set
  422.      * @var mixed
  423.      */
  424.     var $docblock = false;
  425.     /**
  426.      * Flag used to determine whether a page-level docblock is present
  427.      * @var boolean
  428.      * @access private
  429.      */
  430.     var $_explicitdocblock = false;
  431.     /**
  432.      * Type is used by many functions to skip the hassle of if
  433.      * <code>phpDocumentor_get_class($blah) == 'parserBlah'</code>
  434.      * always 'page', used in element indexing and conversion functions found in
  435.      * {@link Converter}
  436.      * @var string
  437.      */
  438.     var $type = 'page';
  439.     
  440.     /**
  441.      * add a new element to the tracking array
  442.      *
  443.      * @param parserElement &$element add a parsed element to the 
  444.      *                                {@link $elements} array,
  445.      *                                also sets {@link $clean} to false
  446.      *
  447.      * @return void
  448.      */
  449.     function addElement(&$element)
  450.     {
  451.         $element->setPath($this->parent->path);
  452.         if ($element->getType() == 'class' 
  453.             || $element->getType() == 'method' 
  454.             || $element->getType() == 'var'
  455.             || $element->getType() == 'const'
  456.         ) {
  457.             if ($element->getType() == 'class') {
  458.                 if ($element->isInterface()) {
  459.                     $this->_hasinterfaces = true;
  460.                 } else {
  461.                     $this->_hasclasses = true;
  462.                 }
  463.             }
  464.             $this->classelements[] = $element;
  465.         } else {
  466.             $this->elements[] = $element;
  467.         }
  468.         $this->clean = false;
  469.     }
  470.  
  471.     /**
  472.      * Does this package have interfaces?
  473.      *
  474.      * @return bool
  475.      */
  476.     function hasInterfaces()
  477.     {
  478.         return $this->_hasinterfaces;
  479.     }
  480.  
  481.     /**
  482.      * Does this package have classes?
  483.      *
  484.      * @return boolean
  485.      */
  486.     function hasClasses()
  487.     {
  488.         return $this->_hasclasses;
  489.     }
  490.  
  491.     /**
  492.      * adds a tutorial parser
  493.      *
  494.      * @param parserTutorial $t  a tutorial parser
  495.      * @param Converter      &$c the output converter
  496.      *
  497.      * @return void
  498.      */
  499.     function addTutorial($t, &$c)
  500.     {
  501.         $this->tutorial = new tutorialLink;
  502.         $this->tutorial->addLink('', $t->path, $t->name, $t->package, 
  503.             $t->subpackage, $t->getTitle($c));
  504.     }
  505.     
  506.     /**
  507.      * If this file has a tutorial associated with it, 
  508.      * returns a link to the tutorial.
  509.      *
  510.      * @return tutorialLink
  511.      */
  512.     function getTutorial()
  513.     {
  514.         return $this->tutorial;
  515.     }
  516.     
  517.     /**
  518.      * If the page-level DocBlock was present in the source, returns true
  519.      *
  520.      * @return bool
  521.      */
  522.     function hasExplicitDocBlock()
  523.     {
  524.         return $this->_explicitdocblock;
  525.     }
  526.     
  527.     /**
  528.      * Tells this page that its DocBlock was not implicit
  529.      *
  530.      * @return bool
  531.      */
  532.     function explicitDocBlock()
  533.     {
  534.         $this->_explicitdocblock = true;
  535.     }
  536.     
  537.     /**
  538.      * adds a link
  539.      *
  540.      * @param parserElement &$element       element to add a new link (descended from
  541.      *                                      {@link abstractLink}) to the
  542.      *                                      {@link $links} array
  543.      * @param string        $classorpackage classname for elements that are
  544.      *                                      class-based (this may be deprecated in
  545.      *                                      the future, as the classname should be
  546.      *                                      contained within the element.  if
  547.      *                                      $element is a page, this parameter is a
  548.      *                                      package name
  549.      * @param string        $subpackage     subpackage name for page elements
  550.      *
  551.      * @return string
  552.      */
  553.     function addLink(&$element, $classorpackage = '', $subpackage = '')
  554.     {
  555.         switch($element->type)
  556.         {
  557.         case 'function':
  558.                 $x = new functionLink;
  559.                 $x->addLink($this->parent->path, $this->parent->name, $element->name,
  560.                     $element->docblock->package, $element->docblock->subpackage);
  561.                 return $x;
  562.             break;
  563.         case 'define':
  564.                 $x = new defineLink;
  565.                 $x->addLink($this->parent->path, $this->parent->name, $element->name,
  566.                     $element->docblock->package, $element->docblock->subpackage);
  567.                 return $x;
  568.             break;
  569.         case 'global':
  570.                 $x = new globalLink;
  571.                 $x->addLink($this->parent->path, $this->parent->name, $element->name,
  572.                     $element->docblock->package, $element->docblock->subpackage);
  573.                 return $x;
  574.             break;
  575.         case 'class':
  576.                 $x = new classLink;
  577.                 $x->addLink($this->parent->path, $this->parent->name, $element->name,
  578.                     $element->docblock->package, $element->docblock->subpackage);
  579.                 return $x;
  580.             break;
  581.         case 'method':
  582.                 $x = new methodLink;
  583.                 $x->addLink($classorpackage, $this->parent->path, 
  584.                     $this->parent->name, $element->name, $element->docblock->package,
  585.                     $element->docblock->subpackage);
  586.                 return $x;
  587.             break;
  588.         case 'var':
  589.                 $x = new varLink;
  590.                 $x->addLink($classorpackage, $this->parent->path,
  591.                     $this->parent->name, $element->name, $element->docblock->package,
  592.                     $element->docblock->subpackage);
  593.                 return $x;
  594.             break;
  595.         case 'page':
  596.             if (empty($classorpackage)) {
  597.                     $classorpackage = $GLOBALS['phpDocumentor_DefaultPackageName'];
  598.             }
  599.                 $x = new pageLink;
  600.                 $x->addLink($element->path, $element->name, $element->file,
  601.                     $classorpackage, $subpackage);
  602.                 return $x;
  603.             break;
  604.         }
  605.     }
  606.     
  607.     /**
  608.      * returns a link
  609.      *
  610.      * @param Converter &$c   the output converter
  611.      * @param bool      $text a text flag
  612.      *
  613.      * @return string
  614.      */
  615.     function &getLink(&$c, $text = false)
  616.     {
  617.         $a = $c->getPageLink($this->parent->file, $this->docblock->package,
  618.             $this->parent->path, $text);
  619.         return $a;
  620.     }
  621.     
  622.     /**
  623.      * returns a list of all classes declared in a file
  624.      *
  625.      * @param Converter &$c output converter
  626.      *
  627.      * @return array Format: array(
  628.      *                           packagename => parserClass,
  629.      *                           packagename => parserClass,
  630.      *                           ...
  631.      *                       )
  632.      */
  633.     function getClasses(&$c)
  634.     {
  635.         $r  = $c->classes->getClassesInPath($this->parent->path);
  636.         $rr = array();
  637.         if ($r) {
  638.             foreach ($r as $class => $obj) {
  639.                 $rr[$obj->docblock->package][] = $obj;
  640.             }
  641.         }
  642.         return $rr;
  643.     }
  644.     
  645.     /**
  646.      * Get the output-safe filename (. changed to _)
  647.      *
  648.      * @return string
  649.      */
  650.     function getName()
  651.     {
  652.         if (isset($this->parent) && $this->parent) {
  653.             return $this->parent->getName();
  654.         }
  655.     }
  656.     
  657.     /**
  658.      * sets the parent
  659.      *
  660.      * @param parserPage &$parent parent element of this parsed data
  661.      *
  662.      * @return void
  663.      */
  664.     function setParent(&$parent)
  665.     {
  666.         $this->parent = $parent;
  667.     }
  668.     
  669.     /**
  670.      * checks if the element is "cleaned" already
  671.      *
  672.      * @return bool returns the value of {@link $clean}
  673.      */
  674.     function isClean()
  675.     {
  676.         return $this->clean;
  677.     }
  678.     
  679.     /**
  680.      * sets the docblock
  681.      *
  682.      * @param parserDocBlock &$docblock docblock element
  683.      *
  684.      * @return void
  685.      * @see parserDocBlock
  686.      */
  687.     function setDocBlock(&$docblock)
  688.     {
  689.         $this->docblock = $docblock;
  690.     }
  691. }
  692.  
  693. /**
  694.  * Base class for all elements
  695.  *
  696.  * @category   ToolsAndUtilities
  697.  * @package    phpDocumentor
  698.  * @subpackage ParserData
  699.  * @author     Gregory Beaver <cellog@php.net>
  700.  * @copyright  2002-2008 Gregory Beaver
  701.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  702.  * @version    Release: 1.4.2
  703.  * @filesource
  704.  * @link       http://www.phpdoc.org
  705.  * @link       http://pear.php.net/PhpDocumentor
  706.  * @since      1.0rc1
  707.  * @todo       CS cleanup - change package to PhpDocumentor
  708.  * @abstract
  709.  */
  710. class parserBase
  711. {
  712.     /**
  713.      * Type is used by many functions to skip the hassle of if 
  714.      * phpDocumentor_get_class($blah) == 'parserBlah'... always base
  715.      * @var string
  716.      */
  717.     var $type = 'base';
  718.     /**
  719.      * set to different things by its descendants
  720.      * @abstract
  721.      * @var mixed
  722.      */
  723.     var $value = false;
  724.  
  725.     /**
  726.      * gets the type
  727.      *
  728.      * @return string returns value of {@link $type}
  729.      */
  730.     function getType()
  731.     {
  732.         return $this->type;
  733.     }
  734.     
  735.     /**
  736.      * sets the given value
  737.      *
  738.      * @param mixed $value set the value of this element
  739.      *
  740.      * @return void
  741.      */
  742.     function setValue($value)
  743.     {
  744.         $this->value = $value;
  745.     }
  746.     
  747.     /**
  748.      * gets the value
  749.      *
  750.      * @return mixed get the value of this element (element-dependent)
  751.      */
  752.     function getValue()
  753.     {
  754.         return $this->value;
  755.     }
  756. }
  757.  
  758.  
  759. /**
  760.  * Used to represent strings that contain inline tags, 
  761.  * so that they can be properly parsed at link time
  762.  *
  763.  * @category   ToolsAndUtilities
  764.  * @package    phpDocumentor
  765.  * @subpackage ParserData
  766.  * @author     Gregory Beaver <cellog@php.net>
  767.  * @copyright  2002-2008 Gregory Beaver
  768.  * @license    http://www.opensource.org/licenses/lgpl-license.php LGPL
  769.  * @version    Release: 1.4.2
  770.  * @filesource
  771.  * @link       http://www.phpdoc.org
  772.  * @link       http://pear.php.net/PhpDocumentor
  773.  * @since      1.0rc1
  774.  * @todo       CS cleanup - change package to PhpDocumentor
  775.  */
  776. class parserStringWithInlineTags extends parserBase
  777. {
  778.     /**
  779.      * Type is used by many functions to skip the hassle of 
  780.      * if phpDocumentor_get_class($blah) == 'parserBlah'...
  781.      * always '_string'
  782.      * @var string
  783.      */
  784.     var $type = '_string';
  785.     /**
  786.      * @access private
  787.      */
  788.     var $cache = false;
  789.     /**
  790.      * array of strings and {@link parserInlineTag}s
  791.      * Format:
  792.      * array(string1,string2,parserInlineTag1,string3,parserInlineTag2,...)
  793.      * @var array
  794.      */
  795.     var $value = array();
  796.  
  797.     /**
  798.      * equivalent to the . operator ($a = $b . $c)
  799.      *
  800.      * @param mixed $stringOrInlineTag either a string or a {@link parserInlineTag}
  801.      *
  802.      * @return void
  803.      */
  804.     function add($stringOrInlineTag)
  805.     {
  806.         if (is_string($stringOrInlineTag)) {
  807.             if (!count($this->value)) {
  808.                 $this->value[] = $stringOrInlineTag;
  809.                 return;
  810.             }
  811.             if (is_string($this->value[count($this->value) - 1])) {
  812.                 $this->value[count($this->value) - 1] .= $stringOrInlineTag;
  813.                 return;
  814.             } else {
  815.                 $this->value[] = $stringOrInlineTag;
  816.                 return;
  817.             }
  818.         } else {
  819.             if (is_a($stringOrInlineTag, 'parserinlinetag') 
  820.                 && phpDocumentor_setup::checkIgnoreTag($stringOrInlineTag->
  821.                     inlinetype, true)
  822.             ) {
  823.                 return;
  824.             }
  825.             $this->value[] = $stringOrInlineTag;
  826.         }
  827.     }
  828.     
  829.     /**
  830.      * Determine whether the string contains any inline tags
  831.      *
  832.      * @return bool
  833.      * @tutorial inlinetags.pkg
  834.      */
  835.     function hasInlineTag()
  836.     {
  837.         for ($i=0; $i<count($this->value); $i++) {
  838.             if (is_a($this->value[$i], 'parserinlinetag')) {
  839.                 return true;
  840.             }
  841.         }
  842.         return false;
  843.     }
  844.     
  845.     /**
  846.      * Pass source code to any {@}source} tags contained within the string
  847.      * for later conversion.
  848.      *
  849.      * @param string|array $source source code ready to be highlighted
  850.      *
  851.      * @return void
  852.      */
  853.     function setSource($source)
  854.     {
  855.         for ($i=0; $i<count($this->value); $i++) {
  856.             if (phpDocumentor_get_class($this->value[$i]) == 'parsersourceinlinetag'
  857.             ) {
  858.                 $this->value[$i]->setSource($source);
  859.             }
  860.         }
  861.     }
  862.  
  863.     /**
  864.      * equivalent to trim(strlen($string))
  865.      *
  866.      * @return integer length of the string this object represents
  867.      */
  868.     function trimmedStrlen()
  869.     {
  870.         $a = 0;
  871.         for ($i=0; $i<count($this->value); $i++) {
  872.             if (is_string($this->value[$i])) {
  873.                 if ($i == 0) {
  874.                     $a += strlen(ltrim($this->value[$i]));
  875.                 } elseif ($i == count($this->value[$i]) - 1) {
  876.                     $a += strlen(chop($this->value[$i]));
  877.                 }
  878.             } else {
  879.                 $a += $this->value[$i]->Strlen();
  880.             }
  881.         }
  882.         return $a;
  883.     }
  884.     
  885.     /**
  886.      * return the string unconverted (all inline tags are taken out - this
  887.      * should only be used in pre-parsing to see if any other text
  888.      * is in the string)
  889.      *
  890.      * @param bool $trim whether to trim the string
  891.      *
  892.      * @return string trimmed value
  893.      * @uses parserInlineTag::getString() removes inline tag length, as it is
  894.      *       indeterminate until conversion.
  895.      */
  896.     function getString($trim = true)
  897.     {
  898.         $a = '';
  899.         for ($i=0; $i<count($this->value); $i++) {
  900.             if (is_string($this->value[$i])) {
  901.                 $a .= $this->value[$i];
  902.             } else {
  903.                 $a .= $this->value[$i]->getString();
  904.             }
  905.         }
  906.         if ($trim) {
  907.             $a = trim($a);
  908.         }
  909.         return $a;
  910.     }
  911.     
  912.     /**
  913.      * Use to convert the string to a real string 
  914.      * with all inline tags parsed and linked
  915.      *
  916.      * @param Converter &$converter  the output converter
  917.      * @param bool      $postprocess true if one needs to postprocess
  918.      * @param bool      $trim        false if the output should not be trimmed
  919.      *
  920.      * @return string
  921.      * @see Converter::returnSee()
  922.      * @todo CS cleanup - rename to convert for camelCase rule
  923.      */
  924.     function Convert(&$converter, $postprocess = true, $trim = true)
  925.     {
  926.         if ($this->cache) {
  927.             if ($converter->name == $this->cache['name'] 
  928.                 && $converter->outputformat == $this->cache['output'] 
  929.                 && $converter->checkState($this->cache['state']) 
  930.                 && $this->cache['postprocess'] === $postprocess
  931.             ) {
  932.                 return $this->cache['contents'];
  933.             }
  934.             if ($converter->name != $this->cache['name']) {
  935.                 $this->cache = false;
  936.             }
  937.         }
  938.         if (is_string($this->value)) {
  939.             return $this->value;
  940.         }
  941.         $a = '';
  942.         for ($i=0; $i<count($this->value); $i++) {
  943.             if (is_string($this->value[$i])) {
  944.                 if ($postprocess && !method_exists($converter, 'postProcess')) {
  945.                     var_dump('a', $converter);
  946.                 }
  947.                 if ($postprocess) {
  948.                     $a .= $converter->postProcess($this->value[$i]);
  949.                 } else {
  950.                     $a .= $this->value[$i];
  951.                 }
  952.             } else {
  953.                 $a .= $this->value[$i]->Convert($converter, $postprocess);
  954.             }
  955.         }
  956.         if ($trim) {
  957.             $a = trim($a);
  958.         }
  959.         $this->cache = array(
  960.             'name'        => $converter->name,
  961.             'output'      => $converter->outputformat, 
  962.             'contents'    => $a, 
  963.             'state'       => $converter->getState(), 
  964.             'postprocess' => $postprocess
  965.         );
  966.         return $a;
  967.     }
  968. }
  969.  
  970. ?>
  971.