home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 August / PCWorld_2001-08_cd.bin / Komunikace / phptriad / phptriadsetup2-11.exe / php / pear / PHPDoc / parser / PhpdocUseParser.php < prev    next >
PHP Script  |  2001-02-18  |  3KB  |  78 lines

  1. <?php
  2. /**
  3. * Extracts use statements (include and friends) an thheir documentation from php code.
  4. *
  5. * @author   Ulf Wendel <ulf.wendel@redsys.de>
  6. * @version  $Id: PhpdocUseParser.php,v 1.2 2001/02/18 14:45:28 uw Exp $
  7. */
  8. class PhpdocUseParser extends PhpdocParserCore {
  9.  
  10.     /**
  11.     * Structure of an empty use entry.
  12.     *
  13.     * @var  array
  14.     */
  15.     var $emptyUse = array(
  16.                             "type"  => "",
  17.                             "file"  => "",
  18.                             "undoc" => true
  19.                     );
  20.                                             
  21.  
  22.     /**
  23.     * List of allowed tags in use doc comments.
  24.     *
  25.     * @var  array
  26.     */
  27.     var $useTags = array(
  28.                             "return"        => true,
  29.                             
  30.                             "see"           => true,
  31.                             "link"          => true,
  32.                             
  33.                             "authhor"       => true,
  34.                             "copyright"     => true,
  35.                             
  36.                             "version"       => true,
  37.                             "since"         => true,
  38.                             
  39.                             "deprecated"    => true,
  40.                             "deprec"        => true,
  41.                             
  42.                             "include"       => true,
  43.  
  44.                             "exclude"       => true,
  45.                             "magic"         => true,
  46.                             "todo"          => true
  47.                         );
  48.  
  49.     /**
  50.     * Takes the result from getPhpdocParagraphs() and interprets it.
  51.     *
  52.     * @param    array
  53.     */
  54.     function analyseUse($para) {
  55.         
  56.         $use = $this->emptyUse;
  57.         $use["file"] = $para["file"];
  58.         
  59.         if ("" != $para["doc"]) {
  60.         
  61.             $use = $this->analyseTags($this->getTags($para["doc"]), $use, $this->useTags);
  62.             
  63.             list($msg, $use) = $this->checkParserErrors($use, "use (include and friends)");
  64.             if ("" != $msg)
  65.                 $this->warn->addDocWarning($this->currentFile, "use", $use["file"], $msg, "mismatch");
  66.                 
  67.             list($use["sdesc"], $use["desc"]) = $this->getDescription($para["doc"]);
  68.             
  69.             $use["undoc"] = false;
  70.         }
  71.         
  72.         $use["type"] = $para["type"];
  73.  
  74.         return $use;
  75.     } // end func analyseUse
  76.     
  77. } // end class PhpdocUseParser
  78. ?>