reflection_php4.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * base include file for SimpleTest
  4. * @package SimpleTest
  5. * @subpackage UnitTester
  6. * @version $Id: reflection_php4.php 1672 2008-03-02 04:47:34Z edwardzyang $
  7. */
  8. /**
  9. * Version specific reflection API.
  10. * @package SimpleTest
  11. * @subpackage UnitTester
  12. * @ignore duplicate with reflection_php5.php
  13. */
  14. class SimpleReflection {
  15. var $_interface;
  16. /**
  17. * Stashes the class/interface.
  18. * @param string $interface Class or interface
  19. * to inspect.
  20. */
  21. function SimpleReflection($interface) {
  22. $this->_interface = $interface;
  23. }
  24. /**
  25. * Checks that a class has been declared.
  26. * @return boolean True if defined.
  27. * @access public
  28. */
  29. function classExists() {
  30. return class_exists($this->_interface);
  31. }
  32. /**
  33. * Needed to kill the autoload feature in PHP5
  34. * for classes created dynamically.
  35. * @return boolean True if defined.
  36. * @access public
  37. */
  38. function classExistsSansAutoload() {
  39. return class_exists($this->_interface);
  40. }
  41. /**
  42. * Checks that a class or interface has been
  43. * declared.
  44. * @return boolean True if defined.
  45. * @access public
  46. */
  47. function classOrInterfaceExists() {
  48. return class_exists($this->_interface);
  49. }
  50. /**
  51. * Needed to kill the autoload feature in PHP5
  52. * for classes created dynamically.
  53. * @return boolean True if defined.
  54. * @access public
  55. */
  56. function classOrInterfaceExistsSansAutoload() {
  57. return class_exists($this->_interface);
  58. }
  59. /**
  60. * Gets the list of methods on a class or
  61. * interface.
  62. * @returns array List of method names.
  63. * @access public
  64. */
  65. function getMethods() {
  66. return get_class_methods($this->_interface);
  67. }
  68. /**
  69. * Gets the list of interfaces from a class. If the
  70. * class name is actually an interface then just that
  71. * interface is returned.
  72. * @returns array List of interfaces.
  73. * @access public
  74. */
  75. function getInterfaces() {
  76. return array();
  77. }
  78. /**
  79. * Finds the parent class name.
  80. * @returns string Parent class name.
  81. * @access public
  82. */
  83. function getParent() {
  84. return strtolower(get_parent_class($this->_interface));
  85. }
  86. /**
  87. * Determines if the class is abstract, which for PHP 4
  88. * will never be the case.
  89. * @returns boolean True if abstract.
  90. * @access public
  91. */
  92. function isAbstract() {
  93. return false;
  94. }
  95. /**
  96. * Determines if the the entity is an interface, which for PHP 4
  97. * will never be the case.
  98. * @returns boolean True if interface.
  99. * @access public
  100. */
  101. function isInterface() {
  102. return false;
  103. }
  104. /**
  105. * Scans for final methods, but as it's PHP 4 there
  106. * aren't any.
  107. * @returns boolean True if the class has a final method.
  108. * @access public
  109. */
  110. function hasFinal() {
  111. return false;
  112. }
  113. /**
  114. * Gets the source code matching the declaration
  115. * of a method.
  116. * @param string $method Method name.
  117. * @access public
  118. */
  119. function getSignature($method) {
  120. return "function &$method()";
  121. }
  122. }
  123. ?>