ReflectionClassConstant_unset_name.phpt 644 B

12345678910111213141516171819202122232425262728
  1. --TEST--
  2. Unsetting name on ReflectionClassConstant
  3. --FILE--
  4. <?php
  5. class Test {
  6. public const C = 1;
  7. }
  8. // This is unsupported and the actual behavior doesn't matter.
  9. // Just make sure it doesn't crash.
  10. $rc = new ReflectionClassConstant(Test::class, 'C');
  11. unset($rc->name);
  12. try {
  13. var_dump($rc->getName());
  14. } catch (Error $e) {
  15. echo $e->getMessage(), "\n";
  16. }
  17. try {
  18. echo $rc, "\n";
  19. } catch (Error $e) {
  20. echo $e->getMessage(), "\n";
  21. }
  22. ?>
  23. --EXPECT--
  24. Typed property ReflectionClassConstant::$name must not be accessed before initialization
  25. Typed property ReflectionClassConstant::$name must not be accessed before initialization