no-write-properties-cache-slot.phpt 479 B

123456789101112131415161718192021222324252627
  1. --TEST--
  2. Readonly enum properties should not be writable via cache slot merging
  3. --FILE--
  4. <?php
  5. enum Test {
  6. case A;
  7. public function modify() {
  8. // Cache slots for the read and write are merged.
  9. var_dump($this->name);
  10. $this->name = 'foobar';
  11. }
  12. }
  13. try {
  14. Test::A->modify();
  15. } catch (Error $e) {
  16. echo $e->getMessage(), "\n";
  17. }
  18. var_dump(Test::A->name);
  19. ?>
  20. --EXPECT--
  21. string(1) "A"
  22. Cannot modify readonly property Test::$name
  23. string(1) "A"