File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / classes / array_access_006.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 and ASSIGN_OP operators (+=)
    3: --FILE--
    4: <?php 
    5: 
    6: class OverloadedArray implements ArrayAccess {
    7: 	public $realArray;
    8: 	
    9: 	function __construct() {
   10: 		$this->realArray = array(1,2,3);
   11: 	}
   12: 
   13: 	function offsetExists($index) {
   14: 		return array_key_exists($this->realArray, $index);
   15: 	}
   16: 
   17: 	function offsetGet($index) {
   18: 		return $this->realArray[$index];
   19: 	}
   20: 
   21: 	function offsetSet($index, $value) {
   22: 		$this->realArray[$index] = $value;
   23: 	}
   24: 
   25: 	function offsetUnset($index) {
   26: 		unset($this->realArray[$index]);
   27: 	}
   28: }
   29: 
   30: $a = new OverloadedArray;
   31: $a[1] += 10;
   32: var_dump($a[1]);
   33: echo "---Done---\n";
   34: ?>
   35: --EXPECT--
   36: int(12)
   37: ---Done---

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