ReflectionClass_isInstantiable_variation.phpt 712 B

1234567891011121314151617181920212223242526272829303132
  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. $classes = array("noCtor", "publicCtorNew", "protectedCtorNew", "privateCtorNew");
  17. foreach ($classes as $class) {
  18. $reflectionClass = new ReflectionClass($class);
  19. echo "Is $class instantiable? ";
  20. var_dump($reflectionClass->IsInstantiable());
  21. }
  22. ?>
  23. --EXPECT--
  24. Is noCtor instantiable? bool(true)
  25. Is publicCtorNew instantiable? bool(true)
  26. Is protectedCtorNew instantiable? bool(false)
  27. Is privateCtorNew instantiable? bool(false)