ReflectionObject_isInstantiable_variation.phpt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. --TEST--
  2. ReflectionObject::IsInstantiable() - variation - constructors
  3. --FILE--
  4. <?php
  5. class noCtor {
  6. public static function reflectionObjectFactory() {
  7. return new ReflectionObject(new self);
  8. }
  9. }
  10. class publicCtorNew {
  11. public function __construct() {}
  12. public static function reflectionObjectFactory() {
  13. return new ReflectionObject(new self);
  14. }
  15. }
  16. class protectedCtorNew {
  17. protected function __construct() {}
  18. public static function reflectionObjectFactory() {
  19. return new ReflectionObject(new self);
  20. }
  21. }
  22. class privateCtorNew {
  23. private function __construct() {}
  24. public static function reflectionObjectFactory() {
  25. return new ReflectionObject(new self);
  26. }
  27. }
  28. class publicCtorOld {
  29. public function publicCtorOld() {}
  30. public static function reflectionObjectFactory() {
  31. return new ReflectionObject(new self);
  32. }
  33. }
  34. class protectedCtorOld {
  35. protected function protectedCtorOld() {}
  36. public static function reflectionObjectFactory() {
  37. return new ReflectionObject(new self);
  38. }
  39. }
  40. class privateCtorOld {
  41. private function privateCtorOld() {}
  42. public static function reflectionObjectFactory() {
  43. return new ReflectionObject(new self);
  44. }
  45. }
  46. $reflectionObjects = array(
  47. noCtor::reflectionObjectFactory(),
  48. publicCtorNew::reflectionObjectFactory(),
  49. protectedCtorNew::reflectionObjectFactory(),
  50. privateCtorNew::reflectionObjectFactory(),
  51. publicCtorOld::reflectionObjectFactory(),
  52. protectedCtorOld::reflectionObjectFactory(),
  53. privateCtorOld::reflectionObjectFactory()
  54. );
  55. foreach($reflectionObjects as $reflectionObject ) {
  56. $name = $reflectionObject->getName();
  57. echo "Is $name instantiable? ";
  58. var_dump($reflectionObject->IsInstantiable());
  59. }
  60. ?>
  61. --EXPECTF--
  62. Is noCtor instantiable? bool(true)
  63. Is publicCtorNew instantiable? bool(true)
  64. Is protectedCtorNew instantiable? bool(false)
  65. Is privateCtorNew instantiable? bool(false)
  66. Is publicCtorOld instantiable? bool(true)
  67. Is protectedCtorOld instantiable? bool(false)
  68. Is privateCtorOld instantiable? bool(false)