ReflectionObject_isInstantiable_variation.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. $reflectionObjects = array(
  29. noCtor::reflectionObjectFactory(),
  30. publicCtorNew::reflectionObjectFactory(),
  31. protectedCtorNew::reflectionObjectFactory(),
  32. privateCtorNew::reflectionObjectFactory(),
  33. );
  34. foreach ($reflectionObjects as $reflectionObject) {
  35. $name = $reflectionObject->getName();
  36. echo "Is $name instantiable? ";
  37. var_dump($reflectionObject->IsInstantiable());
  38. }
  39. ?>
  40. --EXPECT--
  41. Is noCtor instantiable? bool(true)
  42. Is publicCtorNew instantiable? bool(true)
  43. Is protectedCtorNew instantiable? bool(false)
  44. Is privateCtorNew instantiable? bool(false)