summaryrefslogtreecommitdiff
path: root/Zend/tests/bug70321.phpt
blob: 6e490555be4d9bff31391f5cee7f302b218467d7 (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
--TEST--
bug #70321 (Magic getter breaks reference to array property)
--FILE--
<?php
class foo implements arrayAccess
{
    private $bar;
    public function __construct()
    {
        $this->bar = new bar();
    }
    public function & __get($key)
    {
        $bar = $this->bar;
        return $bar;
    }

    public function & offsetGet($key) {
        $bar = $this->bar;
        return $bar;
    }
    public function offsetSet($key, $val) {
    }
    public function offsetUnset($key) {
    }
    public function offsetExists($key) {
    }
}
class bar { public $onBaz = []; }

$foo = new foo();
$foo->bar->onBaz[] = function() {};
var_dump($foo->bar->onBaz);

$foo = new foo();
$foo["bar"]->onBaz[] = function() {};
var_dump($foo->bar->onBaz);
?>
--EXPECTF--
array(1) {
  [0]=>
  object(Closure)#%d (0) {
  }
}
array(1) {
  [0]=>
  object(Closure)#%d (0) {
  }
}