You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
846 B

21 years ago
20 years ago
20 years ago
21 years ago
  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: Objects used as arrays in post/pre increment/decrement must return values by reference in %sarray_access_012.php on line %d