Pelzini

This is the code documentation for the Pelzini project

source of /processor/parser_class.php

Contains the ParserClass 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. /**
  23.  * Contains the {@link ParserClass} class
  24.  *
  25.  * @package Parser model
  26.  * @author Josh Heidenreich
  27.  * @since 0.1
  28.  **/
  29.  
  30. /**
  31.  * Stores information about a specific class
  32.  **/
  33. class ParserClass extends CodeParserItem {
  34. public $name;
  35. public $functions;
  36. public $variables;
  37. public $visibility;
  38. public $extends;
  39. public $implements;
  40. public $abstract;
  41. public $description;
  42. public $final;
  43.  
  44. /**
  45.   * Creates this object
  46.   **/
  47. public function __construct()
  48. {
  49. parent::__construct();
  50.  
  51. $this->functions = array ();
  52. $this->variables = array ();
  53. $this->implements = array ();
  54. $this->visibility = 'public';
  55. $this->final = false;
  56. }
  57.  
  58.  
  59. /**
  60.   * Applies the contents of a doc-block to this element
  61.   *
  62.   * @param $text The content of the DocBlock
  63.   **/
  64. protected function processSpecificDocblockTags($docblock_tags)
  65. {
  66. $this->description = htmlify_text(@$docblock_tags['@summary']);
  67. }
  68.  
  69.  
  70. /**
  71.   * Cascades Docblock tags into the children that do not have any tags, and then
  72.   * runs processTags() for all of the children items.
  73.   **/
  74. public function treeWalk($function_name, ParserItem $parent_item = null)
  75. {
  76. call_user_func($function_name, $this, $parent_item);
  77.  
  78. foreach ($this->functions as $item) {
  79. $item->treeWalk($function_name, $this);
  80. }
  81.  
  82. foreach ($this->variables as $item) {
  83. $item->treeWalk($function_name, $this);
  84. }
  85. }
  86.  
  87.  
  88. /**
  89.   * Debugging use only
  90.   **/
  91. public function dump()
  92. {
  93. echo '<div style="border: 1px blue solid;">';
  94. echo $this->visibility . ' ';
  95. echo $this->name;
  96.  
  97. if ($this->extends) echo '<br>extends ' . $this->extends;
  98. if ($this->implements) echo '<br>implements ' . implode(', ', $this->implements);
  99.  
  100. if ($this->abstract) echo '<br>abstract';
  101. if ($this->final) echo '<br>final';
  102.  
  103. echo '<br>' . $this->description;
  104.  
  105. foreach ($this->variables as $a) $a->dump();
  106. foreach ($this->functions as $a) $a->dump();
  107.  
  108. parent::dump();
  109. echo '</div>';
  110. }
  111.  
  112.  
  113. }
  114.  
  115.  
  116. ?>
  117.