no-unset-propertes.phpt 579 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --TEST--
  2. Enum properties cannot be unset
  3. --FILE--
  4. <?php
  5. enum Foo {
  6. case Bar;
  7. }
  8. enum IntFoo: int {
  9. case Bar = 0;
  10. }
  11. $foo = Foo::Bar;
  12. try {
  13. unset($foo->name);
  14. } catch (Error $e) {
  15. echo $e->getMessage() . "\n";
  16. }
  17. $intFoo = IntFoo::Bar;
  18. try {
  19. unset($intFoo->name);
  20. } catch (Error $e) {
  21. echo $e->getMessage() . "\n";
  22. }
  23. try {
  24. unset($intFoo->value);
  25. } catch (Error $e) {
  26. echo $e->getMessage() . "\n";
  27. }
  28. ?>
  29. --EXPECT--
  30. Cannot unset readonly property Foo::$name
  31. Cannot unset readonly property IntFoo::$name
  32. Cannot unset readonly property IntFoo::$value