Annotation of embedaddon/php/tests/classes/array_access_007.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: ZE2 ArrayAccess and [] assignment
        !             3: --FILE--
        !             4: <?php 
        !             5: 
        !             6: class OverloadedArray implements ArrayAccess {
        !             7:        public $realArray;
        !             8:        
        !             9:        function __construct() {
        !            10:                $this->realArray = array();
        !            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:                if (is_null($index)) {
        !            23:                        $this->realArray[] = $value;
        !            24:                } else {
        !            25:                        $this->realArray[$index] = $value;
        !            26:                }
        !            27:        }
        !            28: 
        !            29:        function offsetUnset($index) {
        !            30:                unset($this->realArray[$index]);
        !            31:        }
        !            32: 
        !            33:        function dump() {
        !            34:                var_dump($this->realArray);
        !            35:        }
        !            36: }
        !            37: 
        !            38: $a = new OverloadedArray;
        !            39: $a[] = 1;
        !            40: $a[1] = 2;
        !            41: $a[2] = 3;
        !            42: $a[] = 4;
        !            43: $a->dump();
        !            44: ?>
        !            45: ===DONE===
        !            46: --EXPECT--
        !            47: array(4) {
        !            48:   [0]=>
        !            49:   int(1)
        !            50:   [1]=>
        !            51:   int(2)
        !            52:   [2]=>
        !            53:   int(3)
        !            54:   [3]=>
        !            55:   int(4)
        !            56: }
        !            57: ===DONE===

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