1--TEST--
2ZE2 ArrayAccess and ASSIGN_OP operators (.=)
3--FILE--
4<?php
5
6class Peoples implements ArrayAccess {
7    public $person;
8
9    function __construct() {
10        $this->person = array(array('name'=>'Foo'));
11    }
12
13    function offsetExists($index) {
14        return array_key_exists($this->person, $index);
15    }
16
17    function offsetGet($index) {
18        return $this->person[$index];
19    }
20
21    function offsetSet($index, $value) {
22        $this->person[$index] = $value;
23    }
24
25    function offsetUnset($index) {
26        unset($this->person[$index]);
27    }
28}
29
30$people = new Peoples;
31
32var_dump($people->person[0]['name']);
33$people->person[0]['name'] = $people->person[0]['name'] . 'Bar';
34var_dump($people->person[0]['name']);
35$people->person[0]['name'] .= 'Baz';
36var_dump($people->person[0]['name']);
37
38echo "===ArrayOverloading===\n";
39
40$people = new Peoples;
41
42var_dump($people[0]['name']);
43$people[0]['name'] = 'FooBar';
44var_dump($people[0]['name']);
45$people[0]['name'] = $people->person[0]['name'] . 'Bar';
46var_dump($people[0]['name']);
47$people[0]['name'] .= 'Baz';
48var_dump($people[0]['name']);
49
50?>
51--EXPECTF--
52string(3) "Foo"
53string(6) "FooBar"
54string(9) "FooBarBaz"
55===ArrayOverloading===
56string(3) "Foo"
57
58Notice: Indirect modification of overloaded element of Peoples has no effect in %sarray_access_008.php on line 40
59string(3) "Foo"
60
61Notice: Indirect modification of overloaded element of Peoples has no effect in %sarray_access_008.php on line 42
62string(3) "Foo"
63
64Notice: Indirect modification of overloaded element of Peoples has no effect in %sarray_access_008.php on line 44
65string(3) "Foo"
66