Annotation of embedaddon/php/Zend/tests/dereference_005.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Testing array dereference on object that implements ArrayAccess
3: --FILE--
4: <?php
5:
6: error_reporting(E_ALL);
7:
8: class obj implements arrayaccess {
9: private $container = array();
10: public function __construct() {
11: $this->container = array(
12: "one" => 1,
13: "two" => 2,
14: "three" => 3,
15: );
16: }
17: public function offsetSet($offset, $value) {
18: $this->container[$offset] = $value;
19: }
20: public function offsetExists($offset) {
21: return isset($this->container[$offset]);
22: }
23: public function offsetUnset($offset) {
24: unset($this->container[$offset]);
25: }
26: public function offsetGet($offset) {
27: return isset($this->container[$offset]) ? $this->container[$offset] : null;
28: }
29: }
30:
31: function x() {
32: return new obj;
33: }
34: var_dump(x()['two']);
35:
36: ?>
37: --EXPECT--
38: int(2)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>