constants_basic_006.phpt 726 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. Ensure class constants are not evaluated when a class is looked up to resolve inheritance during runtime.
  3. --FILE--
  4. <?php
  5. class C
  6. {
  7. const X = E::A;
  8. public static $a = array(K => D::V, E::A => K);
  9. }
  10. eval('class D extends C { const V = \'test\'; }');
  11. class E extends D
  12. {
  13. const A = "hello";
  14. }
  15. define('K', "nasty");
  16. var_dump(C::X, C::$a, D::X, D::$a, E::X, E::$a);
  17. ?>
  18. --EXPECTF--
  19. string(5) "hello"
  20. array(2) {
  21. ["nasty"]=>
  22. string(4) "test"
  23. ["hello"]=>
  24. string(5) "nasty"
  25. }
  26. string(5) "hello"
  27. array(2) {
  28. ["nasty"]=>
  29. string(4) "test"
  30. ["hello"]=>
  31. string(5) "nasty"
  32. }
  33. string(5) "hello"
  34. array(2) {
  35. ["nasty"]=>
  36. string(4) "test"
  37. ["hello"]=>
  38. string(5) "nasty"
  39. }