Pelzini Tests

This is the code documentation for the Pelzini Tests project

source of /php_test.php

Tests the PHP parsing system
  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. * Tests the PHP parsing system
  23. *
  24. * @package Test suite
  25. * @author Josh
  26. * @since 0.1
  27. **/
  28.  
  29.  
  30. /*
  31. ENABLE THIS TO VALIDATE THE FILE
  32.  
  33. class php_missing_base_class {}
  34. interface php_missing_interface {}
  35. */
  36.  
  37.  
  38. /**
  39. * A constant
  40. * @author josh
  41. * @since 0.1
  42. **/
  43. define ('PHP_DOCUMENTED_CONST', 42);
  44.  
  45. define ('PHP_STRING_CONST', 'blah');
  46. define ('PHP_NUMBER_CONST', 42);
  47. define ('PHP_FLOAT_CONST', 4.2);
  48. define ('PHP_NULL_CONST', null);
  49. define ('PHP_NULL_CONST2', NULL);
  50.  
  51.  
  52. /**
  53. * Does not contain arguments
  54. */
  55. function php_documented_function () {
  56. return;
  57. }
  58.  
  59. /**
  60. * Contains arguments
  61. * @param string $arg1 The first argument
  62. * @param string $arg2 The second argument
  63. * @author Monkey Man <monkey.man@example.com>
  64. * @since r567
  65. **/
  66. function php_documented_arguments_function ($arg1, $arg2) {
  67. return;
  68. }
  69.  
  70. /**
  71. * The param tags don't have names
  72. * @param string This one is a string
  73. * @param int This one is an int
  74. **/
  75. function php_noname_arguments_function($arg1, $arg2) {
  76. return;
  77. }
  78.  
  79. /**
  80. * The param tags don't have names
  81. * @param $arg1 string This one is a string
  82. * @param $arg2 int This one is an int
  83. **/
  84. function php_reverse_order_arguments_function($arg1, $arg2) {
  85. return;
  86. }
  87.  
  88. /**
  89. * Contains arguments
  90. **/
  91. function php_typehint_only_arguments_function1($arg1, array $arg2) {
  92. return;
  93. }
  94.  
  95. # Doesn't contain a docblock
  96. function php_typehint_only_arguments_function2($arg1, array $arg2) {
  97. return;
  98. }
  99.  
  100. /**
  101. * Contains arguments with defaults
  102. *
  103. * This description contains inline links.
  104. * - Link to class: {@link php_documented_super_class}
  105. * - Link to function: {@link php_documented_arguments_function}
  106. * - Link to function: {@link php_documented_arguments_function()}
  107. * - Link to constant: {@link PHP_STRING_CONST}
  108. * - Link to file: {@link processor/main.php}
  109. * - Link to file: {@link /processor/main.php}
  110. * - Link to file: {@link main.php}
  111. * - Link to method: {@link php_documented_super_class::php_documented_method()}
  112. * - Link to variable: {@link php_documented_super_class::$php_var1}
  113. * - Link to website: {@link http://www.ahi.org.au}
  114. * - Link to website: {@link http://www.ahi.org.au Australia HOPE International}
  115. *
  116. * @param string $arg1 Default is 'default1'
  117. * @param string $arg2 Default is 100
  118. * @param string $arg3 Default is 15.2
  119. * @param string $arg4 Default is null
  120. * @param string $arg5 Default is true
  121. * @param string $arg6 Default is false
  122. * @author Josh <josh@example.com>
  123. * @author Bob <bob@example.com>
  124. **/
  125. function php_documented_default_arguments_function ($arg1 = 'default1', $arg2 = 100, $arg3 = 15.2, $arg4 = null, $arg5 = true, $arg6 = false) {
  126. return;
  127. }
  128.  
  129. /**
  130. * Contatins typehinted arguments
  131. * @param php_documented_super_class $arg1 Argument 1
  132. * @param php_documented_base_class $arg2 Argument 2
  133. * @param php_missing_class $arg3 Argument 3 (class is not defined in this code)
  134. * @return string The result
  135. * @author Josh, initial work
  136. * @author bob, additional work
  137. **/
  138. function php_documented_typehinting_function (php_documented_super_class $arg1, php_documented_base_class $arg2, php_missing_class $arg3) {
  139. return 'the result';
  140. }
  141.  
  142. /**
  143. * Has something.
  144. * @param $arg1 string something weird
  145. * @param $arg2 something else @param
  146.  * @param $arg2 Redefined.
  147.  * @param string $arg3 defined as one thing in code and something else in comment
  148. * @param integer $arg100 who knows? **/
  149. function php_badly_documented_function ($arg1, $arg2 = 100, php_documented_super_class $arg3) {
  150. return;
  151. }
  152.  
  153. /**
  154. * @return string Sometimes
  155. * @return int Other times
  156. **/
  157. function php_multiple_returns_function() {
  158. return;
  159. }
  160.  
  161. /**
  162. * Parent class is not defined in this code
  163. * @author josh <josh@example.com> did some work
  164. * @author bob <bob@example.com> did some more work
  165. * @since 0.1
  166. **/
  167. abstract class php_documented_base_class extends php_missing_base_class {
  168. private $base_private;
  169. protected $base_protected;
  170. public $base_public;
  171.  
  172. /**
  173.   * This method is final. It is in an abstract class.
  174.   **/
  175. final public function php_documented_final_method () {
  176. return 1337;
  177. }
  178. }
  179.  
  180. /**
  181. * A super class
  182. * - extends php_documented_base_class.
  183. * - implements php_documented_interface
  184. * - implements php_missing_interface (not defined in this code)
  185. **/
  186. final class php_documented_super_class extends php_documented_base_class implements php_documented_interface, php_missing_interface {
  187. private $super_private;
  188. protected $super_protected;
  189. public $super_public;
  190.  
  191. /**
  192.   * Stores some information about something
  193.   * @author josh, 2008-10-10
  194.   * @since 0.1
  195.   **/
  196. private $php_var1;
  197.  
  198. private $php_var2; /// stores some more information
  199.  
  200. static public $php_var3;
  201.  
  202.  
  203. /**
  204.   *** Does soemthing else
  205.   * @author josh, somehting
  206.   * @since 0.1
  207.   **/
  208. public function php_documented_method () {
  209. foreach ($foo as $bar) {
  210. if ($baz) {
  211. echo $this->php_var2;
  212. }
  213. }
  214. }
  215.  
  216. /**
  217.   * Contains arguments
  218.   * @param string $arg1 The first argument
  219.   * @param string $arg2 The second argument
  220.   * @author
  221.   **/
  222. public function php_documented_arguments_method ($arg1, $arg2) {
  223. static $random_variable;
  224. if ($arg1) {
  225. echo $this->php_var1;
  226. }
  227. }
  228.  
  229. /** A static method */
  230. static public function php_documented_static_method () {
  231. return 42;
  232. }
  233.  
  234.  
  235. function aaa() {}
  236. function bbb() {}
  237. function ccc($foo) {}
  238. function ddd($foo) {}
  239. function eee(php_documented_base_class $foo) {}
  240. function fff($foo = 100) {}
  241. }
  242.  
  243. /**
  244. * An interface
  245. * @author peter
  246. * @since 0.1
  247. **/
  248. interface php_documented_interface {
  249.  
  250. function aaa();
  251.  
  252. /**
  253.   * Something
  254.   * @author josh
  255.   **/
  256. function bbb();
  257.  
  258. /** @param string $foo does whatever **/
  259. function ccc($foo);
  260.  
  261. /** @param $foo hmm
  262.   * @param $foo nothing param **/
  263. function ddd($foo);
  264.  
  265. function eee(php_documented_base_class $foo);
  266.  
  267. function fff($foo = 100);
  268. }
  269. ?>
  270.