ReflectionObject_isInstantiable_variation.phpt 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; publicCtorOld has a deprecated constructor in %s on line %d
  63. Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; protectedCtorOld has a deprecated constructor in %s on line %d
  64. Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; privateCtorOld has a deprecated constructor in %s on line %d
  65. Is noCtor instantiable? bool(true)
  66. Is publicCtorNew instantiable? bool(true)
  67. Is protectedCtorNew instantiable? bool(false)
  68. Is privateCtorNew instantiable? bool(false)
  69. Is publicCtorOld instantiable? bool(true)
  70. Is protectedCtorOld instantiable? bool(false)
  71. Is privateCtorOld instantiable? bool(false)