Pelzini

This is the code documentation for the Pelzini project

source of /processor/parser_file.php

Contains the ParserFile class
  1. <?php
  2. /*
  3. Copyright 2008 Josh Heidenreich
  4.  
  5. This file is part of Pelzini.
  6.  
  7. Pelzini is free software: you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation, either version 3 of the License, or
  10. (at your option) any later version.
  11.  
  12. Pelzini is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Pelzini. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20.  
  21. /**
  22.  * Contains the {@link ParserFile} class
  23.  *
  24.  * @package Parser model
  25.  * @author Josh Heidenreich
  26.  * @since 0.1
  27.  **/
  28.  
  29. /**
  30.  * Represents a file
  31.  **/
  32. class ParserFile extends CodeParserItem {
  33. public $name;
  34. public $description;
  35. public $namespace;
  36. public $functions;
  37. public $classes;
  38. public $constants;
  39. public $enumerations;
  40. public $source;
  41.  
  42. public function __construct()
  43. {
  44. parent::__construct();
  45.  
  46. $this->functions = array();
  47. $this->classes = array();
  48. $this->constants = array();
  49. $this->enumerations = array();
  50. $this->namespace = null;
  51. }
  52.  
  53.  
  54. /**
  55.   * Applies the contents of a doc-block to this element
  56.   *
  57.   * @param $text The content of the DocBlock
  58.   **/
  59. public function processSpecificDocblockTags($docblock_tags)
  60. {
  61. $this->description = htmlify_text(@$docblock_tags['@summary']);
  62. }
  63.  
  64.  
  65. /**
  66.   * Cascades Docblock tags into the children that do not have any tags, and then
  67.   * runs processTags() for all of the children items.
  68.   **/
  69. public function treeWalk($function_name, ParserItem $parent_item = null)
  70. {
  71. call_user_func($function_name, $this, $parent_item);
  72.  
  73. foreach ($this->classes as $item) {
  74. $item->treeWalk($function_name, $this);
  75. }
  76.  
  77. foreach ($this->functions as $item) {
  78. $item->treeWalk($function_name, $this);
  79. }
  80.  
  81. foreach ($this->constants as $item) {
  82. $item->treeWalk($function_name, $this);
  83. }
  84.  
  85. foreach ($this->enumerations as $item) {
  86. $item->treeWalk($function_name, $this);
  87. }
  88. }
  89.  
  90.  
  91. /**
  92.   * Debugging use only
  93.   **/
  94. public function dump()
  95. {
  96. echo '<div style="border: 1px black solid;">';
  97. echo $this->name;
  98. echo "<pre>{$this->description}</pre>";
  99. foreach ($this->functions as $a) $a->dump();
  100. foreach ($this->classes as $a) $a->dump();
  101. foreach ($this->constants as $a) $a->dump();
  102. foreach ($this->enumerations as $a) $a->dump();
  103.  
  104. parent::dump();
  105. echo '</div>';
  106. }
  107.  
  108.  
  109. }
  110.  
  111.  
  112. ?>
  113.