constants_visibility_004.phpt 523 B

12345678910111213141516171819202122232425262728
  1. --TEST--
  2. Only public and protected class constants should be inherited
  3. --FILE--
  4. <?php
  5. class A {
  6. public const X = 1;
  7. protected const Y = 2;
  8. private const Z = 3;
  9. }
  10. class B extends A {
  11. static public function checkConstants() {
  12. var_dump(self::X);
  13. var_dump(self::Y);
  14. var_dump(self::Z);
  15. }
  16. }
  17. B::checkConstants();
  18. ?>
  19. --EXPECTF--
  20. int(1)
  21. int(2)
  22. Fatal error: Uncaught Error: Undefined constant B::Z in %s:%d
  23. Stack trace:
  24. #0 %s(15): B::checkConstants()
  25. #1 {main}
  26. thrown in %s on line 11