no-write-properties-through-foreach-reference.phpt 343 B

12345678910111213141516171819202122
  1. --TEST--
  2. Enum properties cannot be written to through reference in foreach
  3. --FILE--
  4. <?php
  5. enum Foo: int {
  6. case Bar = 0;
  7. }
  8. try {
  9. $bar = Foo::Bar;
  10. foreach ([1] as &$bar->value) {}
  11. } catch (Error $e) {
  12. echo $e->getMessage() . "\n";
  13. }
  14. var_dump(Foo::Bar->value);
  15. ?>
  16. --EXPECT--
  17. Cannot modify readonly property Foo::$value
  18. int(0)