File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / classes / array_access_012.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:06 2012 UTC (12 years, 5 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>