array_access_012.phpt 807 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. ZE2 ArrayAccess cannot assign by reference
  3. --FILE--
  4. <?php
  5. class ArrayAccessImpl implements ArrayAccess {
  6. private $data = array();
  7. public function offsetUnset($index) {}
  8. public function offsetSet($index, $value) {
  9. $this->data[$index] = $value;
  10. }
  11. public function offsetGet($index) {
  12. return $this->data[$index];
  13. }
  14. public function offsetExists($index) {
  15. return isset($this->data[$index]);
  16. }
  17. }
  18. $data = new ArrayAccessImpl();
  19. $test = 'some data';
  20. $data['element'] = NULL; // prevent notice
  21. $data['element'] = &$test;
  22. ?>
  23. ===DONE===
  24. <?php exit(0); ?>
  25. --EXPECTF--
  26. Notice: Indirect modification of overloaded element of ArrayAccessImpl has no effect in %sarray_access_012.php on line 24
  27. Fatal error: Cannot assign by reference to overloaded object in %sarray_access_012.php on line 24