ReflectionClass_isInstantiable_variation.phpt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. --TEST--
  2. ReflectionClass::IsInstantiable()
  3. --FILE--
  4. <?php
  5. class noCtor {
  6. }
  7. class publicCtorNew {
  8. public function __construct() {}
  9. }
  10. class protectedCtorNew {
  11. protected function __construct() {}
  12. }
  13. class privateCtorNew {
  14. private function __construct() {}
  15. }
  16. class publicCtorOld {
  17. public function publicCtorOld() {}
  18. }
  19. class protectedCtorOld {
  20. protected function protectedCtorOld() {}
  21. }
  22. class privateCtorOld {
  23. private function privateCtorOld() {}
  24. }
  25. $classes = array("noCtor", "publicCtorNew", "protectedCtorNew", "privateCtorNew",
  26. "publicCtorOld", "protectedCtorOld", "privateCtorOld");
  27. foreach($classes as $class ) {
  28. $reflectionClass = new ReflectionClass($class);
  29. echo "Is $class instantiable? ";
  30. var_dump($reflectionClass->IsInstantiable());
  31. }
  32. ?>
  33. --EXPECTF--
  34. 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
  35. 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
  36. 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
  37. Is noCtor instantiable? bool(true)
  38. Is publicCtorNew instantiable? bool(true)
  39. Is protectedCtorNew instantiable? bool(false)
  40. Is privateCtorNew instantiable? bool(false)
  41. Is publicCtorOld instantiable? bool(true)
  42. Is protectedCtorOld instantiable? bool(false)
  43. Is privateCtorOld instantiable? bool(false)