summaryrefslogtreecommitdiff
path: root/ext/spl/tests/bug62059.phpt
blob: 241dc5a8c13862bfa7a065c331a809e6ffd55c92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
--TEST--
Bug #62059: ArrayObject and isset are not friends
--FILE--
<?php

class MyArrayObject1 extends ArrayObject {
    public function offsetGet($name) {
        echo "offsetGet($name)\n";
        return parent::offsetGet($name);
    }
    public function offsetExists($name) {
        echo "offsetExists($name)\n";
        return parent::offsetExists($name);
    }
}
class MyArrayObject2 extends ArrayObject {
    public function offsetGet($name) {
        echo "offsetGet($name)\n";
        return parent::offsetGet($name);
    }
}
class MyArrayObject3 extends ArrayObject {
    public function offsetExists($name) {
        echo "offsetExists($name)\n";
        return parent::offsetExists($name);
    }
}

$arr = [1 => [1 => 42]];
$ao = new ArrayObject($arr);
var_dump(isset($ao[0][1]));
var_dump(isset($ao[1][0]));
var_dump(isset($ao[1][1]));
$ao = new MyArrayObject1($arr);
var_dump(isset($ao[0][1]));
var_dump(isset($ao[1][0]));
var_dump(isset($ao[1][1]));
$ao = new MyArrayObject2($arr);
var_dump(isset($ao[0][1]));
var_dump(isset($ao[1][0]));
var_dump(isset($ao[1][1]));
$ao = new MyArrayObject3($arr);
var_dump(isset($ao[0][1]));
var_dump(isset($ao[1][0]));
var_dump(isset($ao[1][1]));

?>
--EXPECT--
bool(false)
bool(false)
bool(true)
offsetExists(0)
bool(false)
offsetExists(1)
offsetGet(1)
bool(false)
offsetExists(1)
offsetGet(1)
bool(true)
bool(false)
offsetGet(1)
bool(false)
offsetGet(1)
bool(true)
offsetExists(0)
bool(false)
offsetExists(1)
bool(false)
offsetExists(1)
bool(true)