ReflectionObject_getConstants_basic.phpt 851 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --TEST--
  2. ReflectionObject::getConstants() - basic function test
  3. --FILE--
  4. <?php
  5. class C {
  6. const a = 'hello from C';
  7. }
  8. class D extends C {
  9. }
  10. class E extends D {
  11. }
  12. class F extends E {
  13. const a = 'hello from F';
  14. }
  15. class X {
  16. }
  17. $classes = array("C", "D", "E", "F", "X");
  18. foreach($classes as $class) {
  19. echo "Reflecting on instance of class $class: \n";
  20. $rc = new ReflectionObject(new $class);
  21. var_dump($rc->getConstants());
  22. }
  23. ?>
  24. --EXPECT--
  25. Reflecting on instance of class C:
  26. array(1) {
  27. ["a"]=>
  28. string(12) "hello from C"
  29. }
  30. Reflecting on instance of class D:
  31. array(1) {
  32. ["a"]=>
  33. string(12) "hello from C"
  34. }
  35. Reflecting on instance of class E:
  36. array(1) {
  37. ["a"]=>
  38. string(12) "hello from C"
  39. }
  40. Reflecting on instance of class F:
  41. array(1) {
  42. ["a"]=>
  43. string(12) "hello from F"
  44. }
  45. Reflecting on instance of class X:
  46. array(0) {
  47. }